Robot Simulator of the Robotics Group for Self-Organization of Control  0.8.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
matrixutils.h
Go to the documentation of this file.
1 /***************************************************************************
2  matrixutils.h - description
3  -------------------
4  email : georg.martius@web.de
5 ***************************************************************************/
6 // provides utils for matrix calculation using the GSL (gnu scientific library)
7 
8 #ifndef MATRIXUTILS_H
9 #define MATRIXUTILS_H
10 
11 
12 #include "matrix.h"
13 
14 /**
15  * namespace for the matrix library
16  */
17 namespace matrix{
18 
19  /**
20  calculates the eigenvalues of the real and symmetric matrix m
21  and returns them as a column vector in descending order
22  */
24 
25  /**
26  calculates the eigenvalues and corresponding eigenvectors
27  of the the real and symmetric matrix m.
28  The eigenvalues are returned them as a column vector in descending order
29  and the belonging
30  eigenvectors are stored in the columns of the matrix eigenvectors.
31  */
32  bool eigenValuesVectorsRealSym(const Matrix &m, Matrix& eigenvalues, Matrix& eigenvectors);
33 
34  /**
35  calculates the eigenvalues of the matrix m and returns them as a column vectors
36  seperated to real and imaginary part in descending order.
37  */
38  bool eigenValues(const Matrix &m, Matrix& vals_real, Matrix& vals_imag);
39 
40  /**
41  calculates the eigenvalues and corresponding eigenvectors
42  of the matrix m. The eigenvalues are returned them as a column vector
43  in descending order and the belonging
44  eigenvectors are stored in the columns of the matrix eigenvectors.
45  Both are seperated into real and imaginary part.
46  */
47  bool eigenValuesVectors(const Matrix &m, Matrix& vals_real, Matrix& vals_imag,
48  Matrix& vecs_real, Matrix& vecs_imag);
49 
50 
51  /**
52  flips the signs of the eigenvectors such that their first entry has positive real part.
53  If the first entry is very small the first no-vanishing entry is used.
54  The eigenvectors are assumed to be columnwise (as returned by eigenValues() etc).
55  Returns the original signs (1 or -1 per column)
56  */
57  std::vector<int> toPositiveSignEigenVectors(Matrix& vecs_real, Matrix& vecs_imag);
58 
59  /**
60  scales the eigenvectors with the absolute value of the eigenvalues.
61  returns vector with factors
62  */
63  Matrix scaleEigenVectorsWithValue(const Matrix& vals_real, const Matrix& vals_imag,
64  Matrix& vecs_real, Matrix& vecs_imag);
65 
66 }
67 
68 #endif
Matrixd Matrix
Definition: osgforwarddecl.h:47
Matrix eigenValuesRealSym(const Matrix &m)
calculates the eigenvalues of the real and symmetric matrix m and returns them as a column vector in ...
Definition: matrixutils.cpp:26
Matrix scaleEigenVectorsWithValue(const Matrix &vals_real, const Matrix &vals_imag, Matrix &vecs_real, Matrix &vecs_imag)
scales the eigenvectors with the absolute value of the eigenvalues.
Definition: matrixutils.cpp:247
bool eigenValues(const Matrix &m, Matrix &real, Matrix &imag)
calculates the eigenvalues of the matrix m and returns them as a column vectors seperated to real and...
Definition: matrixutils.cpp:71
std::vector< int > toPositiveSignEigenVectors(Matrix &vecs_real, Matrix &vecs_imag)
flips the signs of the eigenvectors such that their first entry has positive real part...
Definition: matrixutils.cpp:225
bool eigenValuesVectorsRealSym(const Matrix &m, Matrix &eigenvalues, Matrix &eigenvectors)
calculates the eigenvalues and corresponding eigenvectors of the the real and symmetric matrix m...
Definition: matrixutils.cpp:46
bool eigenValuesVectors(const Matrix &m, Matrix &vals_real, Matrix &vals_imag, Matrix &vecs_real, Matrix &vecs_imag)
calculates the eigenvalues and corresponding eigenvectors of the matrix m.
Definition: matrixutils.cpp:92