tensor-0.1.0
 All Data Structures Namespaces Functions Variables Typedefs Enumerations Enumerator Groups Pages
seupp.h
1 // -*- mode: c++; fill-column: 80; c-basic-offset: 2; indent-tabs-mode: nil -*-
2 /*
3  Copyright (c) 2010 Juan Jose Garcia Ripoll
4 
5  Tensor is free software; you can redistribute it and/or modify it
6  under the terms of the GNU Library General Public License as published
7  by the Free Software Foundation; either version 2 of the License, or
8  (at your option) any later version.
9 
10  This program is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  GNU Library General Public License for more details.
14 
15  You should have received a copy of the GNU General Public License along
16  with this program; if not, write to the Free Software Foundation, Inc.,
17  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18 */
19 /*
20  ARPACK++ v1.0 8/1/1997
21  c++ interface to ARPACK code.
22 
23  MODULE seupp.h.
24  Interface to ARPACK subroutines dseupd and sseupd.
25 
26  ARPACK Authors
27  Richard Lehoucq
28  Danny Sorensen
29  Chao Yang
30  Dept. of Computational & Applied Mathematics
31  Rice University
32  Houston, Texas
33 */
34 
35 #ifndef SEUPP_H
36 #define SEUPP_H
37 
38 #include "arpackf.h"
39 
40 inline void seupp(bool rvec, char HowMny, double d[], double Z[],
41  integer ldz, double sigma, char bmat, integer n,
42  const char* which, integer nev, double tol, double resid[],
43  integer ncv, double V[], integer ldv, integer iparam[],
44  integer ipntr[], double workd[], double workl[],
45  integer lworkl, integer& info)
46 
47 /*
48  c++ version of ARPACK routine dseupd.
49  This subroutine returns the converged approximations to eigenvalues
50  of A*z = lambda*B*z and (optionally):
51 
52  (1) the corresponding approximate eigenvectors,
53  (2) an orthonormal (Lanczos) basis for the associated approximate
54  invariant subspace,
55 
56  There is negligible additional cost to obtain eigenvectors. An orthonormal
57  (Lanczos) basis is always computed. There is an additional storage cost
58  of n*nev if both are requested (in this case a separate array Z must be
59  supplied).
60  These quantities are obtained from the Lanczos factorization computed
61  by saupp for the linear operator OP prescribed by the MODE selection
62  (see IPARAM[7] in saupp documentation). saupp must be called before
63  this routine is called. These approximate eigenvalues and vectors are
64  commonly called Ritz values and Ritz vectors respectively. They are
65  referred to as such in the comments that follow. The computed orthonormal
66  basis for the invariant subspace corresponding to these Ritz values is
67  referred to as a Lanczos basis.
68  See documentation in the header of the subroutine dsaupp for a definition
69  of OP as well as other terms and the relation of computed Ritz values
70  and vectors of OP with respect to the given problem A*z = lambda*B*z.
71  The approximate eigenvalues of the original problem are returned in
72  ascending algebraic order. The user may elect to call this routine
73  once for each desired Ritz vector and store it peripherally if desired.
74  There is also the option of computing a selected set of these vectors
75  with a single call.
76 
77  Parameters:
78 
79  rvec (Input) Specifies whether Ritz vectors corresponding to the
80  Ritz value approximations to the eigenproblem A*z = lambda*B*z
81  are computed.
82  rvec = false: Compute Ritz values only.
83  rvec = true : Compute Ritz vectors.
84  HowMny (Input) Specifies how many Ritz vectors are wanted and the
85  form of Z, the matrix of Ritz vectors. See remark 1 below.
86  The only option already implemented is HowMny = 'A'.
87  d (Output) Array of dimension nev. On exit, d contains the Ritz
88  value approximations to the eigenvalues of A*z = lambda*B*z.
89  The values are returned in ascending order. If iparam[7] =
90  3, 4, 5 then d represents the Ritz values of OP computed by
91  dsaupp transformed to those of the original eigensystem A*z =
92  lambda*B*z. If iparam[7] = 1,2 then the Ritz values of OP are
93  the same as the those of A*z = lambda*B*z.
94  Z (Output) Array of dimension nev*n if HowMny = 'A'. On
95  exit, Z contains the B-orthonormal Ritz vectors of the
96  eigensystem A*z = lambda*B*z corresponding to the Ritz value
97  approximations. If rvec = false then Z is not referenced.
98  NOTE: The array Z may be set equal to first nev columns of
99  the Arnoldi/Lanczos basis array V computed by dsaupp.
100  ldz (Input) Dimension of the vectors contained in Z. This
101  parameter MUST be set to n.
102  sigma (Input) If iparam[7] = 3,4,5 represents the shift. Not
103  referenced if iparam[7] = 1 or 2.
104  workl (Input / Output) Array of length lworkl+1.
105  workl[1:4*ncv] contains information obtained in saupp.
106  They are not changed by seupp. workl[4*ncv+1:ncv*(ncv+8)]
107  holds the untransformed Ritz values, the computed error
108  estimates, and the associated eigenvector matrix of H.
109  Note: ipntr[8:10] contains the pointer into workl for
110  addresses of the above information computed by seupp.
111  ipntr (Input / Output) Array of length 12. Pointer to mark the
112  starting locations in the workl array for matrices/vectors
113  used by dsaupp and seupp.
114  ipntr[8] : pointer to the RITZ values of the original system.
115  ipntr[9] : pointer to the ncv corresponding error bounds.
116  ipntr[10]: pointer to the ncv by ncv matrix of eigenvectors
117  of the tridiagonal matrix T. Only referenced by
118  seupp if rvec = true. See Remarks.
119  info (Output) Error flag.
120  = 0 : Normal exit.
121  = -1 : n must be positive.
122  = -2 : nev must be positive.
123  = -3 : ncv must satisfy nev < ncv <= n.
124  = -5 : which must be one of 'LM', 'SM', 'LA', 'SA' or 'BE'.
125  = -6 : bmat must be one of 'I' or 'G'.
126  = -7 : Length of private work workl array is not sufficient.
127  = -8 : Error return from trid. eigenvalue calculation;
128  Information error from LAPACK routine dsteqr.
129  = -9 : Starting vector is zero.
130  = -10: iparam[7] must be 1,2,3,4,5.
131  = -11: iparam[7] = 1 and bmat = 'G' are incompatible.
132  = -12: nev and which = 'BE' are incompatible.
133  = -14: dsaupp did not find any eigenvalues to sufficient
134  accuracy.
135  = -15: HowMny must be one of 'A' or 'S' if rvec = true.
136  = -16: HowMny = 'S' not yet implemented.
137 
138  NOTE: The following arguments
139 
140  bmat, n, which, nev, tol, resid, ncv, V, ldv, iparam,
141  ipntr, workd, workl, lworkl, info
142 
143  must be passed directly to seupp following the last call
144  to saupp. These arguments MUST NOT BE MODIFIED between
145  the the last call to saupp and the call to seupp.
146 
147  Remarks
148  1. The converged Ritz values are always returned in increasing
149  (algebraic) order.
150  2. Currently only HowMny = 'A' is implemented. It is included at
151  this stage for the user who wants to incorporate it.
152 */
153 
154 {
155 
156  integer irvec;
157  logical* iselect;
158  double* iZ;
159 
160  irvec = (int) rvec;
161  iselect = new logical[ncv];
162  iZ = (Z == NULL) ? &V[0] : Z;
163 
164  F77_FUNC(dseupd,DSEUPD)(&irvec, &HowMny, iselect, d, iZ, &ldz, &sigma, &bmat,
165  &n, which, &nev, &tol, resid, &ncv, &V[0], &ldv, &iparam[0],
166  &ipntr[0], &workd[0], &workl[0], &lworkl, &info );
167 
168  delete[] iselect;
169 
170 } // seupp (double).
171 
172 #endif // SEUPP_H