cisst-saw
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Classes | Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | Friends | List of all members
nmrPInverseDynamicData Class Reference

#include <nmrPInverse.h>

Classes

class  Friend
 

Public Types

typedef vct::size_type size_type
 

Public Member Functions

 nmrPInverseDynamicData ()
 
template<class _matrixOwnerTypeA >
 nmrPInverseDynamicData (vctDynamicMatrixBase< _matrixOwnerTypeA, CISSTNETLIB_DOUBLE > &A)
 
template<class _matrixOwnerTypeA , class _vectorOwnerTypeWorkspace >
 nmrPInverseDynamicData (vctDynamicMatrixBase< _matrixOwnerTypeA, CISSTNETLIB_DOUBLE > &A, vctDynamicVectorBase< _vectorOwnerTypeWorkspace, CISSTNETLIB_DOUBLE > &workspace)
 
template<class _matrixOwnerTypeA , class _matrixOwnerTypePInverse , class _vectorOwnerTypeWorkspace >
 nmrPInverseDynamicData (vctDynamicMatrixBase< _matrixOwnerTypeA, CISSTNETLIB_DOUBLE > &CMN_UNUSED(A), vctDynamicMatrixBase< _matrixOwnerTypePInverse, CISSTNETLIB_DOUBLE > &pInverse, vctDynamicVectorBase< _vectorOwnerTypeWorkspace, CISSTNETLIB_DOUBLE > &workspace)
 
template<class _matrixOwnerTypeA , class _matrixOwnerTypePInverse >
 nmrPInverseDynamicData (vctDynamicMatrixBase< _matrixOwnerTypeA, CISSTNETLIB_DOUBLE > &CMN_UNUSED(A), vctDynamicMatrixBase< _matrixOwnerTypePInverse, CISSTNETLIB_DOUBLE > &pInverse)
 
template<class _matrixOwnerTypeA >
void Allocate (vctDynamicMatrixBase< _matrixOwnerTypeA, CISSTNETLIB_DOUBLE > &A)
 
template<class _matrixOwnerTypeA , class _vectorOwnerTypeWorkspace >
void SetRefWorkspace (vctDynamicMatrixBase< _matrixOwnerTypeA, CISSTNETLIB_DOUBLE > &A, vctDynamicVectorBase< _vectorOwnerTypeWorkspace, CISSTNETLIB_DOUBLE > &workspace)
 
template<class _matrixOwnerTypePInverse , class _vectorOwnerTypeWorkspace >
void SetRef (vctDynamicMatrixBase< _matrixOwnerTypePInverse, CISSTNETLIB_DOUBLE > &pInverse, vctDynamicVectorBase< _vectorOwnerTypeWorkspace, CISSTNETLIB_DOUBLE > &workspace)
 
template<class _matrixOwnerTypePInverse >
void SetRefOutput (vctDynamicMatrixBase< _matrixOwnerTypePInverse, CISSTNETLIB_DOUBLE > &pInverse)
 
Retrieving results

In order to get access to U, V^t and S, after the have been computed by calling nmrPInverse function, use the following methods.

const vctDynamicVectorRef
< CISSTNETLIB_DOUBLE > & 
S (void) const
 
const vctDynamicMatrixRef
< CISSTNETLIB_DOUBLE > & 
U (void) const
 
const vctDynamicMatrixRef
< CISSTNETLIB_DOUBLE > & 
Vt (void) const
 
const vctDynamicMatrixRef
< CISSTNETLIB_DOUBLE > & 
PInverse (void) const
 

Static Public Member Functions

static size_type WorkspaceSize (size_type m, size_type n)
 
template<class _matrixOwnerTypeA >
static size_type WorkspaceSize (vctDynamicMatrixBase< _matrixOwnerTypeA, CISSTNETLIB_DOUBLE > &A)
 

Protected Member Functions

void SetDimension (size_type m, size_type n, bool storageOrder)
 
void AllocateOutputWorkspace (bool allocateOutput, bool allocateWorkspace)
 
template<class _vectorOwnerTypeWorkspace >
void SetRefSVD (vctDynamicVectorBase< _vectorOwnerTypeWorkspace, CISSTNETLIB_DOUBLE > &workspace)
 
template<typename _matrixOwnerTypePInverse >
void ThrowUnlessOutputSizeIsCorrect (vctDynamicMatrixBase< _matrixOwnerTypePInverse, CISSTNETLIB_DOUBLE > &pInverse) const throw (std::runtime_error)
 
template<typename _vectorOwnerTypeWorkspace >
void ThrowUnlessWorkspaceSizeIsCorrect (vctDynamicVectorBase< _vectorOwnerTypeWorkspace, CISSTNETLIB_DOUBLE > &workspace) const throw (std::runtime_error)
 

Protected Attributes

vctDynamicVector
< CISSTNETLIB_DOUBLE > 
WorkspaceMemory
 
vctDynamicVector
< CISSTNETLIB_DOUBLE > 
OutputMemory
 
vctDynamicMatrixRef
< CISSTNETLIB_DOUBLE > 
PInverseReference
 
vctDynamicMatrixRef
< CISSTNETLIB_DOUBLE > 
UReference
 
vctDynamicMatrixRef
< CISSTNETLIB_DOUBLE > 
VtReference
 
vctDynamicVectorRef
< CISSTNETLIB_DOUBLE > 
SReference
 
vctDynamicVectorRef
< CISSTNETLIB_DOUBLE > 
WorkspaceReference
 
size_type MMember
 
size_type NMember
 
bool StorageOrderMember
 

Friends

class Friend
 

Detailed Description

This is the class for the composite data container of PInverse.

Member Typedef Documentation

Type used for sizes within nmrSVDDynamicData. This type is compatible with the cisstVector containers such as vctDynamicMatrix and vctDynamicVector (unsigned int). To call the Fortran based routines, these values must be cast to #CISSTNETLIB_INTEGER.

Constructor & Destructor Documentation

nmrPInverseDynamicData::nmrPInverseDynamicData ( )
inline

The default constuctor. For dynamic size, there are assigned default values, which MUST be changed by calling appropriate methods. (See nmrPInverseDynamicData::Allocate and nmrPInverseDynamicData::SetRef)

template<class _matrixOwnerTypeA >
nmrPInverseDynamicData::nmrPInverseDynamicData ( vctDynamicMatrixBase< _matrixOwnerTypeA, CISSTNETLIB_DOUBLE > &  A)
inline

Constructor where user provides the input matrix to specify size, Memory allocation is done for output matrices and vectors as well as Workspace used by LAPACK. This case covers the scenario when user wants to make all system calls for memory allocation before entrying time critical code sections.

Parameters
Ainput matrix
template<class _matrixOwnerTypeA , class _vectorOwnerTypeWorkspace >
nmrPInverseDynamicData::nmrPInverseDynamicData ( vctDynamicMatrixBase< _matrixOwnerTypeA, CISSTNETLIB_DOUBLE > &  A,
vctDynamicVectorBase< _vectorOwnerTypeWorkspace, CISSTNETLIB_DOUBLE > &  workspace 
)
inline

Constructor where user provides the input matrix to specify size, Memory allocation is done for output matrices and vectors. This case covers the scenario when user wants to make all system calls for memory allocation before entrying time critical code sections and might be using more than one numerical method in the same thread, allowing her to share the workspace for LAPACK.

Parameters
AInput matrix
workspaceWorkspace for SVD
template<class _matrixOwnerTypeA , class _matrixOwnerTypePInverse , class _vectorOwnerTypeWorkspace >
nmrPInverseDynamicData::nmrPInverseDynamicData ( vctDynamicMatrixBase< _matrixOwnerTypeA, CISSTNETLIB_DOUBLE > &  CMN_UNUSEDA,
vctDynamicMatrixBase< _matrixOwnerTypePInverse, CISSTNETLIB_DOUBLE > &  pInverse,
vctDynamicVectorBase< _vectorOwnerTypeWorkspace, CISSTNETLIB_DOUBLE > &  workspace 
)
inline

Constructor where user provides the size and storage order of the input matrix, along with matrix AP and workspace. The data object now acts as a composite container to hold, pass and manipulate a convenitent storage for PInverse algorithm. Checks are made on the validity of the input and its consitency with the size of input matrix.

Parameters
AThe input matrix
pInverseThe output matrix for PInverse
workspaceThe workspace for LAPACK.
template<class _matrixOwnerTypeA , class _matrixOwnerTypePInverse >
nmrPInverseDynamicData::nmrPInverseDynamicData ( vctDynamicMatrixBase< _matrixOwnerTypeA, CISSTNETLIB_DOUBLE > &  CMN_UNUSEDA,
vctDynamicMatrixBase< _matrixOwnerTypePInverse, CISSTNETLIB_DOUBLE > &  pInverse 
)
inline

Constructor where user provides the size and storage order of the input matrix, along with matrix PInverse. The data object now acts as a composite container to hold, pass and manipulate a convenitent storage for SVD algorithm. Checks are made on thec validity of the input and its consitency with the size of input matrix. Memory allocation for workspace is done by the method. This case covers the scenario when user wants to make all system calls for memory allocation before entrying time critical code sections and might be using the PInverse matrix elsewhere in the same thread.

Parameters
AThe input matrix
pInverseThe output matrix for PInverse

Member Function Documentation

template<class _matrixOwnerTypeA >
void nmrPInverseDynamicData::Allocate ( vctDynamicMatrixBase< _matrixOwnerTypeA, CISSTNETLIB_DOUBLE > &  A)
inline

This method allocates memory of output matrices and vector as well as the workspace. This method should be called before the nmrPInverseDynamicData object is passed on to nmrPInverse function, as the memory required for output matrices and workspace are allocated here or to reallocate memory previously allocated by constructor. Typically this method is called from a code segment where it is safe to allocate memory and use the data and workspace space later.

Parameters
AThe matrix for which SVD needs to be computed, size MxN
void nmrPInverseDynamicData::AllocateOutputWorkspace ( bool  allocateOutput,
bool  allocateWorkspace 
)
inlineprotected

Private method to allocate memory for the output and the workspace if needed. This method assumes that the dimension m and n as well as the storage order are already set. It is important to use this method in all the methods provided in the user API, even if all the memory is provided by the user since this method will ensure that the data (nmrPInverseDynamicData) does not keep any memory allocated. This is for the case where a single data is used first to allocate everything and, later on, used with user allocated memory (for either the workspace or the output).

Note
The method SetDimension must have been called before.
const vctDynamicMatrixRef<CISSTNETLIB_DOUBLE>& nmrPInverseDynamicData::PInverse ( void  ) const
inline
const vctDynamicVectorRef<CISSTNETLIB_DOUBLE>& nmrPInverseDynamicData::S ( void  ) const
inline
void nmrPInverseDynamicData::SetDimension ( size_type  m,
size_type  n,
bool  storageOrder 
)
inlineprotected

Private method to set the data members MMember, NMember and StorageOrder. This method must be called before AllocateOutputWorkspace, ThrowUnlessOutputSizeIsCorrect or ThrowUnlessWorkspaceSizeIsCorrect.

template<class _matrixOwnerTypePInverse , class _vectorOwnerTypeWorkspace >
void nmrPInverseDynamicData::SetRef ( vctDynamicMatrixBase< _matrixOwnerTypePInverse, CISSTNETLIB_DOUBLE > &  pInverse,
vctDynamicVectorBase< _vectorOwnerTypeWorkspace, CISSTNETLIB_DOUBLE > &  workspace 
)
inline

This method must be called before the data object is passed to nmrPInverse function. The user provides the input matrix to specify size, along with matrix PInverse and workspace. The data object now acts as a composite container to hold, pass and manipulate a convenitent storage for PInverse algorithm. Checks are made on the validity of the input and its consitency with the size of input matrix.

Parameters
pInverseThe output matrix for PInverse
workspaceThe workspace for LAPACK.
template<class _matrixOwnerTypePInverse >
void nmrPInverseDynamicData::SetRefOutput ( vctDynamicMatrixBase< _matrixOwnerTypePInverse, CISSTNETLIB_DOUBLE > &  pInverse)
inline

This method must be called before the data object is passed to nmrPInverse function. The user provides the input matrix to specify size, along with matrix PInverse. The data object now acts as a composite container to hold, pass and manipulate a convenitent storage for PInverse algorithm. Checks are made on thec validity of the input and its consitency with the size of input matrix. Memory allocation for workspace is done by the method. This case covers the scenario when user wants to make all system calls for memory allocation before entrying time critical code sections and might be using the PInverse matrix elsewhere in the same thread.

Parameters
pInverseThe output matrix for PInverse
template<class _vectorOwnerTypeWorkspace >
void nmrPInverseDynamicData::SetRefSVD ( vctDynamicVectorBase< _vectorOwnerTypeWorkspace, CISSTNETLIB_DOUBLE > &  workspace)
inlineprotected

Set all internal references used for the SVD problem. This method requires a valid workspace but it doesn't check the size. It is the caller responsability to do so.

Note
The method SetDimension must have been called before.
template<class _matrixOwnerTypeA , class _vectorOwnerTypeWorkspace >
void nmrPInverseDynamicData::SetRefWorkspace ( vctDynamicMatrixBase< _matrixOwnerTypeA, CISSTNETLIB_DOUBLE > &  A,
vctDynamicVectorBase< _vectorOwnerTypeWorkspace, CISSTNETLIB_DOUBLE > &  workspace 
)
inline

This method allocates memory of output matrices and vector and uses the memory provided by user for workspace. Check is made to ensure that memory provided by user is sufficient for SVD routine of LAPACK. This method should be called before the nmrPInverseDynamicData object is passed on to nmrPInverse function, as the memory required for output matrices and workspace are allocated here or to reallocate memory previously allocated by constructor. This case covers the scenario when user wants to make all system calls for memory allocation before entrying time critical code sections and might be using more than one numerical method in the same thread, allowing her to share the workspace for LAPACK. Typically this method is called from a code segment where it is safe to allocate memory and use the data and workspace space later.

Parameters
AThe matrix for which SVD needs to be computed, size MxN
workspaceThe vector used for workspace by LAPACK.
template<typename _matrixOwnerTypePInverse >
void nmrPInverseDynamicData::ThrowUnlessOutputSizeIsCorrect ( vctDynamicMatrixBase< _matrixOwnerTypePInverse, CISSTNETLIB_DOUBLE > &  pInverse) const
throw (std::runtime_error
)
inlineprotected

Verifies that the user provided reference for the output match the size of the data as set by SetDimension. This method also checks that the storage order is consistent.

Note
The method SetDimension must have been called before.
template<typename _vectorOwnerTypeWorkspace >
void nmrPInverseDynamicData::ThrowUnlessWorkspaceSizeIsCorrect ( vctDynamicVectorBase< _vectorOwnerTypeWorkspace, CISSTNETLIB_DOUBLE > &  workspace) const
throw (std::runtime_error
)
inlineprotected

Verifies that the user provided references for the workspace match (or is greated than) the size of the data as set by SetDimension. This method also checks that the workspace is compact.

Note
The method SetDimension must have been called before.
const vctDynamicMatrixRef<CISSTNETLIB_DOUBLE>& nmrPInverseDynamicData::U ( void  ) const
inline
const vctDynamicMatrixRef<CISSTNETLIB_DOUBLE>& nmrPInverseDynamicData::Vt ( void  ) const
inline
static size_type nmrPInverseDynamicData::WorkspaceSize ( size_type  m,
size_type  n 
)
inlinestatic

Helper methods for user to set min working space required by LAPACK SVD routine plus memory needed for S, U & Vt matrices used to compute PInverse.

Parameters
m,nThe size of matrix whose SVD needs to be computed
template<class _matrixOwnerTypeA >
static size_type nmrPInverseDynamicData::WorkspaceSize ( vctDynamicMatrixBase< _matrixOwnerTypeA, CISSTNETLIB_DOUBLE > &  A)
inlinestatic

Helper method to determine the min working space required by LAPACK SVD routine plus memory needed for S, U & Vt matrices used to compute PInverse.

Parameters
AThe matrix whose SVD needs to be computed

Friends And Related Function Documentation

friend class Friend
friend

Member Data Documentation

size_type nmrPInverseDynamicData::MMember
protected

Stores M, N, and StorageOrder which are needed to check if A matrix passed to solve method matches the allocated size.

size_type nmrPInverseDynamicData::NMember
protected
vctDynamicVector<CISSTNETLIB_DOUBLE> nmrPInverseDynamicData::OutputMemory
protected

Memory allocated for PInverse if needed.

vctDynamicMatrixRef<CISSTNETLIB_DOUBLE> nmrPInverseDynamicData::PInverseReference
protected

References to workspace or return types, these point either to user allocated memory or our memory chunks if needed

vctDynamicVectorRef<CISSTNETLIB_DOUBLE> nmrPInverseDynamicData::SReference
protected
bool nmrPInverseDynamicData::StorageOrderMember
protected
vctDynamicMatrixRef<CISSTNETLIB_DOUBLE> nmrPInverseDynamicData::UReference
protected
vctDynamicMatrixRef<CISSTNETLIB_DOUBLE> nmrPInverseDynamicData::VtReference
protected
vctDynamicVector<CISSTNETLIB_DOUBLE> nmrPInverseDynamicData::WorkspaceMemory
protected

Memory allocated for Workspace matrices if needed This includes memory needed for SVD as well. Order of storage is m x m elements of U followed by n x n elements of Vt followed by min (m, n) elements of S, followed by memory for LAPACK workspace.

vctDynamicVectorRef<CISSTNETLIB_DOUBLE> nmrPInverseDynamicData::WorkspaceReference
protected

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