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
nmrInverseDynamicData Class Reference

Data for Inverse problem (Dynamic). More...

#include <nmrInverse.h>

Classes

class  Friend
 

Public Types

enum  { NB = 64 }
 
typedef vct::size_type size_type
 

Public Member Functions

 nmrInverseDynamicData ()
 
 nmrInverseDynamicData (size_type size, bool storageOrder)
 
template<class _matrixOwnerTypeA >
 nmrInverseDynamicData (vctDynamicMatrixBase< _matrixOwnerTypeA, CISSTNETLIB_DOUBLE > &A)
 
template<class _matrixOwnerTypeA , class _vectorOwnerTypePivotIndices , class _vectorOwnerTypeWorkspace >
 nmrInverseDynamicData (vctDynamicMatrixBase< _matrixOwnerTypeA, CISSTNETLIB_DOUBLE > &A, vctDynamicVectorBase< _vectorOwnerTypePivotIndices, CISSTNETLIB_INTEGER > &pivotIndices, vctDynamicVectorBase< _vectorOwnerTypeWorkspace, CISSTNETLIB_DOUBLE > &workspace)
 
template<class _matrixOwnerTypeA >
void Allocate (vctDynamicMatrixBase< _matrixOwnerTypeA, CISSTNETLIB_DOUBLE > &A)
 
void Allocate (size_type size, bool storageOrder)
 
template<class _matrixOwnerTypeA , class _vectorOwnerTypePivotIndices , class _vectorOwnerTypeWorkspace >
void SetRef (vctDynamicMatrixBase< _matrixOwnerTypeA, CISSTNETLIB_DOUBLE > &A, vctDynamicVectorBase< _vectorOwnerTypePivotIndices, CISSTNETLIB_INTEGER > &pivotIndices, vctDynamicVectorBase< _vectorOwnerTypeWorkspace, CISSTNETLIB_DOUBLE > &workspace) throw (std::runtime_error)
 

Static Public Member Functions

template<class _matrixOwnerTypeA >
static size_type PivotIndicesSize (const vctDynamicConstMatrixBase< _matrixOwnerTypeA, CISSTNETLIB_DOUBLE > &A)
 
template<class _matrixOwnerTypeA >
static size_type WorkspaceSize (const vctDynamicConstMatrixBase< _matrixOwnerTypeA, CISSTNETLIB_DOUBLE > &A)
 

Protected Member Functions

void SetDimension (size_type size, bool storageOrder)
 
void AllocatePivotIndicesWorkspace (bool allocatePivotIndices, bool allocateWorkspace)
 
template<class _vectorOwnerTypePivotIndices >
void ThrowUnlessPivotIndicesSizeIsCorrect (vctDynamicVectorBase< _vectorOwnerTypePivotIndices, CISSTNETLIB_INTEGER > &pivotIndices) throw (std::runtime_error)
 
template<class _vectorOwnerTypeWorkspace >
void ThrowUnlessWorkspaceSizeIsCorrect (vctDynamicVectorBase< _vectorOwnerTypeWorkspace, CISSTNETLIB_DOUBLE > &workspace) throw (std::runtime_error)
 

Protected Attributes

vctDynamicVector
< CISSTNETLIB_INTEGER > 
PivotIndicesMemory
 
vctDynamicVector
< CISSTNETLIB_DOUBLE > 
WorkspaceMemory
 
vctDynamicVectorRef
< CISSTNETLIB_INTEGER > 
PivotIndicesReference
 
vctDynamicVectorRef
< CISSTNETLIB_DOUBLE > 
WorkspaceReference
 
size_type SizeMember
 
bool StorageOrderMember
 

Friends

class Friend
 

Detailed Description

Data for Inverse problem (Dynamic).

To ease the use of the Inverse routine, the user can rely on the nmrInverseDynamicData class to perform the required memory allocation.

Another good reason to use a data object is that the memory allocation can be performed once during an initialization phase while the function nmrInverse can be called numerous times later on without any new dynamic memory allocation. This is crucial for such things as real time tasks.

The Inverse routine can be used for different storage orders, i.e. either VCT_ROW_MAJOR or VCT_COL_MAJOR. The only restriction is that all matrices and vectors must also be compact, i.e. use a contiguous block of memory.

Any size or storage order mismatch will lead to an exception thrown (std::runtime_error). Since we are using cmnThrow, it is possible to configure cisst (at compilation time) to abort the program instead of throwing an exception.

The nmrInverseDynamicData class allows 2 different configurations:

See Also
nmrInverse

Member Typedef Documentation

Type used for sizes within nmrInverseDynamicData. 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.

Member Enumeration Documentation

anonymous enum
Enumerator
NB 

Constructor & Destructor Documentation

nmrInverseDynamicData::nmrInverseDynamicData ( )
inline

The default constuctor. For dynamic size, there are assigned default values, i.e. sets all the dimensions to zero. These MUST be changed by calling the appropriate method.

See Also
nmrInverseDynamicData::Allocate nmrInverseDynamicData::SetRef
nmrInverseDynamicData::nmrInverseDynamicData ( size_type  size,
bool  storageOrder 
)
inline

Constructor where the user specifies the size. Memory allocation is performed for pivot indices vector and workspace. This should be used when the user doesn't care much about where the memory management.

Parameters
sizeDimension of the square matrix.
storageOrderStorage order of the matrix
See Also
nmrInverseDynamicData::Allocate
template<class _matrixOwnerTypeA >
nmrInverseDynamicData::nmrInverseDynamicData ( vctDynamicMatrixBase< _matrixOwnerTypeA, CISSTNETLIB_DOUBLE > &  A)
inline

Constructor where the user provides the input matrix to specify the size and storage order. Memory allocation is performed for pivot indices vector and workspace. This should be used when the user doesn't care much about memory management.

Parameters
Ainput matrix.
See Also
nmrInverseDynamicData::Allocate
template<class _matrixOwnerTypeA , class _vectorOwnerTypePivotIndices , class _vectorOwnerTypeWorkspace >
nmrInverseDynamicData::nmrInverseDynamicData ( vctDynamicMatrixBase< _matrixOwnerTypeA, CISSTNETLIB_DOUBLE > &  A,
vctDynamicVectorBase< _vectorOwnerTypePivotIndices, CISSTNETLIB_INTEGER > &  pivotIndices,
vctDynamicVectorBase< _vectorOwnerTypeWorkspace, CISSTNETLIB_DOUBLE > &  workspace 
)
inline

Constructor where the user provides the vector to store the pivot indices and the workspace. The data object now acts as a composite container to hold, pass and manipulate a convenient storage for nmrInverse algorithm. Checks are made on the validity of the input and its consitency in terms of size.

Parameters
AThe matrix to be inversed, used to verify the sizes.
pivotIndicesVector created by the user to store the pivot indices.
workspaceVector created by the user for the workspace.
See Also
nmrInverseDynamicData::SetRef

Member Function Documentation

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

This method allocates memory for the pivot indices vector and the workspace. The input matrix is used only to determine the size of these vectors.

This method should be called before the nmrInverseDynamicData object is passed on to the nmrInverse function.

Parameters
AThe square matrix for which inverse needs to be computed.
void nmrInverseDynamicData::Allocate ( size_type  size,
bool  storageOrder 
)
inline

This method allocates the memory for the pivot indices and the workspace. This method is not meant to be a top-level user API, but is used by other overloaded Allocate methods.

Parameters
sizeSize of the square input matrix A.
storageOrderStorage order of the input matrix.
void nmrInverseDynamicData::AllocatePivotIndicesWorkspace ( bool  allocatePivotIndices,
bool  allocateWorkspace 
)
inlineprotected

Private method to allocate memory for the the pivot indices 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 (nmrInverseDynamicData) does not keep any memory allocated. This is for the case where a single data object is used first to allocate everything and, later on, used with user allocated memory (for the output).

Note
The method SetDimension must have been called before.
template<class _matrixOwnerTypeA >
static size_type nmrInverseDynamicData::PivotIndicesSize ( const vctDynamicConstMatrixBase< _matrixOwnerTypeA, CISSTNETLIB_DOUBLE > &  A)
inlinestatic

Helper method to compute the size of the pivot indices vector.

Parameters
AThe matrix to be used by nmrInverse (it is used only to determine the size).
void nmrInverseDynamicData::SetDimension ( size_type  size,
bool  storageOrder 
)
inlineprotected

Private method to set the data members SizeMember and StorageOrderMember. This method must be called before AllocatePivotIndicesWorkspace, ThrowUnlessOutputSizeIsCorrect or ThrowUnlessWorkspaceSizeIsCorrect.

template<class _matrixOwnerTypeA , class _vectorOwnerTypePivotIndices , class _vectorOwnerTypeWorkspace >
void nmrInverseDynamicData::SetRef ( vctDynamicMatrixBase< _matrixOwnerTypeA, CISSTNETLIB_DOUBLE > &  A,
vctDynamicVectorBase< _vectorOwnerTypePivotIndices, CISSTNETLIB_INTEGER > &  pivotIndices,
vctDynamicVectorBase< _vectorOwnerTypeWorkspace, CISSTNETLIB_DOUBLE > &  workspace 
)
throw (std::runtime_error
)
inline

This method doesn't allocate any memory as it relies on the user provided vectors (pivotIndices and workspace).

The data object now acts as a composite container to hold, pass and manipulate a convenient storage for Inverse algorithm. The method tests that all the containers provided by the user have the correct size and are compact.

Parameters
AThe matrix to be inversed, used to verify the sizes.
pivotIndicesVector created by the user to store the pivot indices.
workspaceVector created by the user for the workspace.
template<class _vectorOwnerTypePivotIndices >
void nmrInverseDynamicData::ThrowUnlessPivotIndicesSizeIsCorrect ( vctDynamicVectorBase< _vectorOwnerTypePivotIndices, CISSTNETLIB_INTEGER > &  pivotIndices)
throw (std::runtime_error
)
inlineprotected

Verifies that the user provided reference for the pivot indices match the size of the data object as set by SetDimension. This method also checks that all containers are compact.

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

Verifies that the user provided reference for the workspace match the size of the data object as set by SetDimension. This method also checks that all containers are compact.

Note
The method SetDimension must have been called before.
template<class _matrixOwnerTypeA >
static size_type nmrInverseDynamicData::WorkspaceSize ( const vctDynamicConstMatrixBase< _matrixOwnerTypeA, CISSTNETLIB_DOUBLE > &  A)
inlinestatic

Helper method to compute the size of the workspace vector.

Parameters
AThe matrix to be used by nmrInverse (it is used only to determine the size).

Friends And Related Function Documentation

friend class Friend
friend

Member Data Documentation

vctDynamicVector<CISSTNETLIB_INTEGER> nmrInverseDynamicData::PivotIndicesMemory
protected

Memory allocated for pivot indices vector if needed.

vctDynamicVectorRef<CISSTNETLIB_INTEGER> nmrInverseDynamicData::PivotIndicesReference
protected

Reference return type, this points either to user allocated memory or our memory chunk if needed.

size_type nmrInverseDynamicData::SizeMember
protected

Store Size and StorageOrder which are needed to check if A matrix passed nmrInverse matches the allocated size.

bool nmrInverseDynamicData::StorageOrderMember
protected
vctDynamicVector<CISSTNETLIB_DOUBLE> nmrInverseDynamicData::WorkspaceMemory
protected

Memory allocated for the workspace if needed.

vctDynamicVectorRef<CISSTNETLIB_DOUBLE> nmrInverseDynamicData::WorkspaceReference
protected

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