cisst-saw
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Classes
nmrIsOrthonormal.h File Reference

Declaration of functions nmrIsOrthonormal. More...

#include <cisstVector/vctFixedSizeMatrix.h>
#include <cisstVector/vctDynamicMatrix.h>

Go to the source code of this file.

Classes

class  nmrIsOrthonormalDynamicData< _elementType >
 Data (workspace) for nmrIsOrthonormal (Dynamic). More...
 
class  nmrIsOrthonormalDynamicData< _elementType >::Friend
 
class  nmrIsOrthonormalFixedSizeData< _elementType, _rows >
 Data for nmrIsOrthonormal (Fixed size). More...
 
class  nmrIsOrthonormalFixedSizeData< _elementType, _rows >::Friend
 

Functions

nmrIsOrthonormal: Check if a matrix is orthonormal

This function computes the product of the matrix with its transpose then subtracts the identity and verifies that all elements are null within some tolerance.

This function is overloaded to be used with either a fixed size or a dynamic matrix (see vctFixedSizeMatrix and vctDynamicMatrix). Furthermore, it is possible to provide a workspace to store the product of the matrix and its transpose and avoid any undesired memory allocation:

  1. The workspace can be provided using the dedicated classes nmrIsOrthonormalDynamicData and nmrIsOrthonormalFixedSizeData. The user has to create the data based on the matrix to be tested and then pass it to nmrIsOrthonormal:

    int i; bool result;
    for (i = 0; i < 100; i++) {
    vctRandom(A, -10.0, 10.0);
    result = nmrIsOrthonormal(A, data);
    ...
    }

  2. The workspace can be provided as a dynamic vector (vctDynamicVector) large enough to store the product of the matrix with its transpose:

    vctRandom(A, -10.0, 10.0);
    vctDynamicVector<double> workspace(500); // we need at least 12x12
    bool result = nmrIsOrthonormal(A, workspace);

  3. If no workspace is provided the nmrIsOrthonormal function will allocate one for you. This might be more convenient for most users but one must be aware that a memory allocation has to be performed (stack allocation for fixed size matrices, dynamic allocation for dynamic matrices):
    vctRandom(A, -10.0, 10.0);
    bool result = nmrIsOrthonormal(A);
Note
For a dynamic matrix, the function will throw an exception is the matrix is not square (std::runtime_error).
The workspace needs to be compact and large enough otherwise nmrIsOrthonormal will throw an exception (std::runtime_error).
See Also
nmrIsOrthonormalDynamicData nmrIsOrthonormalFixedSizeData
template<vct::size_type _size, vct::stride_type _rowStride, vct::stride_type _colStride, typename _elementType , class _dataPtrType >
bool nmrIsOrthonormal (const vctFixedSizeConstMatrixBase< _size, _size, _rowStride, _colStride, _elementType, _dataPtrType > &A, nmrIsOrthonormalFixedSizeData< _elementType, _size > &data, _elementType tolerance=cmnTypeTraits< _elementType >::Tolerance())
 
template<vct::size_type _size, vct::stride_type _rowStride, vct::stride_type _colStride, typename _elementType , class _dataPtrType >
bool nmrIsOrthonormal (const vctFixedSizeConstMatrixBase< _size, _size, _rowStride, _colStride, _elementType, _dataPtrType > &A, _elementType tolerance=cmnTypeTraits< _elementType >::Tolerance())
 
template<class _matrixOwnerTypeA , class _elementType >
bool nmrIsOrthonormal (const vctDynamicConstMatrixBase< _matrixOwnerTypeA, _elementType > &A, nmrIsOrthonormalDynamicData< _elementType > &data, _elementType tolerance=cmnTypeTraits< _elementType >::Tolerance()) throw (std::runtime_error)
 
template<class _matrixOwnerTypeA , typename _elementType >
bool nmrIsOrthonormal (const vctDynamicConstMatrixBase< _matrixOwnerTypeA, _elementType > &A, _elementType tolerance=cmnTypeTraits< _elementType >::Tolerance()) throw (std::runtime_error)
 
template<class _matrixOwnerTypeA , class _vectorOwnerTypeWorkspace , typename _elementType >
bool nmrIsOrthonormal (const vctDynamicConstMatrixBase< _matrixOwnerTypeA, _elementType > &A, vctDynamicVectorBase< _vectorOwnerTypeWorkspace, _elementType > &workspace, _elementType tolerance=cmnTypeTraits< _elementType >::Tolerance()) throw (std::runtime_error)
 

Detailed Description

Declaration of functions nmrIsOrthonormal.

Function Documentation

template<vct::size_type _size, vct::stride_type _rowStride, vct::stride_type _colStride, typename _elementType , class _dataPtrType >
bool nmrIsOrthonormal ( const vctFixedSizeConstMatrixBase< _size, _size, _rowStride, _colStride, _elementType, _dataPtrType > &  A,
nmrIsOrthonormalFixedSizeData< _elementType, _size > &  data,
_elementType  tolerance = cmnTypeTraits<_elementType>::Tolerance() 
)

This function checks if a fixed size matrix is orthonormal. It uses a data (see nmrIsOrthonormalFixedSizeData) to store the temporary product of the matrix with its transpose.

Parameters
AA square fixed size matrix
dataWorkspace used to compute the product
toleranceTolerance used to compare the product with identity
template<vct::size_type _size, vct::stride_type _rowStride, vct::stride_type _colStride, typename _elementType , class _dataPtrType >
bool nmrIsOrthonormal ( const vctFixedSizeConstMatrixBase< _size, _size, _rowStride, _colStride, _elementType, _dataPtrType > &  A,
_elementType  tolerance = cmnTypeTraits<_elementType>::Tolerance() 
)

This function checks if a fixed size matrix is orthonormal. It creates a data on the stack to store the temporary product of the matrix with its transpose.

Parameters
AA square fixed size matrix
toleranceTolerance used to compare the product with identity
template<class _matrixOwnerTypeA , class _elementType >
bool nmrIsOrthonormal ( const vctDynamicConstMatrixBase< _matrixOwnerTypeA, _elementType > &  A,
nmrIsOrthonormalDynamicData< _elementType > &  data,
_elementType  tolerance = cmnTypeTraits<_elementType>::Tolerance() 
)
throw (std::runtime_error
)

This function checks if a dynamic matrix is orthonormal. It uses a data (see nmrIsOrthonormalDynamicData) to store the temporary product of the matrix with its transpose.

Parameters
AA square dynamic matrix
dataWorkspace used to compute the product
toleranceTolerance used to compare the product with identity
template<class _matrixOwnerTypeA , typename _elementType >
bool nmrIsOrthonormal ( const vctDynamicConstMatrixBase< _matrixOwnerTypeA, _elementType > &  A,
_elementType  tolerance = cmnTypeTraits<_elementType>::Tolerance() 
)
throw (std::runtime_error
)

This function checks if a dynamic matrix is orthonormal. It dynamically allocates a data to store the temporary product of the matrix with its transpose.

Parameters
AA square dynamic matrix
toleranceTolerance used to compare the product with identity
template<class _matrixOwnerTypeA , class _vectorOwnerTypeWorkspace , typename _elementType >
bool nmrIsOrthonormal ( const vctDynamicConstMatrixBase< _matrixOwnerTypeA, _elementType > &  A,
vctDynamicVectorBase< _vectorOwnerTypeWorkspace, _elementType > &  workspace,
_elementType  tolerance = cmnTypeTraits<_elementType>::Tolerance() 
)
throw (std::runtime_error
)

This function checks if a dynamic matrix is orthonormal. It uses a user allocated workspace to store the temporary product of the matrix with its transpose.

Parameters
AA square dynamic matrix
workspaceWorkspace used to compute the product
toleranceTolerance used to compare the product with identity