gevp_solver.hh

Go to the documentation of this file.
1 
7 #ifndef EIGENSOLVER_GEVP_SOLVER_HH_
8 #define EIGENSOLVER_GEVP_SOLVER_HH_
9 
10 #include "arpackpp.hh"
11 #include "operator.hh"
12 #include "basics/typedefs.hh"
13 
14 namespace concepts
15 {
16 
17  template<class F>
19  {
20 
21  public:
23  F shift) :
24  VecOperator<F>(A.nofRows(), A.nofCols()), _B(B), _shift(shift)
25  {
26  SparseMatrix<F> shifted(A);
27  B.addInto(shifted, -shift); // shifted_matrix = A - shift*B
28 #ifdef HAS_MUMPS
29  _shift_and_invert_pointer.reset(new Mumps<F>(shifted));
30 #else
31  _shift_and_invert_pointer.reset(new SuperLU<F>(shifted));
32 #endif
33  }
34 
36  {
37  }
38 
39  F getShift();
40 
41  protected:
42  virtual std::ostream&
43  info(std::ostream& os) const
44  {
45  // TODO ergaenzen
46  return os << concepts::typeOf(*this);
47  }
48 
49  virtual void apply_(const Vector<F>& fncY, Vector<F>& fncX)
50  {
51  Vector<F> B_times_y(fncY.n());
52  _B(fncY, B_times_y);
53  (*_shift_and_invert_pointer)(B_times_y, fncX);
54  }
55 
56  virtual void apply_()
57  {
58  }
59 
60  private:
62 #ifdef HAS_MUMPS
63  std::unique_ptr<Mumps<F> > _shift_and_invert_pointer;
64 #else
65  std::unique_ptr<SuperLU<F> > _shift_and_invert_pointer;
66 #endif
67  F _shift;
68 
69  };
70 
71 }
72 
74 
75 namespace eigensolver
76 {
77 
78  template<typename F>
79  class GEVPSolver: public EigenSolver<Cmplx>
80  {
81 
82  public:
83  GEVPSolver(SparseMatrix<F>& A, SparseMatrix<F>& B, F shift, int kmax = 6,
84  Real tol = EPS,int maxiter=300):
85  standard_evp_solver(*(new concepts::ShiftAndInvertOperatorForGEVPs<F>(A,B,shift)),kmax,(char*)"LM",tol,maxiter),
86  _shift(shift)
87  {
88  }
89 
91  Real tol = EPS,int maxiter=300):
92  standard_evp_solver(OP,kmax,(char*)"LM",tol,maxiter), _shift(OP.getShift())
93  {
94  }
95 
96  virtual ~GEVPSolver()
97  {
98  }
99 
100  virtual const concepts::Array<Cmplx>& getEV();
101 
103 
104  virtual uint converged() const;
105 
106  virtual uint iterations() const;
107 
108  protected:
109  virtual std::ostream& info(std::ostream& os) const
110  {
111  return os << concepts::typeOf(*this);
112  }
113 
114  private:
118 
119  };
120 
121 }
122 
123 #endif /* EIGENSOLVER_GEVP_SOLVER_HH_ */
std::unique_ptr< SuperLU< F > > _shift_and_invert_pointer
Definition: gevp_solver.hh:65
Interafce for eigenvalue solvers.
Definition: eigens.hh:23
virtual const concepts::Array< concepts::Vector< Cmplx > * > & getEF()
virtual void apply_(const Vector< F > &fncY, Vector< F > &fncX)
Intrinsic application method, i.e.
Definition: gevp_solver.hh:49
Direct sparse solver for unsymmetric matrices.
Definition: superLU.hh:70
#define EPS
Definition: typedefs.hh:22
virtual uint iterations() const
void addInto(Matrix< H > &dest, const I fact, const uint rowoffset=0, const uint coloffset=0) const
This matrix is added as block to the given matrix dest.
concepts::Array< Cmplx > _unshifted_eigenvalues
Definition: gevp_solver.hh:117
ArPackppStd< F > standard_evp_solver
Definition: gevp_solver.hh:115
GEVPSolver(concepts::ShiftAndInvertOperatorForGEVPs< F > OP, int kmax=6, Real tol=EPS, int maxiter=300)
Definition: gevp_solver.hh:90
virtual std::ostream & info(std::ostream &os) const
Returns information in an output stream.
Definition: gevp_solver.hh:109
uint n() const
Elements in the vector.
Definition: vector.hh:224
Abstract class for an operator acting on vectors only, not arbitrary functions.
MUMPS : MUltifrontal Massively Parallel sparse direct Solver.
Definition: mumps.hh:72
virtual std::ostream & info(std::ostream &os) const
Definition: gevp_solver.hh:43
GEVPSolver(SparseMatrix< F > &A, SparseMatrix< F > &B, F shift, int kmax=6, Real tol=EPS, int maxiter=300)
Definition: gevp_solver.hh:83
std::string typeOf(const T &t)
Return the typeid name of a class object.
Definition: output.hh:43
virtual const concepts::Array< Cmplx > & getEV()
Returns an array with the eigen values.
virtual uint converged() const
virtual void apply_()
Intrinsic application method without argument.
Definition: gevp_solver.hh:56
Eigenvalue solvers.
Definition: ARPACK.hh:19
double Real
Type normally used for a floating point number.
Definition: typedefs.hh:36
Basic namespace for Concepts-2.
Definition: pml_formula.h:16
ShiftAndInvertOperatorForGEVPs(SparseMatrix< F > &A, SparseMatrix< F > &B, F shift)
Definition: gevp_solver.hh:22
Page URL: http://wiki.math.ethz.ch/bin/view/Concepts/WebHome
21 August 2020
© 2020 Eidgenössische Technische Hochschule Zürich