ArpackSolver.hxx
1 // Copyright (C) 2010 Lin Wu
2 //
3 // This file is part of the linear-algebra library Seldon,
4 // http://seldon.sourceforge.net/.
5 //
6 // Seldon is free software; you can redistribute it and/or modify it under the
7 // terms of the GNU Lesser General Public License as published by the Free
8 // Software Foundation; either version 2.1 of the License, or (at your option)
9 // any later version.
10 //
11 // Seldon is distributed in the hope that it will be useful, but WITHOUT ANY
12 // WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
13 // FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for
14 // more details.
15 //
16 // You should have received a copy of the GNU Lesser General Public License
17 // along with Seldon. If not, see http://www.gnu.org/licenses/.
18 
19 
20 #ifndef SELDON_FILE_ARPACKSOLVER_HXX
21 
22 namespace Seldon
23 {
24 
25 
27  template<class T, class Y>
29  {
30  protected:
31 
32  /*** Parameters ***/
33 
35  int n_;
37  int nev_;
39  int ncv_;
41  int maxit_;
43  T tol_;
46  string solver_type_;
48  int mode_;
50  string which_;
52  char bmat_;
55  char HowMny_;
57  Y sigma_;
59  Y *resid_;
61  int ishfts_;
63  int ldv_;
64 
65  /*** Variables ***/
66 
69  int *pselect_;
71  int ierr_;
73  bool rvec_;
75  int ido_;
77  int info_;
79  int lworkl_;
81  int lworkv_;
83  int lrwork_;
85  int iparam_[11];
87  int ipntr_[14];
89  T *rwork_;
91  Y *workl_;
93  Y *workd_;
95  Y *workev_;
97  Y *v_;
98 
99  /*** Output variables ***/
100 
102  int nconv_;
107 
108  public:
109 
110  /*** Constructor and destructor ***/
111 
112  ArpackSolver();
113  ~ArpackSolver();
114 
115  /*** Initialization ***/
116 
117  void Init(int n, int nev, int ncv, int maxit, T tol, string solver_type,
118  int mode, string which, char bmat, char HowMny,
119  bool with_arpack_verbose = false);
120  void CheckParameter();
121  void Clear();
122  void Allocate();
123  void Deallocate();
124  void SetArpackVerbose();
125  static void SetArpackVerbose(string s);
126  void ClearArpackVerbose();
127 
128  /*** Access methods ***/
129 
130  Y* GetFirstWorkVector();
131  Y* GetSecondWorkVector();
132  Y* GetEigenVector(int index);
133  Y GetEigenValue(int index);
135  void SetReverseCommunicationFlag(int ido);
136  int GetInfoFlag();
137  void SetInfoFlag(int info);
138  int GetConvergedNumber();
139 
140  /*** Methods **/
141 
142  bool Continue();
143  bool Finish();
144  };
145 
146 
147 } // namespace Seldon.
148 
149 
150 #define SELDON_FILE_ARPACKSOLVER_HXX
151 #endif
Seldon::ArpackSolver::v_
Y * v_
Arnoldi basis / Schur vectors.
Definition: ArpackSolver.hxx:97
Seldon::ArpackSolver::GetSecondWorkVector
Y * GetSecondWorkVector()
Gets the address of the second vector in the ARPACK working array.
Definition: ArpackSolver.cxx:257
Seldon::ArpackSolver::Deallocate
void Deallocate()
Deallocates arrays.
Definition: ArpackSolver.cxx:149
Seldon::ArpackSolver::tol_
T tol_
Stopping criterion (relative accuracy of Ritz values).
Definition: ArpackSolver.hxx:43
Seldon::ArpackSolver::nconv_
int nconv_
Number of "converged" Ritz values.
Definition: ArpackSolver.hxx:102
Seldon::ArpackSolver::SetReverseCommunicationFlag
void SetReverseCommunicationFlag(int ido)
Sets the reverse communication flag.
Definition: ArpackSolver.cxx:298
Seldon::ArpackSolver::CheckParameter
void CheckParameter()
Check parameters.
Definition: ArpackSolver.cxx:109
Seldon::ArpackSolver::~ArpackSolver
~ArpackSolver()
Destructor.
Definition: ArpackSolver.cxx:40
Seldon::ArpackSolver::resid_
Y * resid_
Residual vector.
Definition: ArpackSolver.hxx:59
Seldon::ArpackSolver::workev_
Y * workev_
ARPACK internal vector.
Definition: ArpackSolver.hxx:95
Seldon::ArpackSolver::GetReverseCommunicationFlag
int GetReverseCommunicationFlag()
Gets the reverse communication flag.
Definition: ArpackSolver.cxx:287
Seldon::ArpackSolver::maxit_
int maxit_
Maximum number of Arnoldi update iterations.
Definition: ArpackSolver.hxx:41
Seldon::ArpackSolver::n_
int n_
Dimension of the problem.
Definition: ArpackSolver.hxx:35
Seldon::ArpackSolver::rvec_
bool rvec_
Eigenvectors/schur vectors to be computed?
Definition: ArpackSolver.hxx:73
Seldon::ArpackSolver::Finish
bool Finish()
Post-processing.
Definition: ArpackSolver.cxx:352
Seldon::ArpackSolver
Driver for ARPARK solvers.
Definition: ArpackSolver.hxx:28
Seldon::ArpackSolver::workl_
Y * workl_
ARPACK internal vector.
Definition: ArpackSolver.hxx:91
Seldon::ArpackSolver::ipntr_
int ipntr_[14]
Vector that handles original ARPACK pointers.
Definition: ArpackSolver.hxx:87
Seldon::ArpackSolver::ido_
int ido_
ARPACK reverse communication flag.
Definition: ArpackSolver.hxx:75
Seldon::ArpackSolver::Continue
bool Continue()
Calls ARPACK computation routine.
Definition: ArpackSolver.cxx:333
Seldon::ArpackSolver::GetInfoFlag
int GetInfoFlag()
Gets the info flag.
Definition: ArpackSolver.cxx:306
Seldon::ArpackSolver::GetConvergedNumber
int GetConvergedNumber()
Gets the number of "converged" Ritz values.
Definition: ArpackSolver.cxx:325
Seldon::ArpackSolver::mode_
int mode_
Indicates the type of the eigenproblem (regular, shift and invert, etc).
Definition: ArpackSolver.hxx:48
Seldon::ArpackSolver::GetEigenValue
Y GetEigenValue(int index)
Gets one eigenvalue.
Definition: ArpackSolver.cxx:279
Seldon::ArpackSolver::bmat_
char bmat_
Standard ('I') or generalized ('G") eigenproblem?
Definition: ArpackSolver.hxx:52
Seldon::ArpackSolver::SetArpackVerbose
void SetArpackVerbose()
tells to Arpack to display debug information
Definition: ArpackSolver.cxx:164
Seldon::ArpackSolver::pselect_
int * pselect_
Definition: ArpackSolver.hxx:69
Seldon::ArpackSolver::Init
void Init(int n, int nev, int ncv, int maxit, T tol, string solver_type, int mode, string which, char bmat, char HowMny, bool with_arpack_verbose=false)
Initializations.
Definition: ArpackSolver.cxx:65
Seldon::ArpackSolver::rwork_
T * rwork_
ARPACK internal vector.
Definition: ArpackSolver.hxx:89
Seldon::ArpackSolver::ierr_
int ierr_
Error flag on output.
Definition: ArpackSolver.hxx:71
Seldon::ArpackSolver::ldv_
int ldv_
Leading dimension of the Arnoldi basis / Schur vectors (v_).
Definition: ArpackSolver.hxx:63
Seldon::ArpackSolver::workd_
Y * workd_
ARPACK internal vector.
Definition: ArpackSolver.hxx:93
Seldon::ArpackSolver::solver_type_
string solver_type_
Type of solver; set to "symmetric", "non-symmetric", "complex-single", or "complex-double".
Definition: ArpackSolver.hxx:46
Seldon::ArpackSolver::ClearArpackVerbose
void ClearArpackVerbose()
No ARPACK info is to be displayed.
Definition: ArpackSolver.cxx:218
Seldon::ArpackSolver::lworkl_
int lworkl_
Dimension of array workl.
Definition: ArpackSolver.hxx:79
Seldon::ArpackSolver::nev_
int nev_
Number of eigenvalues to be computed.
Definition: ArpackSolver.hxx:37
Seldon::ArpackSolver::ArpackSolver
ArpackSolver()
Constructor.
Definition: ArpackSolver.cxx:33
Seldon::ArpackSolver::which_
string which_
Specify which of the Ritz values of OP to compute.
Definition: ArpackSolver.hxx:50
Seldon::ArpackSolver::SetInfoFlag
void SetInfoFlag(int info)
Sets the info flag.
Definition: ArpackSolver.cxx:317
Seldon::ArpackSolver::ishfts_
int ishfts_
With shift?
Definition: ArpackSolver.hxx:61
Seldon::ArpackSolver::GetEigenVector
Y * GetEigenVector(int index)
Gets one eigenvector.
Definition: ArpackSolver.cxx:268
Seldon::ArpackSolver::info_
int info_
ARPACK error flag.
Definition: ArpackSolver.hxx:77
Seldon::ArpackSolver::lworkv_
int lworkv_
Dimension of array workv.
Definition: ArpackSolver.hxx:81
Seldon::ArpackSolver::GetFirstWorkVector
Y * GetFirstWorkVector()
Gets the address of the first vector in the ARPACK working array.
Definition: ArpackSolver.cxx:249
Seldon
Seldon namespace.
Definition: Array.cxx:24
Seldon::ArpackSolver::ncv_
int ncv_
Number of Arnoldi vectors generated at each iteration.
Definition: ArpackSolver.hxx:39
Seldon::ArpackSolver::Clear
void Clear()
Clear memories.
Definition: ArpackSolver.cxx:122
Seldon::ArpackSolver::HowMny_
char HowMny_
Definition: ArpackSolver.hxx:55
Seldon::ArpackSolver::eig_val_
Y * eig_val_
Eigenvalues.
Definition: ArpackSolver.hxx:104
Seldon::ArpackSolver::lrwork_
int lrwork_
Dimension of array rwork.
Definition: ArpackSolver.hxx:83
Seldon::ArpackSolver::Allocate
void Allocate()
Allocates arrays.
Definition: ArpackSolver.cxx:134
Seldon::ArpackSolver::iparam_
int iparam_[11]
Vector that handles original ARPACK parameters.
Definition: ArpackSolver.hxx:85
Seldon::ArpackSolver::sigma_
Y sigma_
Shift.
Definition: ArpackSolver.hxx:57
Seldon::ArpackSolver::eig_vec_
Y * eig_vec_
Eigenvectors.
Definition: ArpackSolver.hxx:106