CppNoddy  0.92
Loading...
Searching...
No Matches
Public Member Functions | Protected Types | Protected Attributes | List of all members
CppNoddy::LinearEigenSystem_base Class Reference

A linear Nth-order generalised eigensystem base class. More...

#include <LinearEigenSystem_base.h>

Inheritance diagram for CppNoddy::LinearEigenSystem_base:
CppNoddy::DenseLinearEigenSystem< _Type >

Public Member Functions

 LinearEigenSystem_base ()
 Constructor for a linear system object. More...
 
virtual ~LinearEigenSystem_base ()
 Destructor for a linear system object. More...
 
virtual void eigensolve ()
 Solve the matrix linear eigensystem. More...
 
void set_calc_eigenvectors (bool flag)
 Compute the eigenvectors in any eigenvalue computation. More...
 
void set_shift (const D_complex &z)
 Set the shift value to be used in tagging. More...
 
D_complex get_shift () const
 Get the shift value associated with this class (used for tagging) and eigenvalue tagging. More...
 
virtual void tag_eigenvalues_right (const int &val)
 Tag those eigenvalues that are to the right of a specified shft point. More...
 
virtual void tag_eigenvalues_left (const int &val)
 Tag those eigenvalues that are to the left of a specified point. More...
 
virtual void tag_eigenvalues_upper (const int &val)
 Tag those eigenvalues that are in the upper half-plane above a specified point. More...
 
virtual void tag_eigenvalues_lower (const int &val)
 Tag those eigenvalues that are in the lower half-plane below a specified point. More...
 
virtual void tag_eigenvalues_disc (const int &val, const double &radius)
 Tag those eigenvalues that are within a disc centred at a point in the complex plane. More...
 
virtual void tag_eigenvalues_all ()
 Tag all the eigenvalues returned from the ARPACK routine. More...
 
virtual void clear_all_tags ()
 
virtual DenseVector< D_complexget_tagged_eigenvalues () const
 Get the the tagged eigenvalues. More...
 
virtual DenseMatrix< D_complexget_tagged_eigenvectors () const
 Get the the tagged eigenvectors. More...
 

Protected Types

typedef std::set< unsigned, std::less< unsigned > >::iterator iter
 
typedef std::set< unsigned, std::less< unsigned > >::const_iterator citer
 

Protected Attributes

DenseVector< D_complexm_all_eigenvalues
 storage for eigenvectors and eigenvalues More...
 
DenseMatrix< D_complexm_all_eigenvectors
 
std::set< unsigned, std::less< unsigned > > m_tagged_indices
 a set of tagged eigenvalue indices More...
 
D_complex m_shift
 The complex shift value. More...
 
bool m_calc_eigenvectors
 calculate the eigenvectors in any eigenvalue computation More...
 

Detailed Description

A linear Nth-order generalised eigensystem base class.

Here we can construct a linear eigenproblem in the form

\[ A_{NxN} \,{\underline x}_i = \lambda_i\, B_{NxN}\, {\underline x}_i \]

for matrices $ A $ and $ B $. The eigenvalues and eigenvectors can be tagged and retrieved as required.

Definition at line 18 of file LinearEigenSystem_base.h.

Member Typedef Documentation

◆ citer

typedef std::set<unsigned,std::less<unsigned>>::const_iterator CppNoddy::LinearEigenSystem_base::citer
protected

Definition at line 25 of file LinearEigenSystem_base.h.

◆ iter

typedef std::set<unsigned,std::less<unsigned>>::iterator CppNoddy::LinearEigenSystem_base::iter
protected

Definition at line 23 of file LinearEigenSystem_base.h.

Constructor & Destructor Documentation

◆ LinearEigenSystem_base()

CppNoddy::LinearEigenSystem_base::LinearEigenSystem_base ( )

Constructor for a linear system object.

Definition at line 14 of file LinearEigenSystem_base.cpp.

14 :
15 m_shift(D_complex(0., 0.)),
17 }
D_complex m_shift
The complex shift value.
bool m_calc_eigenvectors
calculate the eigenvectors in any eigenvalue computation
std::complex< double > D_complex
A complex double precision number using std::complex.
Definition: Types.h:98

◆ ~LinearEigenSystem_base()

CppNoddy::LinearEigenSystem_base::~LinearEigenSystem_base ( )
virtual

Destructor for a linear system object.

Definition at line 20 of file LinearEigenSystem_base.cpp.

21 {}

Member Function Documentation

◆ clear_all_tags()

virtual void CppNoddy::LinearEigenSystem_base::clear_all_tags ( )
inlinevirtual

Definition at line 79 of file LinearEigenSystem_base.h.

79 {
80 m_tagged_indices.clear();
81 }
std::set< unsigned, std::less< unsigned > > m_tagged_indices
a set of tagged eigenvalue indices

References m_tagged_indices.

◆ eigensolve()

void CppNoddy::LinearEigenSystem_base::eigensolve ( )
virtual

Solve the matrix linear eigensystem.

Reimplemented in CppNoddy::DenseLinearEigenSystem< _Type >.

Definition at line 34 of file LinearEigenSystem_base.cpp.

34 {
35 std::string problem;
36 problem = "The LinearEigenSystem_base::eigensolve method has been called\n";
37 problem += "but the method has not been implemented ... this should be \n";
38 problem += "implemented in the sub-class.";
39 throw ExceptionExternal(problem);
40 }

◆ get_shift()

std::complex< double > CppNoddy::LinearEigenSystem_base::get_shift ( ) const

Get the shift value associated with this class (used for tagging) and eigenvalue tagging.

Definition at line 29 of file LinearEigenSystem_base.cpp.

29 {
30 return m_shift;
31 }

References m_shift.

◆ get_tagged_eigenvalues()

DenseVector< D_complex > CppNoddy::LinearEigenSystem_base::get_tagged_eigenvalues ( ) const
virtual

Get the the tagged eigenvalues.

All of the tagged eigenvalues are returned in a complex vector, with no ordering guaranteed.

Returns
The tagged eigenvalues as a complex vector

Reimplemented in CppNoddy::DenseLinearEigenSystem< _Type >.

Definition at line 48 of file LinearEigenSystem_base.cpp.

48 {
49 if(m_tagged_indices.size() == 0) {
50 std::string problem;
51 problem = "In LinearEigenSystem_base.get_tagged_eigenvalues() : there are\n";
52 problem += "no eigenvalues that have been tagged. This set is empty.\n";
53 throw ExceptionRuntime(problem);
54 }
55 // storage for the eigenvalues
56 DenseVector<D_complex> evals;
57 // loop through the tagged set
58 for(iter p = m_tagged_indices.begin(); p != m_tagged_indices.end(); ++p) {
59 // get the index of the relevant eigenvalue from the set
60 std::size_t j = *p;
61 std::cout << " number " << j << " is a tagged ev.\n";
62 // work out the complex eigenvalue associated with this index
63 // and add it to the vector
64 evals.push_back(m_all_eigenvalues[ j ]);
65 }
66 // return the complex vector of eigenvalues
67 return evals;
68 }
std::set< unsigned, std::less< unsigned > >::iterator iter
DenseVector< D_complex > m_all_eigenvalues
storage for eigenvectors and eigenvalues

References m_all_eigenvalues, m_tagged_indices, p, and CppNoddy::DenseVector< _Type >::push_back().

◆ get_tagged_eigenvectors()

DenseMatrix< D_complex > CppNoddy::LinearEigenSystem_base::get_tagged_eigenvectors ( ) const
virtual

Get the the tagged eigenvectors.

All of the eigenvectors associated with the tagged eigenvalues are returned, with the i-th eigenvector corresponding to the i-th eigenvalue as returned by the get_tagged_eigenvalues method. The i-th eigenvector is returned in row i of the complex dense matrix.

Returns
The tagged eigenvectors as a complex matrix

Reimplemented in CppNoddy::DenseLinearEigenSystem< _Type >.

Definition at line 71 of file LinearEigenSystem_base.cpp.

71 {
72 if(m_tagged_indices.size() == 0) {
73 std::string problem;
74 problem = "In LinearEigenSystem_base.get_tagged_eigenvectors() : there are\n";
75 problem += "no eigenvalues that have been tagged. This set is empty.\n";
76 throw ExceptionRuntime(problem);
77 }
78 // number of degrees of freedom in each eigenvector
79 std::size_t n = m_all_eigenvectors[0].size();
80 // eigenvector storage : size() eigenvectors each of length n
81 DenseMatrix<D_complex> evecs(m_tagged_indices.size(), n, 0.0);
82 std::size_t row = 0;
83 // loop through the tagged set
84 for(iter p = m_tagged_indices.begin(); p != m_tagged_indices.end(); ++p) {
85 // get the index of the relevant eigenvalue from the set
86 std::size_t j = *p;
87 // put the eigenvector in the matrix
88 evecs[ row ] = m_all_eigenvectors[ j ];
89 // next row/eigenvector
90 ++row;
91 }
92 return evecs;
93 }
DenseMatrix< D_complex > m_all_eigenvectors

References m_all_eigenvectors, m_tagged_indices, and p.

◆ set_calc_eigenvectors()

void CppNoddy::LinearEigenSystem_base::set_calc_eigenvectors ( bool  flag)

Compute the eigenvectors in any eigenvalue computation.

Parameters
flagThe boolean value to set.

Definition at line 43 of file LinearEigenSystem_base.cpp.

43 {
45 }

References m_calc_eigenvectors.

Referenced by main().

◆ set_shift()

void CppNoddy::LinearEigenSystem_base::set_shift ( const D_complex z)

Set the shift value to be used in tagging.

Parameters
zThe shift value to be used

Definition at line 24 of file LinearEigenSystem_base.cpp.

24 {
25 m_shift = z;
26 }

References m_shift.

Referenced by CppNoddy::HST::Rayleigh< _Type >::global_evp(), and main().

◆ tag_eigenvalues_all()

void CppNoddy::LinearEigenSystem_base::tag_eigenvalues_all ( )
virtual

Tag all the eigenvalues returned from the ARPACK routine.

Definition at line 98 of file LinearEigenSystem_base.cpp.

98 {
99 for(unsigned i = 0; i < m_all_eigenvalues.size(); ++i) {
100 m_tagged_indices.insert(m_tagged_indices.end(), i);
101 }
102 std::cout << "** I have tagged " << m_all_eigenvalues.size() << " eigenvalues.\n";
103 }
std::size_t size() const
A pass-thru definition to get the size of the vector.
Definition: DenseVector.h:330

References m_all_eigenvalues, m_tagged_indices, and CppNoddy::DenseVector< _Type >::size().

◆ tag_eigenvalues_disc()

void CppNoddy::LinearEigenSystem_base::tag_eigenvalues_disc ( const int &  val,
const double &  radius 
)
virtual

Tag those eigenvalues that are within a disc centred at a point in the complex plane.

Parameters
valTags are added or removed for val +ve or -ve
radiusThe radius of the disc to be considered

Reimplemented in CppNoddy::DenseLinearEigenSystem< _Type >.

Definition at line 106 of file LinearEigenSystem_base.cpp.

106 {
107 // loop through all the eigenvalues
108 for(std::size_t i = 0; i < m_all_eigenvalues.size(); ++i) {
109 // if the eigenvalue is in the disc centred at shift then include it
110 if(std::abs(m_all_eigenvalues[ i ] - m_shift) < radius) {
111 if(val > 0) {
112 // add it to our set of tagged eigenvalues
113 m_tagged_indices.insert(m_tagged_indices.end(), i);
114 } else {
115 // remove it from the set if it exists
116 m_tagged_indices.erase(i);
117 }
118 }
119 }
120 }

References m_all_eigenvalues, m_shift, m_tagged_indices, and CppNoddy::DenseVector< _Type >::size().

◆ tag_eigenvalues_left()

void CppNoddy::LinearEigenSystem_base::tag_eigenvalues_left ( const int &  val)
virtual

Tag those eigenvalues that are to the left of a specified point.

Parameters
valTags are added or removed for val +ve or -ve

Reimplemented in CppNoddy::DenseLinearEigenSystem< _Type >.

Definition at line 140 of file LinearEigenSystem_base.cpp.

140 {
141 // loop through all the eigenvalues
142 for(std::size_t i = 0; i < m_all_eigenvalues.size(); ++i) {
143 // if the eigenvalue is in the disc centred at m_shift then include it
144 if((m_all_eigenvalues[ i ] - m_shift).real() < 0.0) {
145 if(val > 0) {
146 // add it to our set of tagged eigenvalues
147 m_tagged_indices.insert(m_tagged_indices.end(), i);
148 } else {
149 // remove it from the set if it exists
150 m_tagged_indices.erase(i);
151 }
152 }
153 }
154 }
DenseVector< double > real(const DenseVector< D_complex > &X)
Return a double DENSE vector containing the real part of a complex DENSE vector.
Definition: Utility.cpp:177

References m_all_eigenvalues, m_shift, m_tagged_indices, and CppNoddy::DenseVector< _Type >::size().

◆ tag_eigenvalues_lower()

void CppNoddy::LinearEigenSystem_base::tag_eigenvalues_lower ( const int &  val)
virtual

Tag those eigenvalues that are in the lower half-plane below a specified point.

Parameters
valTags are added or removed for val +ve or -ve

Reimplemented in CppNoddy::DenseLinearEigenSystem< _Type >.

Definition at line 173 of file LinearEigenSystem_base.cpp.

173 {
174 // loop through all the eigenvalues
175 for(std::size_t i = 0; i < m_all_eigenvalues.size(); ++i) {
176 // if the eigenvalue is in the disc centred at m_shift then include it
177 if((m_all_eigenvalues[ i ] - m_shift).imag() < 0.0) {
178 if(val > 0) {
179 // add it to our set of tagged eigenvalues
180 m_tagged_indices.insert(m_tagged_indices.end(), i);
181 } else {
182 // remove it from the set if it exists
183 m_tagged_indices.erase(i);
184 }
185 }
186 }
187 }
DenseVector< double > imag(const DenseVector< D_complex > &X)
Return a double DENSE vector containing the imaginary part of a complex DENSE vector.
Definition: Utility.cpp:185

References m_all_eigenvalues, m_shift, m_tagged_indices, and CppNoddy::DenseVector< _Type >::size().

◆ tag_eigenvalues_right()

void CppNoddy::LinearEigenSystem_base::tag_eigenvalues_right ( const int &  val)
virtual

Tag those eigenvalues that are to the right of a specified shft point.

Parameters
valTags are added or removed for val +ve or -ve

Reimplemented in CppNoddy::DenseLinearEigenSystem< _Type >.

Definition at line 123 of file LinearEigenSystem_base.cpp.

123 {
124 // loop through all the eigenvalues
125 for(std::size_t i = 0; i < m_all_eigenvalues.size(); ++i) {
126 // if the eigenvalue is in the disc centred at m_shift then include it
127 if((m_all_eigenvalues[ i ] - m_shift).real() > 0.0) {
128 if(val > 0) {
129 // add it to our set of tagged eigenvalues
130 m_tagged_indices.insert(m_tagged_indices.end(), i);
131 } else {
132 // remove it from the set if it exists
133 m_tagged_indices.erase(i);
134 }
135 }
136 }
137 }

References m_all_eigenvalues, m_shift, m_tagged_indices, and CppNoddy::DenseVector< _Type >::size().

◆ tag_eigenvalues_upper()

void CppNoddy::LinearEigenSystem_base::tag_eigenvalues_upper ( const int &  val)
virtual

Tag those eigenvalues that are in the upper half-plane above a specified point.

Parameters
valTags are added or removed for val +ve or -ve

Reimplemented in CppNoddy::DenseLinearEigenSystem< _Type >.

Definition at line 157 of file LinearEigenSystem_base.cpp.

157 {
158 // loop through all the eigenvalues
159 for(std::size_t i = 0; i < m_all_eigenvalues.size(); ++i) {
160 // if the eigenvalue is in the disc centred at m_shift then include it
161 if((m_all_eigenvalues[ i ] - m_shift).imag() > 0.0) {
162 if(val > 0) {
163 // add it to our set of tagged eigenvalues
164 m_tagged_indices.insert(m_tagged_indices.end(), i);
165 } else {
166 // remove it from the set if it exists
167 m_tagged_indices.erase(i);
168 }
169 }
170 }
171 }

References m_all_eigenvalues, m_shift, m_tagged_indices, and CppNoddy::DenseVector< _Type >::size().

Member Data Documentation

◆ m_all_eigenvalues

DenseVector<D_complex> CppNoddy::LinearEigenSystem_base::m_all_eigenvalues
protected

◆ m_all_eigenvectors

DenseMatrix<D_complex> CppNoddy::LinearEigenSystem_base::m_all_eigenvectors
protected

Definition at line 99 of file LinearEigenSystem_base.h.

Referenced by get_tagged_eigenvectors().

◆ m_calc_eigenvectors

bool CppNoddy::LinearEigenSystem_base::m_calc_eigenvectors
protected

calculate the eigenvectors in any eigenvalue computation

Definition at line 109 of file LinearEigenSystem_base.h.

Referenced by set_calc_eigenvectors().

◆ m_shift

D_complex CppNoddy::LinearEigenSystem_base::m_shift
protected

◆ m_tagged_indices

std::set< unsigned, std::less<unsigned> > CppNoddy::LinearEigenSystem_base::m_tagged_indices
protected

The documentation for this class was generated from the following files:

© 2012

R.E. Hewitt