Adjust more copyright headers
[alexxy/gromacs.git] / src / gromacs / linearalgebra / gmx_arpack.h
1 /*
2  * This file is part of the GROMACS molecular simulation package.
3  *
4  * Copyright (c) 1991-2004 David van der Spoel, Erik Lindahl, University of Groningen.
5  * Copyright (c) 2012,2013, by the GROMACS development team, led by
6  * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
7  * and including many others, as listed in the AUTHORS file in the
8  * top-level source directory and at http://www.gromacs.org.
9  *
10  * GROMACS is free software; you can redistribute it and/or
11  * modify it under the terms of the GNU Lesser General Public License
12  * as published by the Free Software Foundation; either version 2.1
13  * of the License, or (at your option) any later version.
14  *
15  * GROMACS is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
18  * Lesser General Public License for more details.
19  *
20  * You should have received a copy of the GNU Lesser General Public
21  * License along with GROMACS; if not, see
22  * http://www.gnu.org/licenses, or write to the Free Software Foundation,
23  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA.
24  *
25  * If you want to redistribute modifications to GROMACS, please
26  * consider that scientific software is very special. Version
27  * control is crucial - bugs must be traceable. We will be happy to
28  * consider code for inclusion in the official distribution, but
29  * derived work must not be called official GROMACS. Details are found
30  * in the README & COPYING files - if they are missing, get the
31  * official version at http://www.gromacs.org.
32  *
33  * To help us fund GROMACS development, we humbly ask that you cite
34  * the research papers on the package. Check out http://www.gromacs.org.
35  */
36 /*! \internal \file
37  * \brief
38  * Selected routines from ARPACK
39  *
40  * This file contains a subset of ARPACK functions to perform
41  * diagonalization and SVD for sparse matrices in Gromacs.
42  *
43  * Consult the main ARPACK site for detailed documentation:
44  * http://www.caam.rice.edu/software/ARPACK/
45  *
46  * Below, we just list the options and any specific differences
47  * from ARPACK. The code is essentially the same, but the routines
48  * have been made thread-safe by using extra workspace arrays.
49  */
50 #ifndef GMX_ARPACK_H
51 #define GMX_ARPACK_H
52
53 #ifdef HAVE_CONFIG_H
54 #include "config.h"
55 #endif
56 #ifdef __cplusplus
57 extern "C" {
58 #endif
59
60 /*! \brief Implicitly Restarted Arnoldi Iteration, double precision.
61  *
62  *  Reverse communication interface for the Implicitly Restarted Arnoldi
63  *  Iteration.  For symmetric problems this reduces to a variant of the
64  *  Lanczos method. See the ARPACK site for details.
65  *
66  *  \param ido     Reverse communication flag. Set to 0 first time.
67  *                 Upon return with ido=-1 or ido=1 you should calculate
68  *                 Y=A*X and recall the routine. Return with ido=2 means
69  *                 Y=B*X should be calculated. ipntr[0] is the pointer in
70  *                 workd for X, ipntr[1] is the index for Y.
71  *                 Return with ido=99 means it finished.
72  *  \param bmat    'I' for standard eigenproblem, 'G' for generalized.
73  *  \param n       Order of eigenproblem.
74  *  \param which   Which eigenvalues to calculate. 'LA' for largest
75  *                 algebraic, 'SA' for smallest algebraic, 'LM' for largest
76  *                 magnitude, 'SM' for smallest magnitude, and finally
77  *                 'BE' (both ends) to calculate half from each end of
78  *                 the spectrum.
79  *  \param nev     Number of eigenvalues to calculate. 0<nev<n.
80  *  \param tol     Tolerance. Machine precision of it is 0.
81  *  \param resid   Optional starting residual vector at input if info=1,
82  *                 otherwise a random one is used. Final residual vector on
83  *                 return.
84  *  \param ncv     Number of columns in matrix v.
85  *  \param v       N*NCV matrix. V contain the Lanczos basis vectors.
86  *  \param ldv     Leading dimension of v.
87  *  \param iparam  Integer array, size 11. Same contents as arpack.
88  *  \param ipntr   Integer array, size 11. Points to starting locations
89  *                 in the workd/workl arrays. Same contents as arpack.
90  *  \param workd   Double precision work array, length 3*n+4.
91  *                 Provide the same array for all calls, and don't touch it.
92  *                 IMPORTANT: This is 4 units larger than standard ARPACK!
93  *  \param iwork   Integer work array, size 80.
94  *                 Provide the same array for all calls, and don't touch it.
95  *                 IMPORTANT: New argument compared to standard ARPACK!
96  *  \param workl   Double precision work array, length lwork.
97  *  \param lworkl  Length of the work array workl. Must be at least ncv*(ncv+8)
98  *  \param info    Set info to 0 to use random initial residual vector,
99  *                 or to 1 if you provide a one. On output, info=0 means
100  *                 normal exit, 1 that max number of iterations was reached,
101  *                 and 3 that no shifts could be applied. Negative numbers
102  *                 correspond to errors in the arguments provided.
103  */
104 void
105     F77_FUNC(dsaupd, DSAUPD) (int *     ido,
106                               const char *    bmat,
107                               int *     n,
108                               const char *      which,
109                               int *     nev,
110                               double *  tol,
111                               double *  resid,
112                               int *     ncv,
113                               double *  v,
114                               int *     ldv,
115                               int *     iparam,
116                               int *     ipntr,
117                               double *  workd,
118                               int *     iwork,
119                               double *  workl,
120                               int *     lworkl,
121                               int *     info);
122
123
124
125 /*! \brief Get eigenvalues/vectors after Arnoldi iteration, double prec.
126  *
127  *  See the ARPACK site for details. You must have finished the interative
128  *  part with dsaupd() before calling this function.
129  *
130  *  \param rvec    1 if you want eigenvectors, 0 if not.
131  *  \param howmny  'A' if you want all nvec vectors, 'S' if you
132  *                 provide a subset selection in select[].
133  *  \param select  Integer array, dimension nev. Indices of the
134  *                 eigenvectors to calculate. Fortran code means we
135  *                 start counting on 1. This array must be given even in
136  *                 howmny is 'A'. (Arpack documentation is wrong on this).
137  *  \param d       Double precision array, length nev. Eigenvalues.
138  *  \param z       Double precision array, n*nev. Eigenvectors.
139  *  \param ldz     Leading dimension of z. Normally n.
140  *  \param sigma   Shift if iparam[6] is 3,4, or 5. Ignored otherwise.
141  *  \param bmat    Provide the same argument as you did to dsaupd()
142  *  \param n       Provide the same argument as you did to dsaupd()
143  *  \param which   Provide the same argument as you did to dsaupd()
144  *  \param nev     Provide the same argument as you did to dsaupd()
145  *  \param tol     Provide the same argument as you did to dsaupd()
146  *  \param resid   Provide the same argument as you did to dsaupd()
147  *                 The array must not be touched between the two function calls!
148  *  \param ncv     Provide the same argument as you did to dsaupd()
149  *  \param v       Provide the same argument as you did to dsaupd()
150  *                 The array must not be touched between the two function calls!
151  *  \param ldv     Provide the same argument as you did to dsaupd()
152  *  \param iparam  Provide the same argument as you did to dsaupd()
153  *                 The array must not be touched between the two function calls!
154  *  \param ipntr   Provide the same argument as you did to dsaupd()
155  *                 The array must not be touched between the two function calls!
156  *  \param workd   Provide the same argument as you did to dsaupd()
157  *                 The array must not be touched between the two function calls!
158  *  \param workl   Double precision work array, length lwork.
159  *                 The array must not be touched between the two function calls!
160  *  \param lworkl  Provide the same argument as you did to dsaupd()
161  *  \param info    Provide the same argument as you did to dsaupd()
162  */
163 void
164     F77_FUNC(dseupd, DSEUPD) (int *     rvec,
165                               const char *    howmny,
166                               int *     select,
167                               double *  d,
168                               double *  z,
169                               int *     ldz,
170                               double *  sigma,
171                               const char *    bmat,
172                               int *     n,
173                               const char *    which,
174                               int *     nev,
175                               double *  tol,
176                               double *  resid,
177                               int *     ncv,
178                               double *  v,
179                               int *     ldv,
180                               int *     iparam,
181                               int *     ipntr,
182                               double *  workd,
183                               double *  workl,
184                               int *     lworkl,
185                               int *     info);
186
187
188
189
190
191 /*! \brief Implicitly Restarted Arnoldi Iteration, single precision.
192  *
193  *  Reverse communication interface for the Implicitly Restarted Arnoldi
194  *  Iteration.  For symmetric problems this reduces to a variant of the
195  *  Lanczos method. See the ARPACK site for details.
196  *
197  *  \param ido     Reverse communication flag. Set to 0 first time.
198  *                 Upon return with ido=-1 or ido=1 you should calculate
199  *                 Y=A*X and recall the routine. Return with ido=2 means
200  *                 Y=B*X should be calculated. ipntr[0] is the pointer in
201  *                 workd for X, ipntr[1] is the index for Y.
202  *                 Return with ido=99 means it finished.
203  *  \param bmat    'I' for standard eigenproblem, 'G' for generalized.
204  *  \param n       Order of eigenproblem.
205  *  \param which   Which eigenvalues to calculate. 'LA' for largest
206  *                 algebraic, 'SA' for smallest algebraic, 'LM' for largest
207  *                 magnitude, 'SM' for smallest magnitude, and finally
208  *                 'BE' (both ends) to calculate half from each end of
209  *                 the spectrum.
210  *  \param nev     Number of eigenvalues to calculate. 0<nev<n.
211  *  \param tol     Tolerance. Machine precision of it is 0.
212  *  \param resid   Optional starting residual vector at input if info=1,
213  *                 otherwise a random one is used. Final residual vector on
214  *                 return.
215  *  \param ncv     Number of columns in matrix v.
216  *  \param v       N*NCV matrix. V contain the Lanczos basis vectors.
217  *  \param ldv     Leading dimension of v.
218  *  \param iparam  Integer array, size 11. Same contents as arpack.
219  *  \param ipntr   Integer array, size 11. Points to starting locations
220  *                 in the workd/workl arrays. Same contents as arpack.
221  *  \param workd   Single precision work array, length 3*n+4.
222  *                 Provide the same array for all calls, and don't touch it.
223  *                 IMPORTANT: This is 4 units larger than standard ARPACK!
224  *  \param iwork   Integer work array, size 80.
225  *                 Provide the same array for all calls, and don't touch it.
226  *                 IMPORTANT: New argument compared to standard ARPACK!
227  *  \param workl   Single precision work array, length lwork.
228  *  \param lworkl  Length of the work array workl. Must be at least ncv*(ncv+8)
229  *  \param info    Set info to 0 to use random initial residual vector,
230  *                 or to 1 if you provide a one. On output, info=0 means
231  *                 normal exit, 1 that max number of iterations was reached,
232  *                 and 3 that no shifts could be applied. Negative numbers
233  *                 correspond to errors in the arguments provided.
234  */
235 void
236     F77_FUNC(ssaupd, SSAUPD) (int *     ido,
237                               const char *    bmat,
238                               int *     n,
239                               const char *    which,
240                               int *     nev,
241                               float *   tol,
242                               float *   resid,
243                               int *     ncv,
244                               float *   v,
245                               int *     ldv,
246                               int *     iparam,
247                               int *     ipntr,
248                               float *   workd,
249                               int *     iwork,
250                               float *   workl,
251                               int *     lworkl,
252                               int *     info);
253
254
255
256
257
258 /*! \brief Get eigenvalues/vectors after Arnoldi iteration, single prec.
259  *
260  *  See the ARPACK site for details. You must have finished the interative
261  *  part with ssaupd() before calling this function.
262  *
263  *  \param rvec    1 if you want eigenvectors, 0 if not.
264  *  \param howmny  'A' if you want all nvec vectors, 'S' if you
265  *                 provide a subset selection in select[].
266  *  \param select  Integer array, dimension nev. Indices of the
267  *                 eigenvectors to calculate. Fortran code means we
268  *                 start counting on 1. This array must be given even in
269  *                 howmny is 'A'. (Arpack documentation is wrong on this).
270  *  \param d       Single precision array, length nev. Eigenvalues.
271  *  \param z       Single precision array, n*nev. Eigenvectors.
272  *  \param ldz     Leading dimension of z. Normally n.
273  *  \param sigma   Shift if iparam[6] is 3,4, or 5. Ignored otherwise.
274  *  \param bmat    Provide the same argument as you did to ssaupd()
275  *  \param n       Provide the same argument as you did to ssaupd()
276  *  \param which   Provide the same argument as you did to ssaupd()
277  *  \param nev     Provide the same argument as you did to ssaupd()
278  *  \param tol     Provide the same argument as you did to ssaupd()
279  *  \param resid   Provide the same argument as you did to ssaupd()
280  *                 The array must not be touched between the two function calls!
281  *  \param ncv     Provide the same argument as you did to ssaupd()
282  *  \param v       Provide the same argument as you did to ssaupd()
283  *                 The array must not be touched between the two function calls!
284  *  \param ldv     Provide the same argument as you did to ssaupd()
285  *  \param iparam  Provide the same argument as you did to ssaupd()
286  *                 The array must not be touched between the two function calls!
287  *  \param ipntr   Provide the same argument as you did to ssaupd()
288  *                 The array must not be touched between the two function calls!
289  *  \param workd   Provide the same argument as you did to ssaupd()
290  *                 The array must not be touched between the two function calls!
291  *  \param workl   Single precision work array, length lwork.
292  *                 The array must not be touched between the two function calls!
293  *  \param lworkl  Provide the same argument as you did to ssaupd()
294  *  \param info    Provide the same argument as you did to ssaupd()
295  */
296 void
297     F77_FUNC(sseupd, SSEUPD) (int *     rvec,
298                               const char *    howmny,
299                               int *     select,
300                               float *   d,
301                               float *   z,
302                               int *     ldz,
303                               float *   sigma,
304                               const char *    bmat,
305                               int *     n,
306                               const char *    which,
307                               int *     nev,
308                               float *   tol,
309                               float *   resid,
310                               int *     ncv,
311                               float *   v,
312                               int *     ldv,
313                               int *     iparam,
314                               int *     ipntr,
315                               float *   workd,
316                               float *   workl,
317                               int *     lworkl,
318                               int *     info);
319
320 #ifdef __cplusplus
321 }
322 #endif
323
324 #endif