1 /*
2 ARPACK++ v1.2 2/20/2000
3 c++ interface to ARPACK code.
4
5 MODULE ARBGComp.h.
6 Arpack++ class ARluCompGenEig definition
7 (band matrix version).
8
9 ARPACK Authors
10 Richard Lehoucq
11 Danny Sorensen
12 Chao Yang
13 Dept. of Computational & Applied Mathematics
14 Rice University
15 Houston, Texas
16 */
17
18 #ifndef ARBGCOMP_H
19 #define ARBGCOMP_H
20
21 #include <cstddef>
22 #include <string>
23 #include "arch.h"
24 #include "arbnsmat.h"
25 #include "arbnspen.h"
26 #include "arrseig.h"
27 #include "argcomp.h"
28
29
30 template<class ARFLOAT>
31 class ARluCompGenEig:
32 public virtual
33 ARCompGenEig<ARFLOAT, ARbdNonSymPencil<arcomplex<ARFLOAT>, ARFLOAT >,
34 ARbdNonSymPencil<arcomplex<ARFLOAT>, ARFLOAT > > {
35
36 private:
37
38 // a) Data structure used to store matrices.
39
40 ARbdNonSymPencil<arcomplex<ARFLOAT>, ARFLOAT > Pencil;
41
42 // b) Protected functions:
43
44 virtual void Copy(const ARluCompGenEig& other);
45 // Makes a deep copy of "other" over "this" object.
46 // Old values are not deleted (this function is to be used
47 // by the copy constructor and the assignment operator only).
48
49
50 public:
51
52 // c) Public functions:
53
54 // c.1) Functions that allow changes in problem parameters.
55
56 virtual void ChangeShift(arcomplex<ARFLOAT> sigmaRp);
57
58 virtual void SetRegularMode();
59
60 virtual void SetShiftInvertMode(arcomplex<ARFLOAT> sigmap);
61
62 // c.2) Constructors and destructor.
63
ARluCompGenEig()64 ARluCompGenEig() { }
65 // Short constructor.
66
67 ARluCompGenEig(int nevp, ARbdNonSymMatrix<arcomplex<ARFLOAT>, ARFLOAT>& A,
68 ARbdNonSymMatrix<arcomplex<ARFLOAT>, ARFLOAT>& B,
69 const std::string& whichp = "LM", int ncvp = 0,
70 ARFLOAT tolp = 0.0, int maxitp = 0,
71 arcomplex<ARFLOAT>* residp = NULL, bool ishiftp = true);
72 // Long constructor (regular mode).
73
74 ARluCompGenEig(int nevp, ARbdNonSymMatrix<arcomplex<ARFLOAT>, ARFLOAT>& A,
75 ARbdNonSymMatrix<arcomplex<ARFLOAT>, ARFLOAT>& B,
76 arcomplex<ARFLOAT> sigma, const std::string& whichp = "LM",
77 int ncvp = 0, ARFLOAT tolp = 0.0, int maxitp = 0,
78 arcomplex<ARFLOAT>* residp = NULL, bool ishiftp = true);
79 // Long constructor (shift and invert mode).
80
ARluCompGenEig(const ARluCompGenEig & other)81 ARluCompGenEig(const ARluCompGenEig& other) { Copy(other); }
82 // Copy constructor.
83
~ARluCompGenEig()84 virtual ~ARluCompGenEig() { }
85
86 // d) Operators.
87
88 ARluCompGenEig& operator=(const ARluCompGenEig& other);
89 // Assignment operator.
90
91 }; // class ARluCompGenEig.
92
93
94 // ------------------------------------------------------------------------ //
95 // ARluCompGenEig member functions definition. //
96 // ------------------------------------------------------------------------ //
97
98
99 template<class ARFLOAT>
100 inline void ARluCompGenEig<ARFLOAT>::
Copy(const ARluCompGenEig<ARFLOAT> & other)101 Copy(const ARluCompGenEig<ARFLOAT>& other)
102 {
103
104 ARCompGenEig<ARFLOAT, ARbdNonSymPencil<arcomplex<ARFLOAT>, ARFLOAT >,
105 ARbdNonSymPencil<arcomplex<ARFLOAT>, ARFLOAT> >:: Copy(other);
106 Pencil = other.Pencil;
107 this->objOP = &Pencil;
108 this->objB = &Pencil;
109
110 } // Copy.
111
112
113 template<class ARFLOAT>
114 inline void ARluCompGenEig<ARFLOAT>::
ChangeShift(arcomplex<ARFLOAT> sigmaRp)115 ChangeShift(arcomplex<ARFLOAT> sigmaRp)
116 {
117
118 this->objOP->FactorAsB(sigmaRp);
119 ARrcStdEig<ARFLOAT, arcomplex<ARFLOAT> >::ChangeShift(sigmaRp);
120
121 } // ChangeShift.
122
123
124 template<class ARFLOAT>
SetRegularMode()125 inline void ARluCompGenEig<ARFLOAT>::SetRegularMode()
126 {
127
128 ARStdEig<ARFLOAT, arcomplex<ARFLOAT>,
129 ARbdNonSymPencil<arcomplex<ARFLOAT>, ARFLOAT> >::
130 SetRegularMode(&Pencil,
131 &ARbdNonSymPencil<arcomplex<ARFLOAT>, ARFLOAT>::MultInvBAv);
132
133 } // SetRegularMode.
134
135
136 template<class ARFLOAT>
137 inline void ARluCompGenEig<ARFLOAT>::
SetShiftInvertMode(arcomplex<ARFLOAT> sigmap)138 SetShiftInvertMode(arcomplex<ARFLOAT> sigmap)
139 {
140
141 ARCompGenEig<ARFLOAT, ARbdNonSymPencil<arcomplex<ARFLOAT>, ARFLOAT>,
142 ARbdNonSymPencil<arcomplex<ARFLOAT>, ARFLOAT> >::
143 SetShiftInvertMode(sigmap, &Pencil,
144 &ARbdNonSymPencil<arcomplex<ARFLOAT>,ARFLOAT>::MultInvAsBv);
145
146 } // SetShiftInvertMode.
147
148
149 template<class ARFLOAT>
150 inline ARluCompGenEig<ARFLOAT>::
ARluCompGenEig(int nevp,ARbdNonSymMatrix<arcomplex<ARFLOAT>,ARFLOAT> & A,ARbdNonSymMatrix<arcomplex<ARFLOAT>,ARFLOAT> & B,const std::string & whichp,int ncvp,ARFLOAT tolp,int maxitp,arcomplex<ARFLOAT> * residp,bool ishiftp)151 ARluCompGenEig(int nevp, ARbdNonSymMatrix<arcomplex<ARFLOAT>, ARFLOAT>& A,
152 ARbdNonSymMatrix<arcomplex<ARFLOAT>, ARFLOAT>& B, const std::string& whichp,
153 int ncvp, ARFLOAT tolp, int maxitp,
154 arcomplex<ARFLOAT>* residp, bool ishiftp)
155
156 {
157
158 Pencil.DefineMatrices(A, B);
159 this->NoShift();
160 this->DefineParameters(A.ncols(), nevp, &Pencil,
161 &ARbdNonSymPencil<arcomplex<ARFLOAT>, ARFLOAT>::MultInvBAv,
162 &Pencil,
163 &ARbdNonSymPencil<arcomplex<ARFLOAT>, ARFLOAT>::MultBv,
164 whichp, ncvp, tolp, maxitp, residp, ishiftp);
165
166 } // Long constructor (regular mode).
167
168
169 template<class ARFLOAT>
170 inline ARluCompGenEig<ARFLOAT>::
ARluCompGenEig(int nevp,ARbdNonSymMatrix<arcomplex<ARFLOAT>,ARFLOAT> & A,ARbdNonSymMatrix<arcomplex<ARFLOAT>,ARFLOAT> & B,arcomplex<ARFLOAT> sigmap,const std::string & whichp,int ncvp,ARFLOAT tolp,int maxitp,arcomplex<ARFLOAT> * residp,bool ishiftp)171 ARluCompGenEig(int nevp, ARbdNonSymMatrix<arcomplex<ARFLOAT>, ARFLOAT>& A,
172 ARbdNonSymMatrix<arcomplex<ARFLOAT>, ARFLOAT>& B,
173 arcomplex<ARFLOAT> sigmap, const std::string& whichp, int ncvp,
174 ARFLOAT tolp, int maxitp, arcomplex<ARFLOAT>* residp,
175 bool ishiftp)
176
177 {
178
179 Pencil.DefineMatrices(A, B);
180 this->DefineParameters(A.ncols(), nevp, &Pencil,
181 &ARbdNonSymPencil<arcomplex<ARFLOAT>, ARFLOAT>::MultInvAsBv,
182 &Pencil,
183 &ARbdNonSymPencil<arcomplex<ARFLOAT>,ARFLOAT>::MultBv,
184 whichp, ncvp, tolp, maxitp, residp, ishiftp);
185 SetShiftInvertMode(sigmap);
186
187 } // Long constructor (shift and invert mode).
188
189
190 template<class ARFLOAT>
191 ARluCompGenEig<ARFLOAT>& ARluCompGenEig<ARFLOAT>::
192 operator=(const ARluCompGenEig<ARFLOAT>& other)
193 {
194
195 if (this != &other) { // Stroustrup suggestion.
196 this->ClearMem();
197 Copy(other);
198 }
199 return *this;
200
201 } // operator=.
202
203
204 #endif // ARBGCOMP_H
205