2 * This file is part of the GROMACS molecular simulation package.
4 * This file is part of Gromacs Copyright (c) 1991-2004
5 * David van der Spoel, Erik Lindahl, University of Groningen.
6 * Copyright (c) 2012, by the GROMACS development team, led by
7 * David van der Spoel, Berk Hess, Erik Lindahl, and including many
8 * others, as listed in the AUTHORS file in the top-level source
9 * directory and at http://www.gromacs.org.
11 * GROMACS is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU Lesser General Public License
13 * as published by the Free Software Foundation; either version 2.1
14 * of the License, or (at your option) any later version.
16 * GROMACS is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 * Lesser General Public License for more details.
21 * You should have received a copy of the GNU Lesser General Public
22 * License along with GROMACS; if not, see
23 * http://www.gnu.org/licenses, or write to the Free Software Foundation,
24 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
26 * If you want to redistribute modifications to GROMACS, please
27 * consider that scientific software is very special. Version
28 * control is crucial - bugs must be traceable. We will be happy to
29 * consider code for inclusion in the official distribution, but
30 * derived work must not be called official GROMACS. Details are found
31 * in the README & COPYING files - if they are missing, get the
32 * official version at http://www.gromacs.org.
34 * To help us fund GROMACS development, we humbly ask that you cite
35 * the research papers on the package. Check out http://www.gromacs.org.
41 #include "visibility.h"
47 * \brief Selected routines from ARPACK
49 * This file contains a subset of ARPACK functions to perform
50 * diagonalization and SVD for sparse matrices in Gromacs.
52 * Consult the main ARPACK site for detailed documentation:
53 * http://www.caam.rice.edu/software/ARPACK/
55 * Below, we just list the options and any specific differences
56 * from ARPACK. The code is essentially the same, but the routines
57 * have been made thread-safe by using extra workspace arrays.
61 #define F77_FUNC(name,NAME) name ## _
65 /*! \brief Implicitly Restarted Arnoldi Iteration, double precision.
67 * Reverse communication interface for the Implicitly Restarted Arnoldi
68 * Iteration. For symmetric problems this reduces to a variant of the
69 * Lanczos method. See the ARPACK site for details.
71 * \param ido Reverse communication flag. Set to 0 first time.
72 * Upon return with ido=-1 or ido=1 you should calculate
73 * Y=A*X and recall the routine. Return with ido=2 means
74 * Y=B*X should be calculated. ipntr[0] is the pointer in
75 * workd for X, ipntr[1] is the index for Y.
76 * Return with ido=99 means it finished.
77 * \param bmat 'I' for standard eigenproblem, 'G' for generalized.
78 * \param n Order of eigenproblem.
79 * \param which Which eigenvalues to calculate. 'LA' for largest
80 * algebraic, 'SA' for smallest algebraic, 'LM' for largest
81 * magnitude, 'SM' for smallest magnitude, and finally
82 * 'BE' (both ends) to calculate half from each end of
84 * \param nev Number of eigenvalues to calculate. 0<nev<n.
85 * \param tol Tolerance. Machine precision of it is 0.
86 * \param resid Optional starting residual vector at input if info=1,
87 * otherwise a random one is used. Final residual vector on
89 * \param ncv Number of columns in matrix v.
90 * \param v N*NCV matrix. V contain the Lanczos basis vectors.
91 * \param ldv Leading dimension of v.
92 * \param iparam Integer array, size 11. Same contents as arpack.
93 * \param ipntr Integer array, size 11. Points to starting locations
94 * in the workd/workl arrays. Same contents as arpack.
95 * \param workd Double precision work array, length 3*n+4.
96 * Provide the same array for all calls, and don't touch it.
97 * IMPORTANT: This is 4 units larger than standard ARPACK!
98 * \param iwork Integer work array, size 80.
99 * Provide the same array for all calls, and don't touch it.
100 * IMPORTANT: New argument compared to standard ARPACK!
101 * \param workl Double precision work array, length lwork.
102 * \param lworkl Length of the work array workl. Must be at least ncv*(ncv+8)
103 * \param info Set info to 0 to use random initial residual vector,
104 * or to 1 if you provide a one. On output, info=0 means
105 * normal exit, 1 that max number of iterations was reached,
106 * and 3 that no shifts could be applied. Negative numbers
107 * correspond to errors in the arguments provided.
110 F77_FUNC(dsaupd,DSAUPD)(int * ido,
130 /*! \brief Get eigenvalues/vectors after Arnoldi iteration, double prec.
132 * See the ARPACK site for details. You must have finished the interative
133 * part with dsaupd() before calling this function.
135 * \param rvec 1 if you want eigenvectors, 0 if not.
136 * \param howmny 'A' if you want all nvec vectors, 'S' if you
137 * provide a subset selection in select[].
138 * \param select Integer array, dimension nev. Indices of the
139 * eigenvectors to calculate. Fortran code means we
140 * start counting on 1. This array must be given even in
141 * howmny is 'A'. (Arpack documentation is wrong on this).
142 * \param d Double precision array, length nev. Eigenvalues.
143 * \param z Double precision array, n*nev. Eigenvectors.
144 * \param ldz Leading dimension of z. Normally n.
145 * \param sigma Shift if iparam[6] is 3,4, or 5. Ignored otherwise.
146 * \param bmat Provide the same argument as you did to dsaupd()
147 * \param n Provide the same argument as you did to dsaupd()
148 * \param which Provide the same argument as you did to dsaupd()
149 * \param nev Provide the same argument as you did to dsaupd()
150 * \param tol Provide the same argument as you did to dsaupd()
151 * \param resid Provide the same argument as you did to dsaupd()
152 * The array must not be touched between the two function calls!
153 * \param ncv Provide the same argument as you did to dsaupd()
154 * \param v Provide the same argument as you did to dsaupd()
155 * The array must not be touched between the two function calls!
156 * \param ldv Provide the same argument as you did to dsaupd()
157 * \param iparam Provide the same argument as you did to dsaupd()
158 * The array must not be touched between the two function calls!
159 * \param ipntr Provide the same argument as you did to dsaupd()
160 * The array must not be touched between the two function calls!
161 * \param workd Provide the same argument as you did to dsaupd()
162 * The array must not be touched between the two function calls!
163 * \param workl Double precision work array, length lwork.
164 * The array must not be touched between the two function calls!
165 * \param lworkl Provide the same argument as you did to dsaupd()
166 * \param info Provide the same argument as you did to dsaupd()
169 F77_FUNC(dseupd,DSEUPD)(int * rvec,
196 /*! \brief Implicitly Restarted Arnoldi Iteration, single precision.
198 * Reverse communication interface for the Implicitly Restarted Arnoldi
199 * Iteration. For symmetric problems this reduces to a variant of the
200 * Lanczos method. See the ARPACK site for details.
202 * \param ido Reverse communication flag. Set to 0 first time.
203 * Upon return with ido=-1 or ido=1 you should calculate
204 * Y=A*X and recall the routine. Return with ido=2 means
205 * Y=B*X should be calculated. ipntr[0] is the pointer in
206 * workd for X, ipntr[1] is the index for Y.
207 * Return with ido=99 means it finished.
208 * \param bmat 'I' for standard eigenproblem, 'G' for generalized.
209 * \param n Order of eigenproblem.
210 * \param which Which eigenvalues to calculate. 'LA' for largest
211 * algebraic, 'SA' for smallest algebraic, 'LM' for largest
212 * magnitude, 'SM' for smallest magnitude, and finally
213 * 'BE' (both ends) to calculate half from each end of
215 * \param nev Number of eigenvalues to calculate. 0<nev<n.
216 * \param tol Tolerance. Machine precision of it is 0.
217 * \param resid Optional starting residual vector at input if info=1,
218 * otherwise a random one is used. Final residual vector on
220 * \param ncv Number of columns in matrix v.
221 * \param v N*NCV matrix. V contain the Lanczos basis vectors.
222 * \param ldv Leading dimension of v.
223 * \param iparam Integer array, size 11. Same contents as arpack.
224 * \param ipntr Integer array, size 11. Points to starting locations
225 * in the workd/workl arrays. Same contents as arpack.
226 * \param workd Single precision work array, length 3*n+4.
227 * Provide the same array for all calls, and don't touch it.
228 * IMPORTANT: This is 4 units larger than standard ARPACK!
229 * \param iwork Integer work array, size 80.
230 * Provide the same array for all calls, and don't touch it.
231 * IMPORTANT: New argument compared to standard ARPACK!
232 * \param workl Single precision work array, length lwork.
233 * \param lworkl Length of the work array workl. Must be at least ncv*(ncv+8)
234 * \param info Set info to 0 to use random initial residual vector,
235 * or to 1 if you provide a one. On output, info=0 means
236 * normal exit, 1 that max number of iterations was reached,
237 * and 3 that no shifts could be applied. Negative numbers
238 * correspond to errors in the arguments provided.
242 F77_FUNC(ssaupd,SSAUPD)(int * ido,
264 /*! \brief Get eigenvalues/vectors after Arnoldi iteration, single prec.
266 * See the ARPACK site for details. You must have finished the interative
267 * part with ssaupd() before calling this function.
269 * \param rvec 1 if you want eigenvectors, 0 if not.
270 * \param howmny 'A' if you want all nvec vectors, 'S' if you
271 * provide a subset selection in select[].
272 * \param select Integer array, dimension nev. Indices of the
273 * eigenvectors to calculate. Fortran code means we
274 * start counting on 1. This array must be given even in
275 * howmny is 'A'. (Arpack documentation is wrong on this).
276 * \param d Single precision array, length nev. Eigenvalues.
277 * \param z Single precision array, n*nev. Eigenvectors.
278 * \param ldz Leading dimension of z. Normally n.
279 * \param sigma Shift if iparam[6] is 3,4, or 5. Ignored otherwise.
280 * \param bmat Provide the same argument as you did to ssaupd()
281 * \param n Provide the same argument as you did to ssaupd()
282 * \param which Provide the same argument as you did to ssaupd()
283 * \param nev Provide the same argument as you did to ssaupd()
284 * \param tol Provide the same argument as you did to ssaupd()
285 * \param resid Provide the same argument as you did to ssaupd()
286 * The array must not be touched between the two function calls!
287 * \param ncv Provide the same argument as you did to ssaupd()
288 * \param v Provide the same argument as you did to ssaupd()
289 * The array must not be touched between the two function calls!
290 * \param ldv Provide the same argument as you did to ssaupd()
291 * \param iparam Provide the same argument as you did to ssaupd()
292 * The array must not be touched between the two function calls!
293 * \param ipntr Provide the same argument as you did to ssaupd()
294 * The array must not be touched between the two function calls!
295 * \param workd Provide the same argument as you did to ssaupd()
296 * The array must not be touched between the two function calls!
297 * \param workl Single precision work array, length lwork.
298 * The array must not be touched between the two function calls!
299 * \param lworkl Provide the same argument as you did to ssaupd()
300 * \param info Provide the same argument as you did to ssaupd()
304 F77_FUNC(sseupd,SSEUPD)(int * rvec,