#include <nmrInverse.h>
Collaboration diagram for nmrInverseDynamicData:

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:
Definition at line 83 of file nmrInverse.h.
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.
| 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.
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.
| size | Dimension of the square matrix. | |
| storageOrder | Storage order of the matrix |
Definition at line 288 of file nmrInverse.h.
References Allocate().
| 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.
| A | input matrix. |
Definition at line 303 of file nmrInverse.h.
References Allocate().
| 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.
| 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 323 of file nmrInverse.h.
References SetRef().
| 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).
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().
| 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.
Definition at line 170 of file nmrInverse.h.
References cmnThrow(), and SizeMember.
Referenced by SetRef().
| 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.
Definition at line 191 of file nmrInverse.h.
References cmnThrow(), and SizeMember.
Referenced by SetRef().
| static size_type nmrInverseDynamicData::PivotIndicesSize | ( | const vctDynamicConstMatrixBase< _matrixOwnerTypeA, CISSTNETLIB_DOUBLE > & | A | ) | [inline, static] |
Helper method to compute the size of the pivot indices vector.
| 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().
| static size_type nmrInverseDynamicData::WorkspaceSize | ( | const vctDynamicConstMatrixBase< _matrixOwnerTypeA, CISSTNETLIB_DOUBLE > & | A | ) | [inline, static] |
Helper method to compute the size of the workspace vector.
| 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().
| 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.
| 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.
| 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().
| 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.
| 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().
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().