PageRenderTime 31ms CodeModel.GetById 17ms RepoModel.GetById 0ms app.codeStats 0ms

/src/main/native/PRIMME/PRIMMESRC/COMMONSRC/primme.h

http://array4j.googlecode.com/
C Header | 249 lines | 180 code | 36 blank | 33 comment | 0 complexity | 8e730089f1948d76f1b3d7b164b4e61d MD5 | raw file
Possible License(s): GPL-2.0
  1. /*******************************************************************************
  2. * PRIMME PReconditioned Iterative MultiMethod Eigensolver
  3. * Copyright (C) 2005 James R. McCombs, Andreas Stathopoulos
  4. *
  5. * This file is part of PRIMME.
  6. *
  7. * PRIMME is free software; you can redistribute it and/or
  8. * modify it under the terms of the GNU Lesser General Public
  9. * License as published by the Free Software Foundation; either
  10. * version 2.1 of the License, or (at your option) any later version.
  11. *
  12. * PRIMME is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  15. * Lesser General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU Lesser General Public
  18. * License along with this library; if not, write to the Free Software
  19. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  20. *
  21. * File: primme.h
  22. *
  23. * Purpose - To be included in user applications that wish to call primme.
  24. *
  25. ******************************************************************************/
  26. #ifndef PRIMME_H
  27. #define PRIMME_H
  28. #include <stdio.h>
  29. #include <sys/types.h>
  30. #include <limits.h>
  31. #include "Complex.h"
  32. #if 1
  33. #ifdef PRIMME_EXPORTS
  34. #define PRIMME_API __declspec(dllexport)
  35. #else
  36. #define PRIMME_API __declspec(dllimport)
  37. #endif
  38. #else
  39. #define PRIMME_API
  40. #endif
  41. #define PRIMME_MAX_NAME_LENGTH 128
  42. typedef enum {
  43. Primme_dprimme,
  44. Primme_zprimme,
  45. Primme_check_input,
  46. Primme_allocate_workspace,
  47. Primme_main_iter,
  48. Primme_init_basis,
  49. Primme_init_block_krylov,
  50. Primme_init_krylov,
  51. Primme_ortho,
  52. Primme_solve_h,
  53. Primme_restart,
  54. Primme_restart_h,
  55. Primme_insert_submatrix,
  56. Primme_lock_vectors,
  57. Primme_num_dsyev,
  58. Primme_num_zheev,
  59. Primme_num_dspev,
  60. Primme_num_zhpev,
  61. Primme_ududecompose,
  62. Primme_udusolve,
  63. Primme_apply_projected_preconditioner,
  64. Primme_apply_skew_projector,
  65. Primme_inner_solve,
  66. Primme_solve_correction,
  67. Primme_fopen,
  68. Primme_malloc
  69. } primme_function;
  70. typedef enum {
  71. primme_smallest,
  72. primme_largest,
  73. primme_closest_geq,
  74. primme_closest_leq,
  75. primme_closest_abs
  76. } primme_target;
  77. typedef enum {
  78. primme_thick,
  79. primme_dtr
  80. } primme_restartscheme;
  81. typedef enum {
  82. primme_full_LTolerance,
  83. primme_decreasing_LTolerance,
  84. primme_adaptive_ETolerance,
  85. primme_adaptive,
  86. } primme_convergencetest;
  87. typedef struct stackTraceNode {
  88. primme_function callingFunction;
  89. primme_function failedFunction;
  90. int errorCode;
  91. int lineNumber;
  92. char fileName[PRIMME_MAX_NAME_LENGTH];
  93. struct stackTraceNode *nextNode;
  94. } stackTraceNode;
  95. typedef struct primme_stats {
  96. int numOuterIterations;
  97. int numRestarts;
  98. int numMatvecs;
  99. int numPreconds;
  100. double elapsedTime;
  101. } primme_stats;
  102. typedef struct JD_projectors {
  103. int LeftQ;
  104. int LeftX;
  105. int RightQ;
  106. int RightX;
  107. int SkewQ;
  108. int SkewX;
  109. } JD_projectors;
  110. typedef struct correction_params {
  111. int precondition;
  112. int robustShifts;
  113. int maxInnerIterations;
  114. struct JD_projectors projectors;
  115. primme_convergencetest convTest;
  116. double relTolBase;
  117. } correction_params;
  118. typedef struct restarting_params {
  119. primme_restartscheme scheme;
  120. int maxPrevRetain;
  121. } restarting_params;
  122. //-----------------------------------------------------------------------------
  123. typedef struct primme_params {
  124. // The user must input at least the following two arguments
  125. int n;
  126. void (*matrixMatvec)
  127. ( void *x, void *y, int *blockSize, struct primme_params *primme);
  128. // Preconditioner applied on block of vectors (if available)
  129. void (*applyPreconditioner)
  130. ( void *x, void *y, int *blockSize, struct primme_params *primme);
  131. // Matrix times a multivector for mass matrix B for generalized Ax = xBl
  132. void (*massMatrixMatvec)
  133. ( void *x, void *y, int *blockSize, struct primme_params *primme);
  134. // input for the following is only required for parallel programs
  135. int numProcs;
  136. int procID;
  137. int nLocal;
  138. void *commInfo;
  139. void (*globalSumDouble)
  140. (void *sendBuf, void *recvBuf, int *count, struct primme_params *primme );
  141. // Though primme_initialize will assign defaults, most users will set these
  142. int numEvals;
  143. primme_target target;
  144. int numTargetShifts; // For targeting interior epairs,
  145. double *targetShifts; // at least one shift must also be set
  146. /* the following will be given default values depending on the method */
  147. int dynamicMethodSwitch;
  148. int locking;
  149. int initSize;
  150. int numOrthoConst;
  151. int maxBasisSize;
  152. int minRestartSize;
  153. int maxBlockSize;
  154. int maxMatvecs;
  155. int maxOuterIterations;
  156. int intWorkSize;
  157. long int realWorkSize;
  158. int iseed[4];
  159. int *intWork;
  160. void *realWork;
  161. double aNorm;
  162. double eps;
  163. int printLevel;
  164. FILE *outputFile;
  165. void *matrix;
  166. void *preconditioner;
  167. double *ShiftsForPreconditioner;
  168. struct restarting_params restartingParams;
  169. struct correction_params correctionParams;
  170. struct primme_stats stats;
  171. struct stackTraceNode *stackTrace;
  172. } primme_params;
  173. //-----------------------------------------------------------------------------
  174. typedef enum {
  175. DYNAMIC,
  176. DEFAULT_MIN_TIME,
  177. DEFAULT_MIN_MATVECS,
  178. Arnoldi,
  179. GD,
  180. GD_plusK,
  181. GD_Olsen_plusK,
  182. JD_Olsen_plusK,
  183. RQI,
  184. JDQR,
  185. JDQMR,
  186. JDQMR_ETol,
  187. SUBSPACE_ITERATION,
  188. LOBPCG_OrthoBasis,
  189. LOBPCG_OrthoBasis_Window
  190. } primme_preset_method;
  191. PRIMME_API
  192. int dprimme(double *evals, double *evecs, double *resNorms,
  193. primme_params *primme);
  194. int zprimme(double *evals, Complex_Z *evecs, double *resNorms,
  195. primme_params *primme);
  196. PRIMME_API
  197. void primme_initialize(primme_params *primme);
  198. PRIMME_API
  199. int primme_set_method(primme_preset_method method, primme_params *params);
  200. PRIMME_API
  201. void primme_display_params(primme_params primme);
  202. void *primme_valloc(size_t byteSize, const char *target);
  203. void *primme_calloc(size_t nelem, size_t elsize, const char *target);
  204. PRIMME_API
  205. void primme_Free(primme_params *primme);
  206. void primme_seq_globalSumDouble(void *sendBuf, void *recvBuf, int *count,
  207. primme_params *params);
  208. void primme_PushErrorMessage(const primme_function callingFunction,
  209. const primme_function failedFunction, const int errorCode,
  210. const char *fileName, const int lineNumber, primme_params *primme);
  211. void primme_PrintStackTrace(const primme_params primme);
  212. void primme_DeleteStackTrace(primme_params *primme);
  213. #endif /* PRIMME_H */