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