ERC CISST - cisst software

nmrInverseDynamicData Class Reference
[Numerical Methods]

#include <nmrInverse.h>

Collaboration diagram for nmrInverseDynamicData:

Collaboration graph
[legend]
List of all members.

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

Definition at line 83 of file nmrInverse.h.

Public Types

Public Member Functions

Static Public Member Functions

Protected Member Functions

Protected Attributes


Member Typedef Documentation

typedef vct::size_type nmrInverseDynamicData::size_type

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.

Definition at line 91 of file nmrInverse.h.


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

Definition at line 271 of file nmrInverse.h.

References AllocatePivotIndicesWorkspace().

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:
size Dimension of the square matrix.
storageOrder Storage order of the matrix
See also:
nmrInverseDynamicData::Allocate

Definition at line 288 of file nmrInverse.h.

References 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:
A input matrix.
See also:
nmrInverseDynamicData::Allocate

Definition at line 303 of file nmrInverse.h.

References 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:
A The matrix to be inversed, used to verify the sizes.
pivotIndices Vector created by the user to store the pivot indices.
workspace Vector created by the user for the workspace.
See also:
nmrInverseDynamicData::SetRef

Definition at line 323 of file nmrInverse.h.

References SetRef().


Member Function Documentation

void nmrInverseDynamicData::SetDimension ( size_type  size,
bool  storageOrder 
) [inline, protected]

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

Definition at line 121 of file nmrInverse.h.

References SizeMember, and StorageOrderMember.

Referenced by Allocate(), and SetRef().

void nmrInverseDynamicData::AllocatePivotIndicesWorkspace ( bool  allocatePivotIndices,
bool  allocateWorkspace 
) [inline, protected]

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.

Definition at line 140 of file nmrInverse.h.

References PivotIndicesMemory, PivotIndicesReference, vctDynamicVectorRef< _elementType >::SetRef(), vctDynamicVector< _elementType >::SetSize(), SizeMember, WorkspaceMemory, and WorkspaceReference.

Referenced by Allocate(), nmrInverseDynamicData(), and SetRef().

template<class _vectorOwnerTypePivotIndices>
void nmrInverseDynamicData::ThrowUnlessPivotIndicesSizeIsCorrect ( vctDynamicVectorBase< _vectorOwnerTypePivotIndices, CISSTNETLIB_INTEGER > &  pivotIndices  )  throw (std::runtime_error) [inline, protected]

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.

Definition at line 170 of file nmrInverse.h.

References cmnThrow(), and SizeMember.

Referenced by SetRef().

template<class _vectorOwnerTypeWorkspace>
void nmrInverseDynamicData::ThrowUnlessWorkspaceSizeIsCorrect ( vctDynamicVectorBase< _vectorOwnerTypeWorkspace, CISSTNETLIB_DOUBLE > &  workspace  )  throw (std::runtime_error) [inline, protected]

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.

Definition at line 191 of file nmrInverse.h.

References cmnThrow(), and SizeMember.

Referenced by SetRef().

template<class _matrixOwnerTypeA>
static size_type nmrInverseDynamicData::PivotIndicesSize ( const vctDynamicConstMatrixBase< _matrixOwnerTypeA, CISSTNETLIB_DOUBLE > &  A  )  [inline, static]

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

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

Definition at line 214 of file nmrInverse.h.

References vctDynamicConstMatrixBase< _matrixOwnerType, _elementType >::rows().

template<class _matrixOwnerTypeA>
static size_type nmrInverseDynamicData::WorkspaceSize ( const vctDynamicConstMatrixBase< _matrixOwnerTypeA, CISSTNETLIB_DOUBLE > &  A  )  [inline, static]

Helper method to compute the size of the workspace vector.

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

Definition at line 227 of file nmrInverse.h.

References vctDynamicConstMatrixBase< _matrixOwnerType, _elementType >::rows().

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:
A The square matrix for which inverse needs to be computed.

Definition at line 341 of file nmrInverse.h.

References vctDynamicConstMatrixBase< _matrixOwnerType, _elementType >::rows(), and vctDynamicConstMatrixBase< _matrixOwnerType, _elementType >::StorageOrder().

Referenced by nmrInverseDynamicData().

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:
size Size of the square input matrix A.
storageOrder Storage order of the input matrix.

Definition at line 353 of file nmrInverse.h.

References AllocatePivotIndicesWorkspace(), and SetDimension().

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:
A The matrix to be inversed, used to verify the sizes.
pivotIndices Vector created by the user to store the pivot indices.
workspace Vector created by the user for the workspace.

Definition at line 374 of file nmrInverse.h.

References AllocatePivotIndicesWorkspace(), PivotIndicesReference, SetDimension(), vctDynamicVectorRef< _elementType >::SetRef(), ThrowUnlessPivotIndicesSizeIsCorrect(), ThrowUnlessWorkspaceSizeIsCorrect(), and WorkspaceReference.

Referenced by nmrInverseDynamicData().


Member Data Documentation

vctDynamicVector<CISSTNETLIB_INTEGER> nmrInverseDynamicData::PivotIndicesMemory [protected]

Memory allocated for pivot indices vector if needed.

Definition at line 97 of file nmrInverse.h.

Referenced by AllocatePivotIndicesWorkspace().

vctDynamicVector<CISSTNETLIB_DOUBLE> nmrInverseDynamicData::WorkspaceMemory [protected]

Memory allocated for the workspace if needed.

Definition at line 100 of file nmrInverse.h.

Referenced by AllocatePivotIndicesWorkspace().

vctDynamicVectorRef<CISSTNETLIB_INTEGER> nmrInverseDynamicData::PivotIndicesReference [protected]

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

Definition at line 106 of file nmrInverse.h.

Referenced by AllocatePivotIndicesWorkspace(), and SetRef().

vctDynamicVectorRef<CISSTNETLIB_DOUBLE> nmrInverseDynamicData::WorkspaceReference [protected]

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

Definition at line 107 of file nmrInverse.h.

Referenced by AllocatePivotIndicesWorkspace(), and SetRef().

size_type nmrInverseDynamicData::SizeMember [protected]

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

Definition at line 113 of file nmrInverse.h.

Referenced by AllocatePivotIndicesWorkspace(), SetDimension(), ThrowUnlessPivotIndicesSizeIsCorrect(), and ThrowUnlessWorkspaceSizeIsCorrect().

bool nmrInverseDynamicData::StorageOrderMember [protected]

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

Definition at line 114 of file nmrInverse.h.

Referenced by SetDimension().


The documentation for this class was generated from the following file:
erc-cisst-devel<at>lists.johnshopkins.edu