ERC CISST - cisst software

vctDynamicMatrixRef< _elementType > Class Template Reference
[Vectors]

#include <vctDynamicMatrixRef.h>

Inheritance diagram for vctDynamicMatrixRef< _elementType >:

Inheritance graph
[legend]
Collaboration diagram for vctDynamicMatrixRef< _elementType >:

Collaboration graph
[legend]
List of all members.

Detailed Description

template<class _elementType>
class vctDynamicMatrixRef< _elementType >

Dynamic matrix referencing existing memory.

The class vctDynamicMatrixRef allows to create a matrix overlaying an existing block of memory. It can be used to manipulate a container created by another toolkit (i.e. OpenGL, vtk, ...) or a cisstVector container using different parameters (different size, storage order or stride).

To setup the overlay, one can use either the constructors or the SetRef methods. When used with a cisst container, the SetRef methods can infer some of the memory layout information (pointer on first element, sizes, strides). When used to overlay existing memory referenced by a pointer, the user has to provide all the required information. In any case, the Ref object doesn't allocate nor free memory.

For example to manipulate the first five elements of a matrix, one can do:

  vctDynamicMatrix<double> wholeMatrix(10, 10);
  vctRandom(wholeMatrix, -10.0, 10.0);
  vctDynamicMatrixRef<double> first5x5;
  first5x5.SetRef(wholeMatrix, 0, 0, 5, 5);
  first5x5.SetAll(5.0);

Note:
Make sure the underlying memory is not freed after the Ref object is created and before it is used. This would lead to faulty memory access and potential bugs.

vctDynamicMatrixRef can perform const and non-const operations. It can be initialized with a non-const object only (value_type *). For a const Ref, see vctDynamicConstMatrixRef.

See also:
vctDynamicMatrix, vctDynamicConstMatrixRef
Parameters:
_elementType Type of elements referenced. Also defined as value_type.

Definition at line 77 of file vctDynamicMatrixRef.h.

Public Types

Public Member Functions

Assignment operation into a matrix reference
Parameters:
other The matrix to be copied.


Public Attributes


Member Typedef Documentation

template<class _elementType>
typedef vctDynamicMatrixRef<_elementType> vctDynamicMatrixRef< _elementType >::ThisType

Type of the matrix itself.

Reimplemented from vctDynamicMatrixBase< vctDynamicMatrixRefOwner< _elementType >, _elementType >.

Definition at line 85 of file vctDynamicMatrixRef.h.

template<class _elementType>
typedef vctDynamicMatrixBase<vctDynamicMatrixRefOwner<_elementType>, _elementType> vctDynamicMatrixRef< _elementType >::BaseType

Type of the base class.

Reimplemented from vctDynamicMatrixBase< vctDynamicMatrixRefOwner< _elementType >, _elementType >.

Definition at line 87 of file vctDynamicMatrixRef.h.

template<class _elementType>
typedef MatrixOwnerType::iterator vctDynamicMatrixRef< _elementType >::iterator

Iterator on the elements of the matrix.

Reimplemented from vctDynamicMatrixBase< vctDynamicMatrixRefOwner< _elementType >, _elementType >.

Definition at line 88 of file vctDynamicMatrixRef.h.

template<class _elementType>
typedef MatrixOwnerType::const_iterator vctDynamicMatrixRef< _elementType >::const_iterator

Const iterator on the elements of the matrix.

Reimplemented from vctDynamicMatrixBase< vctDynamicMatrixRefOwner< _elementType >, _elementType >.

Definition at line 89 of file vctDynamicMatrixRef.h.

template<class _elementType>
typedef MatrixOwnerType::reverse_iterator vctDynamicMatrixRef< _elementType >::reverse_iterator

Reverse iterator on the elements of the matrix.

Reimplemented from vctDynamicMatrixBase< vctDynamicMatrixRefOwner< _elementType >, _elementType >.

Definition at line 90 of file vctDynamicMatrixRef.h.

template<class _elementType>
typedef MatrixOwnerType::const_reverse_iterator vctDynamicMatrixRef< _elementType >::const_reverse_iterator

Const reverse iterator on the elements of the matrix.

Reimplemented from vctDynamicMatrixBase< vctDynamicMatrixRefOwner< _elementType >, _elementType >.

Definition at line 91 of file vctDynamicMatrixRef.h.


Constructor & Destructor Documentation

template<class _elementType>
vctDynamicMatrixRef< _elementType >::vctDynamicMatrixRef ( const ThisType other  )  [inline]

Copy constructor. This copy constructor takes a const reference on the object to copy but has to remove the const-ness of the point to create a vctDynamicMatrixRef and allow it to manipulate elements. The explict use of a const_cast is far from great but there is no easy solution as C++ requires the copy constructor to take a const reference.

Definition at line 103 of file vctDynamicMatrixRef.h.

template<class _elementType>
vctDynamicMatrixRef< _elementType >::vctDynamicMatrixRef ( size_type  rows,
size_type  cols,
stride_type  rowStride,
stride_type  colStride,
pointer  dataPointer 
) [inline]

Constructor requiring the user to provide all the necessary information, i.e. the size (number of rows and columns), the strides (increment from row to row and from column to column) as well as a pointer on the first element.

Definition at line 114 of file vctDynamicMatrixRef.h.

template<class _elementType>
vctDynamicMatrixRef< _elementType >::vctDynamicMatrixRef ( const nsize_type &  matrixSize,
stride_type  rowStride,
stride_type  colStride,
pointer  dataPointer 
) [inline]

Constructor requiring the user to provide all the necessary information, i.e. the size (number of rows and columns), the strides (increment from row to row and from column to column) as well as a pointer on the first element.

Definition at line 120 of file vctDynamicMatrixRef.h.

template<class _elementType>
vctDynamicMatrixRef< _elementType >::vctDynamicMatrixRef ( const nsize_type &  matrixSize,
const nstride_type &  matrixStride,
pointer  dataPointer 
) [inline]

Constructor requiring the user to provide all the necessary information, i.e. the size (number of rows and columns), the strides (increment from row to row and from column to column) as well as a pointer on the first element.

Definition at line 126 of file vctDynamicMatrixRef.h.

template<class _elementType>
vctDynamicMatrixRef< _elementType >::vctDynamicMatrixRef ( size_type  rows,
size_type  cols,
pointer  dataPointer,
bool  storageOrder = VCT_DEFAULT_STORAGE 
) [inline]

Constructor requiring the user to provide the size of the matrix (number of rows and columns), a pointer on the first element and the desired storage order. If the storage order is omitted, the default is used (row major).

Definition at line 139 of file vctDynamicMatrixRef.h.

template<class _elementType>
vctDynamicMatrixRef< _elementType >::vctDynamicMatrixRef ( const nsize_type &  matrixSize,
pointer  dataPointer,
bool  storageOrder = VCT_DEFAULT_STORAGE 
) [inline]

Constructor requiring the user to provide the size of the matrix (number of rows and columns), a pointer on the first element and the desired storage order. If the storage order is omitted, the default is used (row major).

Definition at line 144 of file vctDynamicMatrixRef.h.

template<class _elementType>
template<size_type __rows, size_type __cols, stride_type __rowStride, stride_type __colStride, typename __dataPtrType>
vctDynamicMatrixRef< _elementType >::vctDynamicMatrixRef ( vctFixedSizeMatrixBase< __rows, __cols, __rowStride, __colStride, _elementType, __dataPtrType > &  otherMatrix  )  [inline]

Construct a dynamic reference to a fixed-size matrix.

Note:
the strides of this reference will be identical to the strides of the input matrix. For a more advanced access, customize the parameters yourself (see the other ctors).

Definition at line 157 of file vctDynamicMatrixRef.h.

template<class _elementType>
template<size_type __rows, size_type __cols, stride_type __rowStride, stride_type __colStride, typename __dataPtrType>
vctDynamicMatrixRef< _elementType >::vctDynamicMatrixRef ( vctFixedSizeMatrixBase< __rows, __cols, __rowStride, __colStride, _elementType, __dataPtrType > &  otherMatrix,
size_type  startRow,
size_type  startCol,
size_type  rows,
size_type  cols 
) [inline]

Construct a dynamic reference to a fixed-size matrix.

Parameters:
otherMatrix a fixed size matrix to which a reference is created.
startRow row index of the position where the reference will start.
startCol column index of the position where the reference will start.
rows the number of rows being referenced
cols the number of columns being referenced
Note:
the strides of this reference will be identical to the strides of the input matrix. For a more advanced access, customize the parameters yourself (see the other ctors).

Definition at line 173 of file vctDynamicMatrixRef.h.

template<class _elementType>
template<class __ownerType>
vctDynamicMatrixRef< _elementType >::vctDynamicMatrixRef ( vctDynamicMatrixBase< __ownerType, _elementType > &  otherMatrix  )  [inline]

Construct a dynamic reference to a dynamic matrix.

Note:
the strides of this reference will be identical to the strides of the input matrix. For a more advanced access, customize the parameters yourself (see the other ctors).

Definition at line 185 of file vctDynamicMatrixRef.h.

template<class _elementType>
template<class __ownerType>
vctDynamicMatrixRef< _elementType >::vctDynamicMatrixRef ( vctDynamicMatrixBase< __ownerType, _elementType > &  otherMatrix,
size_type  startRow,
size_type  startCol,
size_type  rows,
size_type  cols 
) [inline]

Construct a dynamic reference to a submatrix of a dynamic matrix.

Parameters:
otherMatrix a dynamic matrix to which a reference is created.
startRow row index of the position where the reference will start.
startCol column index of the position where the reference will start.
rows the number of rows being referenced
cols the number of columns being referenced
Note:
the strides of this reference will be identical to the strides of the input matrix. For a more advanced access, customize the parameters yourself (see the other ctors).

Definition at line 202 of file vctDynamicMatrixRef.h.

template<class _elementType>
vctDynamicMatrixRef< _elementType >::vctDynamicMatrixRef ( size_type  rows,
size_type  cols,
stride_type  rowStride,
stride_type  colStride,
pointer  dataPointer 
) [inline]

Constructor requiring the user to provide all the necessary information, i.e. the size (number of rows and columns), the strides (increment from row to row and from column to column) as well as a pointer on the first element.

Definition at line 114 of file vctDynamicMatrixRef.h.

template<class _elementType>
vctDynamicMatrixRef< _elementType >::vctDynamicMatrixRef ( const nsize_type &  matrixSize,
stride_type  rowStride,
stride_type  colStride,
pointer  dataPointer 
) [inline]

Constructor requiring the user to provide all the necessary information, i.e. the size (number of rows and columns), the strides (increment from row to row and from column to column) as well as a pointer on the first element.

Definition at line 120 of file vctDynamicMatrixRef.h.

template<class _elementType>
vctDynamicMatrixRef< _elementType >::vctDynamicMatrixRef ( const nsize_type &  matrixSize,
const nstride_type &  matrixStride,
pointer  dataPointer 
) [inline]

Constructor requiring the user to provide all the necessary information, i.e. the size (number of rows and columns), the strides (increment from row to row and from column to column) as well as a pointer on the first element.

Definition at line 126 of file vctDynamicMatrixRef.h.

template<class _elementType>
vctDynamicMatrixRef< _elementType >::vctDynamicMatrixRef ( size_type  rows,
size_type  cols,
pointer  dataPointer,
bool  storageOrder = VCT_DEFAULT_STORAGE 
) [inline]

Constructor requiring the user to provide the size of the matrix (number of rows and columns), a pointer on the first element and the desired storage order. If the storage order is omitted, the default is used (row major).

Definition at line 139 of file vctDynamicMatrixRef.h.

template<class _elementType>
vctDynamicMatrixRef< _elementType >::vctDynamicMatrixRef ( const nsize_type &  matrixSize,
pointer  dataPointer,
bool  storageOrder = VCT_DEFAULT_STORAGE 
) [inline]

Constructor requiring the user to provide the size of the matrix (number of rows and columns), a pointer on the first element and the desired storage order. If the storage order is omitted, the default is used (row major).

Definition at line 144 of file vctDynamicMatrixRef.h.


Member Function Documentation

template<class _elementType>
void vctDynamicMatrixRef< _elementType >::SetRef ( size_type  rows,
size_type  cols,
stride_type  rowStride,
stride_type  colStride,
pointer  dataPointer 
) [inline]

Set a dynamic reference to a memory location. The user should specify all the parameters of the referenced memory, including a start memory address.

Definition at line 220 of file vctDynamicMatrixRef.h.

Referenced by nmrSVDEconomyDynamicData::AllocateOutputWorkspace(), nmrSVDDynamicData::AllocateOutputWorkspace(), nmrPInverseEconomyDynamicData::AllocateOutputWorkspace(), nmrPInverseDynamicData::AllocateOutputWorkspace(), nmrNNLSDynamicData::AllocateOutputWorkspaces(), nmrIsOrthonormal(), vctDynamicMatrixRef< CISSTNETLIB_DOUBLE >::SetRef(), nmrSVDEconomyDynamicData::SetRef(), nmrSVDDynamicData::SetRef(), nmrPInverseEconomyDynamicData::SetRef(), nmrPInverseDynamicData::SetRef(), nmrNNLSDynamicData::SetRef(), nmrSVDEconomyDynamicData::SetRefOutput(), nmrSVDDynamicData::SetRefOutput(), nmrPInverseEconomyDynamicData::SetRefOutput(), nmrPInverseDynamicData::SetRefOutput(), nmrNNLSDynamicData::SetRefOutput(), nmrPInverseEconomyDynamicData::SetRefSVD(), nmrPInverseDynamicData::SetRefSVD(), and vctDynamicMatrixRef< CISSTNETLIB_DOUBLE >::vctDynamicMatrixRef().

template<class _elementType>
void vctDynamicMatrixRef< _elementType >::SetRef ( const nsize_type &  matrixSize,
stride_type  rowStride,
stride_type  colStride,
pointer  dataPointer 
) [inline]

Set a dynamic reference to a memory location. The user should specify all the parameters of the referenced memory, including a start memory address.

Definition at line 226 of file vctDynamicMatrixRef.h.

template<class _elementType>
void vctDynamicMatrixRef< _elementType >::SetRef ( const nsize_type &  matrixSize,
const nstride_type &  matrixStride,
pointer  dataPointer 
) [inline]

Set a dynamic reference to a memory location. The user should specify all the parameters of the referenced memory, including a start memory address.

Definition at line 232 of file vctDynamicMatrixRef.h.

template<class _elementType>
void vctDynamicMatrixRef< _elementType >::SetRef ( size_type  rows,
size_type  cols,
pointer  dataPointer,
bool  storageOrder = VCT_DEFAULT_STORAGE 
) [inline]

Set a dynamic reference to a memory location. The user should specify the dimension, start memory address and desired storage order. This method assumes there is enough memory and will create a compact matrix reference.

Definition at line 245 of file vctDynamicMatrixRef.h.

template<class _elementType>
void vctDynamicMatrixRef< _elementType >::SetRef ( const nsize_type &  sizes,
pointer  dataPointer,
bool  storageOrder = VCT_DEFAULT_STORAGE 
) [inline]

Set a dynamic reference to a memory location. The user should specify the dimension, start memory address and desired storage order. This method assumes there is enough memory and will create a compact matrix reference.

Definition at line 250 of file vctDynamicMatrixRef.h.

template<class _elementType>
template<size_type __rows, size_type __cols, stride_type __rowStride, stride_type __colStride, typename __dataPtrType>
void vctDynamicMatrixRef< _elementType >::SetRef ( vctFixedSizeMatrixBase< __rows, __cols, __rowStride, __colStride, _elementType, __dataPtrType > &  otherMatrix  )  [inline]

Set a dynamic reference to a fixed-size matrix. The reference will have identical dimensions and strides as the input matrix.

Definition at line 261 of file vctDynamicMatrixRef.h.

template<class _elementType>
template<size_type __rows, size_type __cols, stride_type __rowStride, stride_type __colStride, typename __dataPtrType>
void vctDynamicMatrixRef< _elementType >::SetRef ( vctFixedSizeMatrixBase< __rows, __cols, __rowStride, __colStride, _elementType, __dataPtrType > &  otherMatrix,
size_type  startRow,
size_type  startCol,
size_type  rows,
size_type  cols 
) [inline]

Set a dynamic reference to a submatrix of a fixed-size matrix.

Parameters:
otherMatrix a fixed size matrix to which a reference is created.
startRow row index of the position where the reference will start.
startCol column index of the position where the reference will start.
rows the number of rows being referenced
cols the number of columns being referenced
Note:
the strides of this reference will be identical to the strides of the input matrix. For a more advanced access, customize the parameters yourself (see the SetRef methods).

This method verifies that the size of this matrix does not exceed the size of the input matrix (otherwise cmnThrow is used to throw std::out_of_range).

Definition at line 280 of file vctDynamicMatrixRef.h.

template<class _elementType>
template<class __ownerType>
void vctDynamicMatrixRef< _elementType >::SetRef ( vctDynamicMatrixBase< __ownerType, _elementType > &  otherMatrix  )  [inline]

Set a dynamic reference to a dynamic matrix. The reference will have identical dimensions and strides as the input matrix.

Definition at line 293 of file vctDynamicMatrixRef.h.

template<class _elementType>
template<class __ownerType>
void vctDynamicMatrixRef< _elementType >::SetRef ( vctDynamicMatrixBase< __ownerType, _elementType > &  otherMatrix,
size_type  startRow,
size_type  startCol,
size_type  rows,
size_type  cols 
) [inline]

Set a dynamic reference to a submatrix of a dynamic matrix.

Parameters:
otherMatrix a dynamic matrix to which a reference is created.
startRow row index of the position where the reference will start.
startCol column index of the position where the reference will start.
rows the number of rows being referenced
cols the number of columns being referenced
Note:
the strides of this reference will be identical to the strides of the input matrix. For a more advanced access, customize the parameters yourself (see the other SetRef methods).

This method verifies that the size of this matrix does not exceed the size of the input matrix (otherwise cmnThrow is used to throw std::out_of_range).

Definition at line 313 of file vctDynamicMatrixRef.h.

template<class _elementType>
template<class __ownerType>
void vctDynamicMatrixRef< _elementType >::SetRef ( vctDynamicMatrixBase< __ownerType, _elementType > &  otherMatrix,
const nsize_type &  start,
const nsize_type &  matrixSize 
) [inline]

Set a dynamic reference to a submatrix of a dynamic matrix.

Parameters:
otherMatrix a dynamic matrix to which a reference is created.
startRow row index of the position where the reference will start.
startCol column index of the position where the reference will start.
rows the number of rows being referenced
cols the number of columns being referenced
Note:
the strides of this reference will be identical to the strides of the input matrix. For a more advanced access, customize the parameters yourself (see the other SetRef methods).

This method verifies that the size of this matrix does not exceed the size of the input matrix (otherwise cmnThrow is used to throw std::out_of_range).

Definition at line 324 of file vctDynamicMatrixRef.h.

template<class _elementType>
ThisType& vctDynamicMatrixRef< _elementType >::operator= ( const value_type &  value  )  [inline]

Assignement of a scalar to all elements. See also SetAll.

Definition at line 353 of file vctDynamicMatrixRef.h.

template<class _elementType>
void vctDynamicMatrixRef< _elementType >::DeSerializeRaw ( std::istream &  inputStream  )  throw (std::runtime_error) [inline]

Binary deserialization. This method can not resize the existing block of memory and will throw an exception is the sizes don't match.

Definition at line 361 of file vctDynamicMatrixRef.h.


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