tensor-0.1.0
 All Data Structures Namespaces Functions Variables Typedefs Enumerations Enumerator Groups Pages
arpack_z.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 #ifndef TENSOR_ARPACK_Z_H
21 #define TENSOR_ARPACK_Z_H
22 
23 #include <tensor/tensor_blas.h>
24 #include <tensor/linalg.h>
25 
26 namespace linalg {
27 
32 class CArpack {
33  public:
34  typedef tensor::cdouble elt_t;
35  typedef blas::integer integer;
36 
37  enum Status {
38  Uninitialized = 0,
39  Initialized = 1,
40  Running = 2,
41  Finished = 3,
42  Error = 4,
43  TooManyIterations = 5,
44  NoConvergence = 6,
45  };
46 
47  CArpack(size_t n, enum EigType t, size_t neig);
48  ~CArpack();
49  void set_random_start_vector();
50  void set_start_vector(const elt_t *v);
51  void set_tolerance(double tol);
52  void set_maxiter(size_t maxiter);
53  enum Status update();
54  elt_t *get_x_vector();
55  elt_t *get_y_vector();
56  const tensor::CTensor get_x();
57  tensor::CTensor get_y();
58  void set_y(const tensor::CTensor &y);
59  tensor::CTensor get_data(tensor::CTensor *vectors);
60  tensor::CTensor get_data(tensor::cdouble *z);
61  std::string error_message() { return std::string(error); };
62  enum Status get_status() { return status; };
63  size_t get_vector_size() { return n; };
64 
65  void prepare();
66  void clear();
67 
68  static tensor::Indices sort_values(const tensor::CTensor &t, EigType selector);
69 
70  protected:
71  enum Status status;
72  enum EigType which_eig;
73 
74  integer n; // Dimension of the eigenproblem.
75  integer nev; // Number of eigenvalues to be computed. 0 < nev < n-1.
76  integer ncv; // Number of Arnoldi vectors generated at each iteration.
77  integer maxit; // Maximum number of Arnoldi update iterations allowed.
78  const char* which; // Specify which of the Ritz values of OP to compute.
79  double tol; // Stopping criterion (relative accuracy of Ritz values).
80  elt_t sigma; // Shift (for nonsymmetric problems).
81  elt_t *resid; // Initial residual vector.
82 
83  // a.2) Internal variables.
84 
85  bool symmetric; // Symmetric matrix, or not
86  bool rvec; // Indicates if eigenvectors/Schur vectors were
87  // requested (or only eigenvalues will be determined).
88  char bmat; // Indicates if the problem is a standard ('I') or
89  // generalized ('G") eigenproblem.
90  char hwmny; // Indicates if eigenvectors ('A') or Schur vectors ('P')
91  // were requested (not referenced if rvec = false).
92  integer ido; // Original ARPACK reverse communication flag.
93  integer info; // Original ARPACK error flag.
94  integer mode; // Indicates the type of the eigenproblem (regular,
95  // shift and invert, etc).
96  integer lworkl; // Dimension of array workl.
97  integer lworkv; // Dimension of array workv.
98  integer lrwork; // Dimension of array rwork.
99  integer iparam[12]; // CVector that handles original ARPACK parameters.
100  integer ipntr[15]; // CVector that handles original ARPACK pointers.
101  double *rwork; // Original ARPACK internal vector.
102  elt_t *workl; // Original ARPACK internal vector.
103  elt_t *workd; // Original ARPACK internal vector.
104  elt_t *workv; // Original ARPACK internal vector.
105  elt_t *V; // Arnoldi basis / Schur vectors.
106 
107  // a.3) Pure output variables.
108 
109  integer nconv; // Number of "converged" Ritz values.
110 
111  const char *error;
112 };
113 
116 }
117 
118 #endif /* !TENSOR_ARPACK_Z_H */
Complex Tensor with elements of type "cdouble".
Definition: tensor.h:435
Vector of 'index' type, where 'index' fits the indices of a tensor.
Definition: indices.h:35
Finder of a few eigenvalues of eigenvectors via Arnoldi method.
Definition: arpack_z.h:32
EigType
Type of eigenvalues that eigs and Arpack compute.
Definition: linalg.h:69