75 #ifndef SLIP_LINEAR_ALGEBRA_EIGEN_HPP
76 #define SLIP_LINEAR_ALGEBRA_EIGEN_HPP
120 template <
class Matrix1,
125 Vector1& EigenValues,
126 Matrix2& EigenVectors)
128 typedef typename Matrix1::value_type value_type;
129 std::size_t A_rows = A.rows();
130 std::size_t A_cols = A.cols();
137 AA.resize(A_cols,A_cols);
138 U.resize(A_cols,A_cols);
139 EigenValues.resize(A_cols);
140 EigenVectors.resize(A_cols,A_cols);
142 for(std::size_t i = 0; i < A_cols; ++i)
144 for(std::size_t j = 0; j < A_cols; ++j)
150 slip::svd(AA,U,EigenValues.begin(),EigenValues.end(),EigenVectors);
155 AA.resize(A_rows,A_rows);
156 V.resize(A_rows,A_rows);
157 EigenValues.resize(A_rows);
158 EigenVectors.resize(A_rows,A_rows);
160 for(std::size_t i = 0; i < A_rows; ++i)
162 for(std::size_t j = 0; j < A_rows; ++j)
168 slip::svd(AA,EigenVectors,EigenValues.begin(),EigenValues.end(),V);
202 template <
class Matrix1,
class Vector1>
204 void eigen(
const Matrix1 & A, Vector1 & E,
bool sort=
false)
206 typedef typename Matrix1::value_type value_type;
215 for(std::size_t i = 0 ; i < E.size() ; ++i)
217 if(
std::abs(std::imag(E[i])) > slip::epsilon<typename slip::lin_alg_traits<typename Vector1::value_type>::value_type >())
226 typedef typename Vector1::value_type complex_type;
228 for(std::size_t i = 0; i < E.size(); ++i)
230 Er[i] = std::real(E[i]);
232 std::sort(Er.begin(),Er.end(),std::greater<real>());
233 E.fill(
typename Vector1::value_type(0));
236 for(std::size_t i = 0; i < E.size(); ++i)
240 E[i] = complex_type(Er[i],
real(0));
265 template <
class Matrix1>
283 #endif //SLIP_LINEAR_ALGEBRA_EIGEN_HPP
Provides a class to manipulate 2d dynamic and generic arrays.
slip::lin_alg_traits< typename Matrix1::value_type >::value_type spectral_radius(const Matrix1 &A)
Spectral radius of a matrix .
bool schur(const Matrix1 &M, Matrix2 &H, Matrix3 &Z, Vector &Eig, bool compute_Z, typename slip::lin_alg_traits< typename Matrix1::value_type >::value_type precision=typename slip::lin_alg_traits< typename Matrix1::value_type >::value_type(1.0E-12))
computes the shur decomposition of a square Matrix and copy the eigenvalues in the Eig vector: Algor...
Provides common linear algebra algorithms.
void real(const Matrix1 &C, Matrix2 &R)
Extract the real Matrix of a complex Matrix. .
HyperVolume< T > abs(const HyperVolume< T > &M)
void eigen(const Matrix1 &A, Vector1 &E, bool sort=false)
Eigen Values Computation for non symmetric matrix.
void hermitian_eigen(const Matrix1 &A, Vector1 &EigenValues, Matrix2 &EigenVectors)
Eigen Values Computation of an hermitian semi-definite positive matrix.
Provides some macros which are used for using complex as real.
Numerical Vector class. This container statisfies the RandomAccessContainer concepts of the Standard ...
Provides some mathematical functors and constants.
HyperVolume< T > sqrt(const HyperVolume< T > &M)
Compare two element according to their absolute value. Return true if std::abs(__x) > std::abs( __y)...
std::iterator_traits< RandomAccessIterator1 >::value_type hermitian_inner_product(RandomAccessIterator1 first1, RandomAccessIterator1 last1, RandomAccessIterator2 first2, typename std::iterator_traits< RandomAccessIterator1 >::value_type init)
Computes the hermitian inner-product of two ranges X and Y: .
void svd(const Matrix1 &M, Matrix2 &U, RandomAccessIterator S_first, RandomAccessIterator S_last, Matrix3 &V, const int max_it=75)
(thin) Singular Value Decomposition Given a matrix M, this function computes its singular value decom...
Provides some QR decomposition algorithms.
Provides some algorithms to apply C like functions to ranges.
Provides some algorithms to add noise to ranges.
void balance(Matrix1 &A, Matrix2 &D)
applies a diagonal similarity transform to the square matrix A to make the rows and columns as close ...
Provides some Singular Value Decomposition (SVD) algorithms.
void apply(InputIterator first, InputIterator last, OutputIterator result, typename std::iterator_traits< OutputIterator >::value_type(*function)(typename std::iterator_traits< InputIterator >::value_type))
Applies a C-function to each element of a range.
Provides a class to manipulate numerical vectors.
This is a two-dimensional dynamic and generic container. This container statisfies the Bidirectionnal...
Provides some algorithms to compute norms.