CppNoddy  0.92
All Classes Namespaces Files Functions Variables Typedefs Enumerator Friends Macros Modules Pages
Public Member Functions | List of all members
CppNoddy::DenseLinearEigenSystem< _Type > Class Template Reference

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

#include <DenseLinearEigenSystem.h>

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

Public Member Functions

 DenseLinearEigenSystem (DenseMatrix< _Type > *Aptr, DenseMatrix< _Type > *Bptr)
 Constructor for a linear system object. More...
 
 ~DenseLinearEigenSystem ()
 Destructor for a linear system object. More...
 
void eigensolve ()
 Solve the matrix linear eigensystem. More...
 
void tag_eigenvalues_right (const int &val)
 Tag those eigenvalues that are to the right of a specified point. More...
 
void tag_eigenvalues_left (const int &val)
 Tag those eigenvalues that are to the left of a specified point. More...
 
void tag_eigenvalues_upper (const int &val)
 Tag those eigenvalues that are in the upper half-plane above a specified point. More...
 
void tag_eigenvalues_lower (const int &val)
 Tag those eigenvalues that are in the lower half-plane below a specified point. More...
 
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...
 
DenseVector< D_complexget_tagged_eigenvalues () const
 Get the the tagged eigenvalues. More...
 
DenseMatrix< D_complexget_tagged_eigenvectors () const
 Get the the tagged eigenvectors. More...
 
- Public Member Functions inherited from CppNoddy::LinearEigenSystem_base
 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...
 

Additional Inherited Members

- Protected Types inherited from CppNoddy::LinearEigenSystem_base
typedef std::set< unsigned, std::less< unsigned > >::iterator iter
 
typedef std::set< unsigned, std::less< unsigned > >::const_iterator citer
 
- Protected Attributes inherited from CppNoddy::LinearEigenSystem_base
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

template<typename _Type>
class CppNoddy::DenseLinearEigenSystem< _Type >

A linear Nth-order generalised eigensystem class.

Here we can construct a linear eigenproblem in the form

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

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

Definition at line 19 of file DenseLinearEigenSystem.h.

Constructor & Destructor Documentation

◆ DenseLinearEigenSystem()

template<typename _Type >
CppNoddy::DenseLinearEigenSystem< _Type >::DenseLinearEigenSystem ( DenseMatrix< _Type > *  Aptr,
DenseMatrix< _Type > *  Bptr 
)

Constructor for a linear system object.

Parameters
AptrA pointer to a typed A matrix
BptrA pointer to a typed B matrix

Definition at line 17 of file DenseLinearEigenSystem.cpp.

17 :
19 m_pA = Aptr;
20 m_pB = Bptr;
21 }
LinearEigenSystem_base()
Constructor for a linear system object.

◆ ~DenseLinearEigenSystem()

template<typename _Type >
CppNoddy::DenseLinearEigenSystem< _Type >::~DenseLinearEigenSystem

Destructor for a linear system object.

Definition at line 24 of file DenseLinearEigenSystem.cpp.

25 {}

Member Function Documentation

◆ eigensolve()

template<typename _Type >
void CppNoddy::DenseLinearEigenSystem< _Type >::eigensolve
virtual

Solve the matrix linear eigensystem.

Reimplemented from CppNoddy::LinearEigenSystem_base.

Definition at line 28 of file DenseLinearEigenSystem.cpp.

28 {
29 // reset any tagged eigenvalues
30 m_tagged_indices.clear();
31 //
33 eigensolve_lapack_with_vectors();
34 } else {
35 eigensolve_lapack_without_vectors();
36 }
37 }
std::set< unsigned, std::less< unsigned > > m_tagged_indices
a set of tagged eigenvalue indices
bool m_calc_eigenvectors
calculate the eigenvectors in any eigenvalue computation

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

◆ get_tagged_eigenvalues()

template<typename _Type >
DenseVector< D_complex > CppNoddy::DenseLinearEigenSystem< _Type >::get_tagged_eigenvalues
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 from CppNoddy::LinearEigenSystem_base.

Definition at line 337 of file DenseLinearEigenSystem.cpp.

337 {
338 if(m_tagged_indices.size() == 0) {
339 std::string problem;
340 problem = "In DenseLinearEigenSystem.get_tagged_eigenvalues() : there are\n";
341 problem += "no eigenvalues that have been tagged. This set is empty.\n";
342 throw ExceptionRuntime(problem);
343 }
344 // storage for the eigenvalues
345 DenseVector<D_complex> evals;
346 // loop through the tagged set
347 for(iter p = m_tagged_indices.begin(); p != m_tagged_indices.end(); ++p) {
348 // get the index of the relevant eigenvalue from the set
349 std::size_t j = *p;
350 // work out the complex eigenvalue associated with this index
351 // and add it to the vector
352 evals.push_back(m_eigenvalues_alpha[ j ] / m_eigenvalues_beta[ j ]);
353 }
354 // return the complex vector of eigenvalues
355 return evals;
356 }
std::set< unsigned, std::less< unsigned > >::iterator iter

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

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

◆ get_tagged_eigenvectors()

template<typename _Type >
DenseMatrix< D_complex > CppNoddy::DenseLinearEigenSystem< _Type >::get_tagged_eigenvectors
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 from CppNoddy::LinearEigenSystem_base.

Definition at line 359 of file DenseLinearEigenSystem.cpp.

359 {
360 if(m_tagged_indices.size() == 0) {
361 std::string problem;
362 problem = "In DenseLinearEigenSystem.get_tagged_eigenvectors() : there are\n";
363 problem += "no eigenvalues that have been tagged. This set is empty.\n";
364 throw ExceptionRuntime(problem);
365 }
366 // order of the problem
367 std::size_t N = m_eigenvalues_alpha.size();
368 // eigenvector storage : size() eigenvectors each of length N
369 DenseMatrix<D_complex> evecs(m_tagged_indices.size(), N, 0.0);
370 std::size_t row = 0;
371 // loop through the tagged set
372 for(iter p = m_tagged_indices.begin(); p != m_tagged_indices.end(); ++p) {
373 // get the index of the relevant eigenvalue from the set
374 std::size_t j = *p;
375 // put the eigenvector in the matrix
376 evecs[ row ] = m_all_eigenvectors[ j ];
377 // next row/eigenvector
378 ++row;
379 }
380 return evecs;
381 }
std::size_t size() const
A pass-thru definition to get the size of the vector.
Definition: DenseVector.h:330
DenseMatrix< D_complex > m_all_eigenvectors

References p.

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

◆ tag_eigenvalues_disc()

template<typename _Type >
void CppNoddy::DenseLinearEigenSystem< _Type >::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 from CppNoddy::LinearEigenSystem_base.

Definition at line 386 of file DenseLinearEigenSystem.cpp.

386 {
387 // loop through all the eigenvalues
388 for(std::size_t i = 0; i < m_eigenvalues_alpha.size(); ++i) {
389 // if the eigenvalue is in the disc centred at m_shift then include it
390 if(std::abs(m_eigenvalues_alpha[ i ] - m_shift * m_eigenvalues_beta[ i ]) <
391 std::abs(radius * m_eigenvalues_beta[ i ])) {
392 if(val > 0) {
393 // add it to our set of tagged eigenvalues
394 m_tagged_indices.insert(m_tagged_indices.end(), i);
395 } else {
396 // remove it from the set if it exists
397 m_tagged_indices.erase(i);
398 }
399 }
400 }
401 }
D_complex m_shift
The complex shift value.

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

◆ tag_eigenvalues_left()

template<typename _Type >
void CppNoddy::DenseLinearEigenSystem< _Type >::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 from CppNoddy::LinearEigenSystem_base.

Definition at line 423 of file DenseLinearEigenSystem.cpp.

423 {
424 double real_value = m_shift.real();
425 // loop through all the eigenvalues
426 for(std::size_t i = 0; i < m_eigenvalues_alpha.size(); ++i) {
427 // if the eigenvalue is to the left of the shift position
428 if((m_eigenvalues_alpha[ i ] * std::conj(m_eigenvalues_beta[ i ])).real() <
429 std::pow(std::abs(m_eigenvalues_beta[ i ]), 2) * real_value) {
430 if(val > 0) {
431 // add it to our set of tagged eigenvalues
432 m_tagged_indices.insert(m_tagged_indices.end(), i);
433 } else {
434 // remove it from the set if it exists
435 m_tagged_indices.erase(i);
436 }
437 }
438 }
439 }
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

◆ tag_eigenvalues_lower()

template<typename _Type >
void CppNoddy::DenseLinearEigenSystem< _Type >::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 from CppNoddy::LinearEigenSystem_base.

Definition at line 461 of file DenseLinearEigenSystem.cpp.

461 {
462 double imag_value = m_shift.imag();
463 // loop through all the eigenvalues
464 for(std::size_t i = 0; i < m_eigenvalues_alpha.size(); ++i) {
465 // if the eigenvalue is in the half plane then include it
466 if((m_eigenvalues_alpha[ i ] * std::conj(m_eigenvalues_beta[ i ])).imag() <
467 std::pow(std::abs(m_eigenvalues_beta[ i ]), 2) * imag_value) {
468 if(val > 0) {
469 // add it to our set of tagged eigenvalues
470 m_tagged_indices.insert(m_tagged_indices.end(), i);
471 } else {
472 // remove it from the set if it exists
473 m_tagged_indices.erase(i);
474 }
475 }
476 }
477 }
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

◆ tag_eigenvalues_right()

template<typename _Type >
void CppNoddy::DenseLinearEigenSystem< _Type >::tag_eigenvalues_right ( const int &  val)
virtual

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

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

Reimplemented from CppNoddy::LinearEigenSystem_base.

Definition at line 404 of file DenseLinearEigenSystem.cpp.

404 {
405 double real_value = m_shift.real();
406 // loop through all the eigenvalues
407 for(std::size_t i = 0; i < m_eigenvalues_alpha.size(); ++i) {
408 // if the eigenvalue is to the right of the shift position
409 if((m_eigenvalues_alpha[ i ] * std::conj(m_eigenvalues_beta[ i ])).real() >
410 std::pow(std::abs(m_eigenvalues_beta[ i ]), 2) * real_value) {
411 if(val > 0) {
412 // add it to our set of tagged eigenvalues
413 m_tagged_indices.insert(m_tagged_indices.end(), i);
414 } else {
415 // remove it from the set if it exists
416 m_tagged_indices.erase(i);
417 }
418 }
419 }
420 }

◆ tag_eigenvalues_upper()

template<typename _Type >
void CppNoddy::DenseLinearEigenSystem< _Type >::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 from CppNoddy::LinearEigenSystem_base.

Definition at line 442 of file DenseLinearEigenSystem.cpp.

442 {
443 double imag_value = m_shift.imag();
444 // loop through all the eigenvalues
445 for(std::size_t i = 0; i < m_eigenvalues_alpha.size(); ++i) {
446 // if the eigenvalue is in the half plane then include it
447 if((m_eigenvalues_alpha[ i ] * std::conj(m_eigenvalues_beta[ i ])).imag() >
448 std::pow(std::abs(m_eigenvalues_beta[ i ]), 2) * imag_value) {
449 if(val > 0) {
450 // add it to our set of tagged eigenvalues
451 m_tagged_indices.insert(m_tagged_indices.end(), i);
452 } else {
453 // remove it from the set if it exists
454 m_tagged_indices.erase(i);
455 }
456 }
457 }
458 }

Referenced by main().


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

© 2012

R.E. Hewitt