SLAMflex SE  0.1.0
SLAMflex provides detection and tracking of dominant planes for smartphone devices. This plane can then be used to show AR content relative to the plane orientation. The detection of plane is performed in the field of view of the smartphone camera. In subsequent frames it is tracked. The interface returns the plane position and orientation.
Public Member Functions | Private Member Functions | Private Attributes | Static Private Attributes | List of all members
TooN::SVD< Rows, Cols, Precision > Class Template Reference

#include <SVD.h>

Public Member Functions

 SVD ()
 default constructor for Rows>0 and Cols>0 More...
 
 SVD (int rows, int cols)
 constructor for Rows=-1 or Cols=-1 (or both) More...
 
template<int R2, int C2, typename P2 , typename B2 >
 SVD (const Matrix< R2, C2, P2, B2 > &m)
 
template<int R2, int C2, typename P2 , typename B2 >
void compute (const Matrix< R2, C2, P2, B2 > &m)
 Compute the SVD decomposition of M, typically used after the default constructor. More...
 
template<int Rows2, int Cols2, typename P2 , typename B2 >
Matrix< Cols, Cols2, typename Internal::MultiplyType< Precision, P2 >::type > backsub (const Matrix< Rows2, Cols2, P2, B2 > &rhs, const Precision condition=condition_no)
 
template<int Size, typename P2 , typename B2 >
Vector< Cols, typename Internal::MultiplyType< Precision, P2 >::type > backsub (const Vector< Size, P2, B2 > &rhs, const Precision condition=condition_no)
 
Matrix< Cols, Rows > get_pinv (const Precision condition=condition_no)
 
Precision determinant ()
 
int rank (const Precision condition=condition_no)
 
Matrix< Rows, Min_Dim, Precision, Reference::RowMajorget_U ()
 
Vector< Min_Dim, Precision > & get_diagonal ()
 Return the singular values as a vector. More...
 
Matrix< Min_Dim, Cols, Precision, Reference::RowMajorget_VT ()
 
void get_inv_diag (Vector< Min_Dim > &inv_diag, const Precision condition)
 

Private Member Functions

void do_compute ()
 
bool is_vertical ()
 
int min_dim ()
 

Private Attributes

Matrix< Rows, Cols, Precision, RowMajormy_copy
 
Vector< Min_Dim, Precision > my_diagonal
 
Matrix< Min_Dim, Min_Dim, Precision, RowMajormy_square
 

Static Private Attributes

static const int Min_Dim = Rows<Cols?Rows:Cols
 

Detailed Description

template<int Rows = Dynamic, int Cols = Rows, typename Precision = DefaultPrecision>
class TooN::SVD< Rows, Cols, Precision >

Performs SVD and back substitute to solve equations. Singular value decompositions are more robust than LU decompositions in the face of singular or nearly singular matrices. They decompose a matrix (of any shape) $M$ into:

\[M = U \times D \times V^T\]

where $D$ is a diagonal matrix of positive numbers whose dimension is the minimum of the dimensions of $M$. If $M$ is tall and thin (more rows than columns) then $U$ has the same shape as $M$ and $V$ is square (vice-versa if $M$ is short and fat). The columns of $U$ and the rows of $V$ are orthogonal and of unit norm (so one of them lies in SO(N)). The inverse of $M$ (or pseudo-inverse if $M$ is not square) is then given by

\[M^{\dagger} = V \times D^{-1} \times U^T\]

If $M$ is nearly singular then the diagonal matrix $D$ has some small values (relative to its largest value) and these terms dominate $D^{-1}$. To deal with this problem, the inverse is conditioned by setting a maximum ratio between the largest and smallest values in $D$ (passed as the condition parameter to the various functions). Any values which are too small are set to zero in the inverse (rather than a large number)

It can be used as follows to solve the $M\underline{x} = \underline{c}$ problem as follows:

// construct M
Matrix<3> M;
M[0] = makeVector(1,2,3);
M[1] = makeVector(4,5,6);
M[2] = makeVector(7,8.10);
// construct c
Vector<3> c;
c = 2,3,4;
// create the SVD decomposition of M
SVD<3> svdM(M);
// compute x = M^-1 * c
Vector<3> x = svdM.backsub(c);

SVD<> (= SVD<-1>) can be used to create an SVD whose size is determined at run-time.

Definition at line 89 of file SVD.h.

Constructor & Destructor Documentation

template<int Rows = Dynamic, int Cols = Rows, typename Precision = DefaultPrecision>
TooN::SVD< Rows, Cols, Precision >::SVD ( )
inline

default constructor for Rows>0 and Cols>0

Definition at line 97 of file SVD.h.

template<int Rows = Dynamic, int Cols = Rows, typename Precision = DefaultPrecision>
TooN::SVD< Rows, Cols, Precision >::SVD ( int  rows,
int  cols 
)
inline

constructor for Rows=-1 or Cols=-1 (or both)

Definition at line 100 of file SVD.h.

template<int Rows = Dynamic, int Cols = Rows, typename Precision = DefaultPrecision>
template<int R2, int C2, typename P2 , typename B2 >
TooN::SVD< Rows, Cols, Precision >::SVD ( const Matrix< R2, C2, P2, B2 > &  m)
inline

Construct the SVD decomposition of a matrix. This initialises the class, and performs the decomposition immediately.

Definition at line 109 of file SVD.h.

Member Function Documentation

template<int Rows = Dynamic, int Cols = Rows, typename Precision = DefaultPrecision>
template<int Rows2, int Cols2, typename P2 , typename B2 >
Matrix<Cols,Cols2, typename Internal::MultiplyType<Precision,P2>::type > TooN::SVD< Rows, Cols, Precision >::backsub ( const Matrix< Rows2, Cols2, P2, B2 > &  rhs,
const Precision  condition = condition_no 
)
inline

Calculate result of multiplying the (pseudo-)inverse of M by another matrix. For a matrix $A$, this calculates $M^{\dagger}A$ by back substitution (i.e. without explictly calculating the (pseudo-)inverse). See the detailed description for a description of condition variables.

Definition at line 182 of file SVD.h.

template<int Rows = Dynamic, int Cols = Rows, typename Precision = DefaultPrecision>
template<int Size, typename P2 , typename B2 >
Vector<Cols, typename Internal::MultiplyType<Precision,P2>::type > TooN::SVD< Rows, Cols, Precision >::backsub ( const Vector< Size, P2, B2 > &  rhs,
const Precision  condition = condition_no 
)
inline

Calculate result of multiplying the (pseudo-)inverse of M by a vector. For a vector $b$, this calculates $M^{\dagger}b$ by back substitution (i.e. without explictly calculating the (pseudo-)inverse). See the detailed description for a description of condition variables.

Definition at line 195 of file SVD.h.

template<int Rows = Dynamic, int Cols = Rows, typename Precision = DefaultPrecision>
template<int R2, int C2, typename P2 , typename B2 >
void TooN::SVD< Rows, Cols, Precision >::compute ( const Matrix< R2, C2, P2, B2 > &  m)
inline

Compute the SVD decomposition of M, typically used after the default constructor.

Definition at line 119 of file SVD.h.

template<int Rows = Dynamic, int Cols = Rows, typename Precision = DefaultPrecision>
Precision TooN::SVD< Rows, Cols, Precision >::determinant ( )
inline

Calculate the product of the singular values for square matrices this is the determinant

Definition at line 214 of file SVD.h.

template<int Rows = Dynamic, int Cols = Rows, typename Precision = DefaultPrecision>
void TooN::SVD< Rows, Cols, Precision >::do_compute ( )
inlineprivate

Definition at line 125 of file SVD.h.

template<int Rows = Dynamic, int Cols = Rows, typename Precision = DefaultPrecision>
Vector<Min_Dim,Precision>& TooN::SVD< Rows, Cols, Precision >::get_diagonal ( )
inline

Return the singular values as a vector.

Definition at line 249 of file SVD.h.

template<int Rows = Dynamic, int Cols = Rows, typename Precision = DefaultPrecision>
void TooN::SVD< Rows, Cols, Precision >::get_inv_diag ( Vector< Min_Dim > &  inv_diag,
const Precision  condition 
)
inline

Return the pesudo-inverse diagonal. The reciprocal of the diagonal elements is returned if the elements are well scaled with respect to the largest element, otherwise 0 is returned.

Parameters
inv_diagVector in which to return the inverse diagonal.
conditionElements must be larger than this factor times the largest diagonal element to be considered well scaled.

Definition at line 269 of file SVD.h.

template<int Rows = Dynamic, int Cols = Rows, typename Precision = DefaultPrecision>
Matrix<Cols,Rows> TooN::SVD< Rows, Cols, Precision >::get_pinv ( const Precision  condition = condition_no)
inline

Calculate (pseudo-)inverse of the matrix. This is not usually needed: if you need the inverse just to multiply it by a matrix or a vector, use one of the backsub() functions, which will be faster. See the detailed description of the pseudo-inverse and condition variables.

Definition at line 206 of file SVD.h.

template<int Rows = Dynamic, int Cols = Rows, typename Precision = DefaultPrecision>
Matrix<Rows,Min_Dim,Precision,Reference::RowMajor> TooN::SVD< Rows, Cols, Precision >::get_U ( )
inline

Return the U matrix from the decomposition The size of this depends on the shape of the original matrix it is square if the original matrix is wide or tall if the original matrix is tall

Definition at line 238 of file SVD.h.

template<int Rows = Dynamic, int Cols = Rows, typename Precision = DefaultPrecision>
Matrix<Min_Dim,Cols,Precision,Reference::RowMajor> TooN::SVD< Rows, Cols, Precision >::get_VT ( )
inline

Return the VT matrix from the decomposition The size of this depends on the shape of the original matrix it is square if the original matrix is tall or wide if the original matrix is wide

Definition at line 254 of file SVD.h.

template<int Rows = Dynamic, int Cols = Rows, typename Precision = DefaultPrecision>
bool TooN::SVD< Rows, Cols, Precision >::is_vertical ( )
inlineprivate

Definition at line 168 of file SVD.h.

template<int Rows = Dynamic, int Cols = Rows, typename Precision = DefaultPrecision>
int TooN::SVD< Rows, Cols, Precision >::min_dim ( )
inlineprivate

Definition at line 172 of file SVD.h.

template<int Rows = Dynamic, int Cols = Rows, typename Precision = DefaultPrecision>
int TooN::SVD< Rows, Cols, Precision >::rank ( const Precision  condition = condition_no)
inline

Calculate the rank of the matrix. See the detailed description of the pseudo-inverse and condition variables.

Definition at line 224 of file SVD.h.

Member Data Documentation

template<int Rows = Dynamic, int Cols = Rows, typename Precision = DefaultPrecision>
const int TooN::SVD< Rows, Cols, Precision >::Min_Dim = Rows<Cols?Rows:Cols
staticprivate

Definition at line 92 of file SVD.h.

template<int Rows = Dynamic, int Cols = Rows, typename Precision = DefaultPrecision>
Matrix<Rows,Cols,Precision,RowMajor> TooN::SVD< Rows, Cols, Precision >::my_copy
private

Definition at line 280 of file SVD.h.

template<int Rows = Dynamic, int Cols = Rows, typename Precision = DefaultPrecision>
Vector<Min_Dim,Precision> TooN::SVD< Rows, Cols, Precision >::my_diagonal
private

Definition at line 281 of file SVD.h.

template<int Rows = Dynamic, int Cols = Rows, typename Precision = DefaultPrecision>
Matrix<Min_Dim,Min_Dim,Precision,RowMajor> TooN::SVD< Rows, Cols, Precision >::my_square
private

Definition at line 282 of file SVD.h.


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