Class documentation of Concepts

Loading...
Searching...
No Matches
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
14namespace 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 {
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 {
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
75namespace 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
90 GEVPSolver(concepts::ShiftAndInvertOperatorForGEVPs<F> OP, int kmax = 6,
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
102 virtual const concepts::Array<concepts::Vector<Cmplx>*>& getEF();
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:
115 ArPackppStd<F> standard_evp_solver;
116 F _shift;
117 concepts::Array<Cmplx> _unshifted_eigenvalues;
118
119 };
120
121}
122
123#endif /* EIGENSOLVER_GEVP_SOLVER_HH_ */
const uint nofCols() const
Number of columns.
Definition matrix.hh:58
const uint nofRows() const
Number of rows.
Definition matrix.hh:56
virtual void apply_(const Vector< F > &fncY, Vector< F > &fncX)
virtual std::ostream & info(std::ostream &os) const
Returns information in an output stream.
std::string typeOf(const T &t)
Definition output.hh:43
Set< F > makeSet(uint n, const F &first,...)
Definition set.hh:320