|
Algorithms_in_C++ 1.0.0
Set of algorithms implemented in C++.
|
Compute real eigen values and eigen vectors of a symmetric matrix using QR decomposition method. More...
#include <cassert>#include <cmath>#include <cstdlib>#include <ctime>#include <iostream>#include "./qr_decompose.h"Namespaces | |
| namespace | qr_algorithm |
| Functions to compute QR decomposition of any rectangular matrix. | |
Macros | |
| #define | LIMS 9 |
Functions | |
| void | create_matrix (std::valarray< std::valarray< double > > *A) |
| void | mat_mul (const std::valarray< std::valarray< double > > &A, const std::valarray< std::valarray< double > > &B, std::valarray< std::valarray< double > > *OUT) |
| std::valarray< double > | qr_algorithm::eigen_values (std::valarray< std::valarray< double > > *A, bool print_intermediates=false) |
| void | test1 () |
| void | test2 () |
| int | main (int argc, char **argv) |
Compute real eigen values and eigen vectors of a symmetric matrix using QR decomposition method.
| #define LIMS 9 |
limit of range of matrix values
| void create_matrix | ( | std::valarray< std::valarray< double > > * | A | ) |
create a symmetric square matrix of given size with random elements. A symmetric square matrix will always have real eigen values.
| [out] | A | matrix to create (must be pre-allocated in memory) |
| int main | ( | int | argc, |
| char ** | argv | ||
| ) |
main function
| void mat_mul | ( | const std::valarray< std::valarray< double > > & | A, |
| const std::valarray< std::valarray< double > > & | B, | ||
| std::valarray< std::valarray< double > > * | OUT | ||
| ) |
Perform multiplication of two matrices.
| [in] | A | first matrix to multiply |
| [in] | B | second matrix to multiply |
| [out] | OUT | output matrix (must be pre-allocated) |
| void test1 | ( | ) |
test function to compute eigen values of a 2x2 matrix
\[\begin{bmatrix} 5 & 7\\ 7 & 11 \end{bmatrix}\]
which are approximately, {15.56158, 0.384227}
| void test2 | ( | ) |
test function to compute eigen values of a 2x2 matrix
\[\begin{bmatrix} -4& 4& 2& 0& -3\\ 4& -4& 4& -3& -1\\ 2& 4& 4& 3& -3\\ 0& -3& 3& -1&-1\\ -3& -1& -3& -3& 0 \end{bmatrix}\]
which are approximately, {9.27648, -9.26948, 2.0181, -1.03516, -5.98994}