RobWorkProject  23.9.11-
Classes | Static Public Member Functions | List of all members
LinearAlgebra Class Reference

Collection of Linear Algebra functions. More...

#include <LinearAlgebra.hpp>

Classes

struct  EigenMatrix
 Type for Eigen matrices used to reduce namespace cluttering. More...
 
struct  EigenVector
 Type for Eigen vectors, used to reduce namespace cluttering. More...
 

Static Public Member Functions

static void svd (const Eigen::Matrix< double, -1, -1 > &M, Eigen::Matrix< double, -1, -1 > &U, Eigen::Matrix< double, -1, 1 > &sigma, Eigen::Matrix< double, -1, -1 > &V)
 Performs a singular value decomposition (SVD) More...
 
static Eigen::Matrix< double, -1, -1 > pseudoInverse (const Eigen::Matrix< double, -1, -1 > &am, double precision=1e-6)
 Calculates the moore-penrose (pseudo) inverse of a matrix \( \mathbf{M}^+\). More...
 
static bool checkPenroseConditions (const Eigen::Matrix< double, -1, -1 > &A, const Eigen::Matrix< double, -1, -1 > &X, double prec)
 Checks the penrose conditions. More...
 
template<class R >
static double det (const Eigen::MatrixBase< R > &m)
 Calculates matrix determinant. More...
 
template<class T >
static T inverse (const Eigen::MatrixBase< T > &M)
 Calculates matrix inverse. More...
 
template<class R >
static bool isSO (const Eigen::MatrixBase< R > &M)
 Checks if a given matrix is in SO(n) (special orthogonal) More...
 
template<class R >
static bool isSO (const Eigen::MatrixBase< R > &M, typename R::Scalar precision)
 Checks if a given matrix is in SO(n) (special orthogonal) More...
 
template<class R >
static bool isSkewSymmetric (const Eigen::MatrixBase< R > &M)
 Checks if a given matrix is skew-symmetrical. More...
 
template<class R >
static bool isProperOrthonormal (const Eigen::MatrixBase< R > &r, typename R::Scalar precision=std::numeric_limits< typename R::Scalar >::epsilon())
 Checks if a given matrix is proper orthonormal. More...
 
template<class R >
static bool isOrthonormal (const Eigen::MatrixBase< R > &r, typename R::Scalar precision=std::numeric_limits< typename R::Scalar >::epsilon())
 Checks if a given matrix is orthonormal. More...
 
template<class T >
static std::pair< typename EigenMatrix< T >::type, typename EigenVector< T >::type > eigenDecompositionSymmetric (const Eigen::Matrix< T, Eigen::Dynamic, Eigen::Dynamic > &Am1)
 Decomposition for a symmetric matrix. More...
 
template<class T >
static std::pair< typename EigenMatrix< std::complex< T > >::type, typename EigenVector< std::complex< T > >::type > eigenDecomposition (const typename Eigen::Matrix< T, Eigen::Dynamic, Eigen::Dynamic > &Am1)
 Eigen decomposition of a matrix. More...
 
template<>
std::pair< typename LinearAlgebra::EigenMatrix< double >::type, typename LinearAlgebra::EigenVector< double >::type > eigenDecompositionSymmetric (const Eigen::MatrixXd &Am1)
 
template<>
std::pair< typename LinearAlgebra::EigenMatrix< std::complex< double > >::type, typename LinearAlgebra::EigenVector< std::complex< double > >::type > eigenDecomposition (const Eigen::MatrixXd &Am1)
 

Detailed Description

Collection of Linear Algebra functions.

Member Function Documentation

◆ checkPenroseConditions()

static bool checkPenroseConditions ( const Eigen::Matrix< double, -1, -1 > &  A,
const Eigen::Matrix< double, -1, -1 > &  X,
double  prec 
)
static

Checks the penrose conditions.

Parameters
A[in] a matrix
X[in] a pseudoinverse of A
prec[in] the tolerance
Returns
true if the pseudoinverse X of A fullfills the penrose conditions, false otherwise

Checks the penrose conditions:

\( AXA = A \)

\( XAX = X \)

\( (AX)^T = AX \)

\( (XA)^T = XA \)

◆ det()

static double det ( const Eigen::MatrixBase< R > &  m)
inlinestatic

Calculates matrix determinant.

Parameters
m[in] a square matrix
Returns
the matrix determinant

◆ eigenDecomposition()

static std::pair<typename EigenMatrix<std::complex<T> >::type, typename EigenVector<std::complex<T> >::type> eigenDecomposition ( const typename Eigen::Matrix< T, Eigen::Dynamic, Eigen::Dynamic > &  Am1)
inlinestatic

Eigen decomposition of a matrix.

Parameters
Am1[in] the matrix.
Returns
the decomposition as a pair with eigenvectors and eigenvalues.

◆ eigenDecompositionSymmetric()

static std::pair<typename EigenMatrix<T>::type, typename EigenVector<T>::type> eigenDecompositionSymmetric ( const Eigen::Matrix< T, Eigen::Dynamic, Eigen::Dynamic > &  Am1)
inlinestatic

Decomposition for a symmetric matrix.

Parameters
Am1[in] a symmetric matrix.
Returns
the decomposition as a pair with eigenvectors and eigenvalues.

◆ inverse()

static T inverse ( const Eigen::MatrixBase< T > &  M)
inlinestatic

Calculates matrix inverse.

Parameters
M[in] input matrix \( \mathbf{M} \) to invert
Returns
output matrix \( \mathbf{M}^{-1} \)

◆ isOrthonormal()

static bool isOrthonormal ( const Eigen::MatrixBase< R > &  r,
typename R::Scalar  precision = std::numeric_limits<typename R::Scalar>::epsilon() 
)
inlinestatic

Checks if a given matrix is orthonormal.

Returns
true if the matrix is orthonormal, false otherwise

A matrix is orthonormal if all of it's column's are mutually orthogonal and all of it's column's has unit length.

that is for any \( i, j \) the following holds \( col_i . col_j = 0 \) and \( ||col_i|| = 1 \)

Another nessesary and sufficient condition of orthonormal matrices is that \( \mathbf{M}\mathbf{M}^T=I \)

◆ isProperOrthonormal()

static bool isProperOrthonormal ( const Eigen::MatrixBase< R > &  r,
typename R::Scalar  precision = std::numeric_limits<typename R::Scalar>::epsilon() 
)
inlinestatic

Checks if a given matrix is proper orthonormal.

Returns
true if the matrix is proper orthonormal, false otherwise

A matrix is proper orthonormal if it is orthonormal and its determinant is equal to \( +1 \)

◆ isSkewSymmetric()

static bool isSkewSymmetric ( const Eigen::MatrixBase< R > &  M)
inlinestatic

Checks if a given matrix is skew-symmetrical.

Parameters
M[in] \( \mathbf{M} \) the matrix to check
Returns
true if the property \( \mathbf{M}=-\mathbf{M}^T \) holds, false otherwise.

◆ isSO() [1/2]

static bool isSO ( const Eigen::MatrixBase< R > &  M)
inlinestatic

Checks if a given matrix is in SO(n) (special orthogonal)

Parameters
M[in] \( \mathbf{M} \)
Returns
true if \( M\in SO(n) \)

\( SO(n) = {\mathbf{R}\in \mathbb{R}^{n\times n} : \mathbf{R}\mathbf{R}^T=\mathbf{I}, det \mathbf{R}=+1} \)

◆ isSO() [2/2]

static bool isSO ( const Eigen::MatrixBase< R > &  M,
typename R::Scalar  precision 
)
inlinestatic

Checks if a given matrix is in SO(n) (special orthogonal)

Parameters
M[in] \( \mathbf{M} \)
precision[in] the precision to use for floating point comparison
Returns
true if \( M\in SO(n) \)

\( SO(n) = {\mathbf{R}\in \mathbb{R}^{n\times n} : \mathbf{R}\mathbf{R}^T=\mathbf{I}, det \mathbf{R}=+1} \)

◆ pseudoInverse()

static Eigen::Matrix<double, -1, -1> pseudoInverse ( const Eigen::Matrix< double, -1, -1 > &  am,
double  precision = 1e-6 
)
static

Calculates the moore-penrose (pseudo) inverse of a matrix \( \mathbf{M}^+\).

Parameters
am[in] the matrix \( \mathbf{M} \) to be inverted
precision[in] the precision to use, values below this treshold are considered singular
Returns
the pseudo-inverse \( \mathbf{M}^+\) of \( \mathbf{M} \)

\( \mathbf{M}^+=\mathbf{V}\mathbf{\Sigma} ^+\mathbf{U}^T \) where \( \mathbf{V} \), \( \mathbf{\Sigma} \) and \( \mathbf{U} \) are optained using Singular Value Decomposition (SVD)

◆ svd()

static void svd ( const Eigen::Matrix< double, -1, -1 > &  M,
Eigen::Matrix< double, -1, -1 > &  U,
Eigen::Matrix< double, -1, 1 > &  sigma,
Eigen::Matrix< double, -1, -1 > &  V 
)
static

Performs a singular value decomposition (SVD)

The SVD computes the decomposition \( \mathbf{M}=\mathbf{U}*\mathbf{DiagonalMatrix(\sigma)}*\mathbf{V}^T \) .

Parameters
M[in] the matrix to decomposite
U[out] Result matrix \(\mathbf{U}\)
sigma[out] The \(\mathbf{sigma}\) vector with diagonal elements
V[out] Result matrix \(\mathbf{V}\)

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