CppNoddy  0.92
Loading...
Searching...
No Matches
Functions
EVPComplex_lapack.cpp File Reference

Solves a 4x4 complex generalised eigenvalue problem. More...

#include <EVP_bundle.h>

Go to the source code of this file.

Functions

int main ()
 

Detailed Description

Solves a 4x4 complex generalised eigenvalue problem.

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

for the 4 eigenvalues $ \lambda_i $, $i=1,2,3,4.$. In this case $ A_{4x4} $ and $ B_{4x4} $ are such that the eigenvalues are $ 3-9i,\, 2-5i,\, 3-i,\, 4-5i $. The computation requests eigenvalues that satisfy $ \vert\lambda\vert < 4$, which in this case is $ 3-i $.

Definition in file EVPComplex_lapack.cpp.

Function Documentation

◆ main()

int main ( )

Definition at line 17 of file EVPComplex_lapack.cpp.

18{
19 cout << "\n";
20 cout << "=== EVP: complex generalised eigenvalue problem ====\n";
21 cout << "\n";
22
23 DenseMatrix<D_complex> a( 4, 4, 0.0 );
24
25 a( 0, 0 ) = D_complex( -21.10, -22.50 );
26 a( 0, 1 ) = D_complex( 53.50, -50.50 );
27 a( 0, 2 ) = D_complex( -34.50, 127.50 );
28 a( 0, 3 ) = D_complex( 7.50, 0.50 );
29
30 a( 1, 0 ) = D_complex( -0.46, -7.78 );
31 a( 1, 1 ) = D_complex( -3.50, -37.50 );
32 a( 1, 2 ) = D_complex( -15.50, 58.50 );
33 a( 1, 3 ) = D_complex( -10.50, -1.50 );
34
35 a( 2, 0 ) = D_complex( 4.30, -5.50 );
36 a( 2, 1 ) = D_complex( 39.70, -17.10 );
37 a( 2, 2 ) = D_complex( -68.50, 12.50 );
38 a( 2, 3 ) = D_complex( -7.50, -3.50 );
39
40 a( 3, 0 ) = D_complex( 5.50, 4.40 );
41 a( 3, 1 ) = D_complex( 14.40, 43.30 );
42 a( 3, 2 ) = D_complex( -32.50, -46.00 );
43 a( 3, 3 ) = D_complex( -19.00, -32.50 );
44
45 DenseMatrix<D_complex> b( 4, 4, 0.0 );
46
47 b( 0, 0 ) = D_complex( 1.00, -5.00 );
48 b( 0, 1 ) = D_complex( 1.60, 1.20 );
49 b( 0, 2 ) = D_complex( -3.00, 0.00 );
50 b( 0, 3 ) = D_complex( 0.00, -1.00 );
51
52 b( 1, 0 ) = D_complex( 0.80, -0.60 );
53 b( 1, 1 ) = D_complex( 3.00, -5.00 );
54 b( 1, 2 ) = D_complex( -4.00, 3.00 );
55 b( 1, 3 ) = D_complex( -2.40, -3.20 );
56
57 b( 2, 0 ) = D_complex( 1.00, 0.00 );
58 b( 2, 1 ) = D_complex( 2.40, 1.80 );
59 b( 2, 2 ) = D_complex( -4.00, -5.00 );
60 b( 2, 3 ) = D_complex( 0.00, -3.00 );
61
62 b( 3, 0 ) = D_complex( 0.00, 1.00 );
63 b( 3, 1 ) = D_complex( -1.80, 2.40 );
64 b( 3, 2 ) = D_complex( 0.00, -4.00 );
65 b( 3, 3 ) = D_complex( 4.00, -5.00 );
66
67 // a vector for the eigenvalues
69 // eigenvalues are: (3,-9), (2,-5), (3,-1), (4,-5)
70
71 DenseLinearEigenSystem<D_complex> system( &a, &b );
72 try
73 {
74 system.eigensolve();
75 }
76 catch (const std::runtime_error &error )
77 {
78 cout << " \033[1;31;48m * FAILED THROUGH EXCEPTION BEING RAISED \033[0m\n";
79 return 1;
80 }
81
82 // tag any eigenvalues within a distance of 0.1 of the point 3-i
83 system.set_shift( D_complex( 3.0, -1.0 ) );
84 system.tag_eigenvalues_disc( + 1, 0.1 );
85 // get those tagged eigenvalues
86 lambdas = system.get_tagged_eigenvalues();
87 const double tol = 1.e-14;
88 if ( std::abs( lambdas[ 0 ] - D_complex( 3.0, -1.0 ) ) > tol )
89 {
90 cout << "\033[1;31;48m * FAILED \033[0m\n";
91 cout.precision( 12 );
92 cout << " Final error = " << std::abs( lambdas[ 0 ] - D_complex( 3.0, -1.0 ) ) << "\n";
93 lambdas.dump();
94 return 1;
95 }
96
97 cout << "\033[1;32;48m * PASSED \033[0m\n";
98 return 0;
99
100}
A linear Nth-order generalised eigensystem class.
A matrix class that constructs a DENSE matrix as a row major std::vector of DenseVectors.
Definition: DenseMatrix.h:25
An DenseVector class – a dense vector object.
Definition: DenseVector.h:34
void dump() const
Dump to std::cout.
Definition: DenseVector.cpp:64
std::complex< double > D_complex
A complex double precision number using std::complex.
Definition: Types.h:98

References CppNoddy::DenseVector< _Type >::dump(), CppNoddy::DenseLinearEigenSystem< _Type >::eigensolve(), CppNoddy::DenseLinearEigenSystem< _Type >::get_tagged_eigenvalues(), CppNoddy::LinearEigenSystem_base::set_shift(), and CppNoddy::DenseLinearEigenSystem< _Type >::tag_eigenvalues_disc().

© 2012

R.E. Hewitt