Merge branch 'master' of git@git.gromacs.org:gromacs
[gromacs/rigid-bodies.git] / include / gmx_arpack.h
blobd89a226f6eacf5baba4b272197ecc0ac002d9a49
1 /*
2 *
3 * This file is part of Gromacs Copyright (c) 1991-2004
4 * David van der Spoel, Erik Lindahl, University of Groningen.
6 * This file contains a subset of ARPACK functions to perform
7 * diagonalization and SVD for sparse matrices in Gromacs.
9 * The code has been translated to C to avoid being dependent on
10 * a Fotran compiler, and it has been made threadsafe by using
11 * additional workspace arrays to store data during reverse communication.
13 * You might prefer the original ARPACK library for general use, but
14 * in case you want to this version can be redistributed freely, just
15 * as the original library. However, please make clear that it is the
16 * hacked version from Gromacs so any bugs are blamed on us and not
17 * the original authors. You should also be aware that the double
18 * precision work array workd needs to be of size (3*N+4) here
19 * (4 more than the general library), and there is an extra argument
20 * iwork, which should be an integer work array of length 80.
22 * ARPACK was written by
24 * Danny Sorensen Phuong Vu
25 * Riconst chard Lehoucq CRPC / Rice University
26 * Dept. of Computational & Houston, Texas
27 * Applied Mathematics
28 * Rice University
29 * Houston, Texas
32 #ifndef _GMX_ARPACK_H
33 #define _GMX_ARPACK_H
36 #ifdef HAVE_CONFIG_H
37 #include <config.h>
38 #endif
41 #ifdef __cplusplus
42 extern "C" {
43 #endif
45 /*! \file
46 * \brief Selected routines from ARPACK
48 * This file contains a subset of ARPACK functions to perform
49 * diagonalization and SVD for sparse matrices in Gromacs.
51 * Consult the main ARPACK site for detailed documentation:
52 * http://www.caam.rice.edu/software/ARPACK/
54 * Below, we just list the options and any specific differences
55 * from ARPACK. The code is essentially the same, but the routines
56 * have been made thread-safe by using extra workspace arrays.
59 #ifndef F77_FUNC
60 #define F77_FUNC(name,NAME) name ## _
61 #endif
64 /*! \brief Implicitly Restarted Arnoldi Iteration, double precision.
66 * Reverse communication interface for the Implicitly Restarted Arnoldi
67 * Iteration. For symmetric problems this reduces to a variant of the
68 * Lanczos method. See the ARPACK site for details.
70 * \param ido Reverse communication flag. Set to 0 first time.
71 * Upon return with ido=-1 or ido=1 you should calculate
72 * Y=A*X and recall the routine. Return with ido=2 means
73 * Y=B*X should be calculated. ipntr[0] is the pointer in
74 * workd for X, ipntr[1] is the index for Y.
75 * Return with ido=99 means it finished.
76 * \param bmat 'I' for standard eigenproblem, 'G' for generalized.
77 * \param n Order of eigenproblem.
78 * \param which Which eigenvalues to calculate. 'LA' for largest
79 * algebraic, 'SA' for smallest algebraic, 'LM' for largest
80 * magnitude, 'SM' for smallest magnitude, and finally
81 * 'BE' (both ends) to calculate half from each end of
82 * the spectrum.
83 * \param nev Number of eigenvalues to calculate. 0<nev<n.
84 * \param tol Tolerance. Machine precision of it is 0.
85 * \param resid Optional starting residual vector at input if info=1,
86 * otherwise a random one is used. Final residual vector on
87 * return.
88 * \param ncv Number of columns in matrix v.
89 * \param v N*NCV matrix. V contain the Lanczos basis vectors.
90 * \param ldv Leading dimension of v.
91 * \param iparam Integer array, size 11. Same contents as arpack.
92 * \param ipntr Integer array, size 11. Points to starting locations
93 * in the workd/workl arrays. Same contents as arpack.
94 * \param workd Double precision work array, length 3*n+4.
95 * Provide the same array for all calls, and don't touch it.
96 * IMPORTANT: This is 4 units larger than standard ARPACK!
97 * \param iwork Integer work array, size 80.
98 * Provide the same array for all calls, and don't touch it.
99 * IMPORTANT: New argument compared to standard ARPACK!
100 * \param workl Double precision work array, length lwork.
101 * \param lworkl Length of the work array workl. Must be at least ncv*(ncv+8)
102 * \param info Set info to 0 to use random initial residual vector,
103 * or to 1 if you provide a one. On output, info=0 means
104 * normal exit, 1 that max number of iterations was reached,
105 * and 3 that no shifts could be applied. Negative numbers
106 * correspond to errors in the arguments provided.
108 void
109 F77_FUNC(dsaupd,DSAUPD)(int * ido,
110 const char * bmat,
111 int * n,
112 const char * which,
113 int * nev,
114 double * tol,
115 double * resid,
116 int * ncv,
117 double * v,
118 int * ldv,
119 int * iparam,
120 int * ipntr,
121 double * workd,
122 int * iwork,
123 double * workl,
124 int * lworkl,
125 int * info);
129 /*! \brief Get eigenvalues/vectors after Arnoldi iteration, double prec.
131 * See the ARPACK site for details. You must have finished the interative
132 * part with dsaupd() before calling this function.
134 * \param rvec 1 if you want eigenvectors, 0 if not.
135 * \param howmny 'A' if you want all nvec vectors, 'S' if you
136 * provide a subset selection in select[].
137 * \param select Integer array, dimension nev. Indices of the
138 * eigenvectors to calculate. Fortran code means we
139 * start counting on 1. This array must be given even in
140 * howmny is 'A'. (Arpack documentation is wrong on this).
141 * \param d Double precision array, length nev. Eigenvalues.
142 * \param z Double precision array, n*nev. Eigenvectors.
143 * \param ldz Leading dimension of z. Normally n.
144 * \param sigma Shift if iparam[6] is 3,4, or 5. Ignored otherwise.
145 * \param bmat Provide the same argument as you did to dsaupd()
146 * \param n Provide the same argument as you did to dsaupd()
147 * \param which Provide the same argument as you did to dsaupd()
148 * \param nev Provide the same argument as you did to dsaupd()
149 * \param tol Provide the same argument as you did to dsaupd()
150 * \param resid Provide the same argument as you did to dsaupd()
151 * The array must not be touched between the two function calls!
152 * \param ncv Provide the same argument as you did to dsaupd()
153 * \param v Provide the same argument as you did to dsaupd()
154 * The array must not be touched between the two function calls!
155 * \param ldv Provide the same argument as you did to dsaupd()
156 * \param iparam Provide the same argument as you did to dsaupd()
157 * The array must not be touched between the two function calls!
158 * \param ipntr Provide the same argument as you did to dsaupd()
159 * The array must not be touched between the two function calls!
160 * \param workd Provide the same argument as you did to dsaupd()
161 * The array must not be touched between the two function calls!
162 * \param workl Double precision work array, length lwork.
163 * The array must not be touched between the two function calls!
164 * \param lworkl Provide the same argument as you did to dsaupd()
165 * \param info Provide the same argument as you did to dsaupd()
167 void
168 F77_FUNC(dseupd,DSEUPD)(int * rvec,
169 const char * howmny,
170 int * select,
171 double * d,
172 double * z,
173 int * ldz,
174 double * sigma,
175 const char * bmat,
176 int * n,
177 const char * which,
178 int * nev,
179 double * tol,
180 double * resid,
181 int * ncv,
182 double * v,
183 int * ldv,
184 int * iparam,
185 int * ipntr,
186 double * workd,
187 double * workl,
188 int * lworkl,
189 int * info);
195 /*! \brief Implicitly Restarted Arnoldi Iteration, single precision.
197 * Reverse communication interface for the Implicitly Restarted Arnoldi
198 * Iteration. For symmetric problems this reduces to a variant of the
199 * Lanczos method. See the ARPACK site for details.
201 * \param ido Reverse communication flag. Set to 0 first time.
202 * Upon return with ido=-1 or ido=1 you should calculate
203 * Y=A*X and recall the routine. Return with ido=2 means
204 * Y=B*X should be calculated. ipntr[0] is the pointer in
205 * workd for X, ipntr[1] is the index for Y.
206 * Return with ido=99 means it finished.
207 * \param bmat 'I' for standard eigenproblem, 'G' for generalized.
208 * \param n Order of eigenproblem.
209 * \param which Which eigenvalues to calculate. 'LA' for largest
210 * algebraic, 'SA' for smallest algebraic, 'LM' for largest
211 * magnitude, 'SM' for smallest magnitude, and finally
212 * 'BE' (both ends) to calculate half from each end of
213 * the spectrum.
214 * \param nev Number of eigenvalues to calculate. 0<nev<n.
215 * \param tol Tolerance. Machine precision of it is 0.
216 * \param resid Optional starting residual vector at input if info=1,
217 * otherwise a random one is used. Final residual vector on
218 * return.
219 * \param ncv Number of columns in matrix v.
220 * \param v N*NCV matrix. V contain the Lanczos basis vectors.
221 * \param ldv Leading dimension of v.
222 * \param iparam Integer array, size 11. Same contents as arpack.
223 * \param ipntr Integer array, size 11. Points to starting locations
224 * in the workd/workl arrays. Same contents as arpack.
225 * \param workd Single precision work array, length 3*n+4.
226 * Provide the same array for all calls, and don't touch it.
227 * IMPORTANT: This is 4 units larger than standard ARPACK!
228 * \param iwork Integer work array, size 80.
229 * Provide the same array for all calls, and don't touch it.
230 * IMPORTANT: New argument compared to standard ARPACK!
231 * \param workl Single precision work array, length lwork.
232 * \param lworkl Length of the work array workl. Must be at least ncv*(ncv+8)
233 * \param info Set info to 0 to use random initial residual vector,
234 * or to 1 if you provide a one. On output, info=0 means
235 * normal exit, 1 that max number of iterations was reached,
236 * and 3 that no shifts could be applied. Negative numbers
237 * correspond to errors in the arguments provided.
239 void
240 F77_FUNC(ssaupd,SSAUPD)(int * ido,
241 const char * bmat,
242 int * n,
243 const char * which,
244 int * nev,
245 float * tol,
246 float * resid,
247 int * ncv,
248 float * v,
249 int * ldv,
250 int * iparam,
251 int * ipntr,
252 float * workd,
253 int * iwork,
254 float * workl,
255 int * lworkl,
256 int * info);
262 /*! \brief Get eigenvalues/vectors after Arnoldi iteration, single prec.
264 * See the ARPACK site for details. You must have finished the interative
265 * part with ssaupd() before calling this function.
267 * \param rvec 1 if you want eigenvectors, 0 if not.
268 * \param howmny 'A' if you want all nvec vectors, 'S' if you
269 * provide a subset selection in select[].
270 * \param select Integer array, dimension nev. Indices of the
271 * eigenvectors to calculate. Fortran code means we
272 * start counting on 1. This array must be given even in
273 * howmny is 'A'. (Arpack documentation is wrong on this).
274 * \param d Single precision array, length nev. Eigenvalues.
275 * \param z Single precision array, n*nev. Eigenvectors.
276 * \param ldz Leading dimension of z. Normally n.
277 * \param sigma Shift if iparam[6] is 3,4, or 5. Ignored otherwise.
278 * \param bmat Provide the same argument as you did to ssaupd()
279 * \param n Provide the same argument as you did to ssaupd()
280 * \param which Provide the same argument as you did to ssaupd()
281 * \param nev Provide the same argument as you did to ssaupd()
282 * \param tol Provide the same argument as you did to ssaupd()
283 * \param resid Provide the same argument as you did to ssaupd()
284 * The array must not be touched between the two function calls!
285 * \param ncv Provide the same argument as you did to ssaupd()
286 * \param v Provide the same argument as you did to ssaupd()
287 * The array must not be touched between the two function calls!
288 * \param ldv Provide the same argument as you did to ssaupd()
289 * \param iparam Provide the same argument as you did to ssaupd()
290 * The array must not be touched between the two function calls!
291 * \param ipntr Provide the same argument as you did to ssaupd()
292 * The array must not be touched between the two function calls!
293 * \param workd Provide the same argument as you did to ssaupd()
294 * The array must not be touched between the two function calls!
295 * \param workl Single precision work array, length lwork.
296 * The array must not be touched between the two function calls!
297 * \param lworkl Provide the same argument as you did to ssaupd()
298 * \param info Provide the same argument as you did to ssaupd()
300 void
301 F77_FUNC(sseupd,SSEUPD)(int * rvec,
302 const char * howmny,
303 int * select,
304 float * d,
305 float * z,
306 int * ldz,
307 float * sigma,
308 const char * bmat,
309 int * n,
310 const char * which,
311 int * nev,
312 float * tol,
313 float * resid,
314 int * ncv,
315 float * v,
316 int * ldv,
317 int * iparam,
318 int * ipntr,
319 float * workd,
320 float * workl,
321 int * lworkl,
322 int * info);
324 #ifdef __cplusplus
326 #endif
328 #endif