cisst-saw
Loading...
Searching...
No Matches
vctDynamicConstMatrixRef< _elementType > Class Template Reference

Dynamic matrix referencing existing memory (const). More...

#include <vctDynamicConstMatrixRef.h>

Inheritance diagram for vctDynamicConstMatrixRef< _elementType >:
vctDynamicConstMatrixBase< vctDynamicMatrixRefOwner< _elementType >, _elementType >

Public Types

enum  { DIMENSION = 2 }
typedef vctDynamicConstMatrixRef< _elementType > ThisType
typedef vctDynamicMatrixRefOwner< _elementType > MatrixOwnerType
typedef vctDynamicConstMatrixBase< vctDynamicMatrixRefOwner< _elementType >, _elementType > BaseType
typedef MatrixOwnerType::iterator iterator
typedef MatrixOwnerType::const_iterator const_iterator
typedef MatrixOwnerType::reverse_iterator reverse_iterator
typedef MatrixOwnerType::const_reverse_iterator const_reverse_iterator

Public Member Functions

 VCT_CONTAINER_TRAITS_TYPEDEFS (_elementType)
 VCT_NARRAY_TRAITS_TYPEDEFS (DIMENSION)
 vctDynamicConstMatrixRef ()
 vctDynamicConstMatrixRef (const ThisType &other)
 vctDynamicConstMatrixRef (size_type rows, size_type cols, stride_type rowStride, stride_type colStride, pointer dataPointer)
 vctDynamicConstMatrixRef (size_type rows, size_type cols, stride_type rowStride, stride_type colStride, const_pointer dataPointer)
 vctDynamicConstMatrixRef (const nsize_type &matrixSize, stride_type rowStride, stride_type colStride, pointer dataPointer)
 vctDynamicConstMatrixRef (const nsize_type &matrixSize, stride_type rowStride, stride_type colStride, const_pointer dataPointer)
 vctDynamicConstMatrixRef (const nsize_type &matrixSize, const nstride_type &matrixStride, pointer dataPointer)
 vctDynamicConstMatrixRef (const nsize_type &matrixSize, const nstride_type &matrixStride, const_pointer dataPointer)
 vctDynamicConstMatrixRef (size_type rows, size_type cols, pointer dataPointer, bool storageOrder=VCT_DEFAULT_STORAGE)
 vctDynamicConstMatrixRef (size_type rows, size_type cols, const_pointer dataPointer, bool storageOrder=VCT_DEFAULT_STORAGE)
 vctDynamicConstMatrixRef (const nsize_type &matrixSize, pointer dataPointer, bool storageOrder=VCT_DEFAULT_STORAGE)
 vctDynamicConstMatrixRef (const nsize_type &matrixSize, const_pointer dataPointer, bool storageOrder=VCT_DEFAULT_STORAGE)
template<size_type __rows, size_type __cols, stride_type __rowStride, stride_type __colStride, typename __dataPtrType>
 vctDynamicConstMatrixRef (const vctFixedSizeConstMatrixBase< __rows, __cols, __rowStride, __colStride, _elementType, __dataPtrType > &otherMatrix)
template<size_type __rows, size_type __cols, stride_type __rowStride, stride_type __colStride, typename __dataPtrType>
 vctDynamicConstMatrixRef (const vctFixedSizeConstMatrixBase< __rows, __cols, __rowStride, __colStride, _elementType, __dataPtrType > &otherMatrix, size_type startRow, size_type startCol, size_type rows, size_type cols)
template<class __ownerType>
 vctDynamicConstMatrixRef (const vctDynamicConstMatrixBase< __ownerType, _elementType > &otherMatrix)
template<class __ownerType>
 vctDynamicConstMatrixRef (const vctDynamicConstMatrixBase< __ownerType, _elementType > &otherMatrix, size_type startRow, size_type startCol, size_type rows, size_type cols)
template<class __ownerType>
 vctDynamicConstMatrixRef (const vctDynamicConstMatrixBase< __ownerType, _elementType > &otherMatrix, const nsize_type &start, const nsize_type &matrixSize)
void SetRef (size_type rows, size_type cols, stride_type rowStride, stride_type colStride, pointer dataPointer)
void SetRef (size_type rows, size_type cols, stride_type rowStride, stride_type colStride, const_pointer dataPointer)
void SetRef (const nsize_type &matrixSize, stride_type rowStride, stride_type colStride, pointer dataPointer)
void SetRef (const nsize_type &matrixSize, stride_type rowStride, stride_type colStride, const_pointer dataPointer)
void SetRef (const nsize_type &matrixSize, const nstride_type &matrixStride, pointer dataPointer)
void SetRef (const nsize_type &matrixSize, const nstride_type &matrixStride, const_pointer dataPointer)
void SetRef (size_type rows, size_type cols, pointer dataPointer, bool storageOrder=VCT_DEFAULT_STORAGE)
void SetRef (size_type rows, size_type cols, const_pointer dataPointer, bool storageOrder=VCT_DEFAULT_STORAGE)
void SetRef (const nsize_type &sizes, pointer dataPointer, bool storageOrder=VCT_DEFAULT_STORAGE)
void SetRef (const nsize_type &sizes, const_pointer dataPointer, bool storageOrder=VCT_DEFAULT_STORAGE)
template<size_type __rows, size_type __cols, stride_type __rowStride, stride_type __colStride, typename __dataPtrType>
void SetRef (const vctFixedSizeConstMatrixBase< __rows, __cols, __rowStride, __colStride, _elementType, __dataPtrType > &otherMatrix)
template<size_type __rows, size_type __cols, stride_type __rowStride, stride_type __colStride, typename __dataPtrType>
void SetRef (const vctFixedSizeConstMatrixBase< __rows, __cols, __rowStride, __colStride, _elementType, __dataPtrType > &otherMatrix, size_type startRow, size_type startCol, size_type rows, size_type cols)
template<class __ownerType>
void SetRef (const vctDynamicConstMatrixBase< __ownerType, _elementType > &otherMatrix)
template<class __ownerType>
void SetRef (const vctDynamicConstMatrixBase< __ownerType, _elementType > &otherMatrix, size_type startRow, size_type startCol, size_type rows, size_type cols)
template<class __ownerType>
void SetRef (const vctDynamicConstMatrixBase< __ownerType, _elementType > &otherMatrix, const nsize_type &start, const nsize_type &matrixSize)

Detailed Description

template<class _elementType>
class vctDynamicConstMatrixRef< _elementType >

Dynamic matrix referencing existing memory (const).

The class vctDynamicConstMatrixRef 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.

Finally, as this overlay is const, it can be used to make sure the referenced content is not modified.

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

vctDynamicMatrix<double> wholeMatrix(10, 10);
vctRandom(wholeMatrix, -10.0, 10.0);
first5x5.SetRef(wholeMatrix, 0, 0, 5, 5);
std::cout << first5x5 << " " << first5x5.SumOfElements() << std::endl;
vctDynamicConstMatrixRef()
Definition vctDynamicConstMatrixRef.h:96
void SetRef(size_type rows, size_type cols, stride_type rowStride, stride_type colStride, pointer dataPointer)
Definition vctDynamicConstMatrixRef.h:248
Definition vctForwardDeclarations.h:157
void vctRandom(vctDynamicMatrixBase< _matrixOwnerType, _elementType > &matrix, const typename vctDynamicMatrixBase< _matrixOwnerType, _elementType >::value_type min, const typename vctDynamicMatrixBase< _matrixOwnerType, _elementType >::value_type max)
Definition vctRandomDynamicMatrix.h:47
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.
vctDynamicConstMatrixRef only performs const operations even if it stores a non-const value_type *. It can be initialized with either value_type * or const value_type *. For a non-const Ref, see vctDynamicMatrixRef.
See also
vctDynamicMatrix, vctDynamicMatrixRef
Parameters
_elementTypeType of elements referenced. Also defined as value_type.

Member Typedef Documentation

◆ BaseType

template<class _elementType>
typedef vctDynamicConstMatrixBase<vctDynamicMatrixRefOwner<_elementType>, _elementType> vctDynamicConstMatrixRef< _elementType >::BaseType

◆ const_iterator

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

◆ const_reverse_iterator

◆ iterator

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

◆ MatrixOwnerType

template<class _elementType>
typedef vctDynamicMatrixRefOwner<_elementType> vctDynamicConstMatrixRef< _elementType >::MatrixOwnerType

◆ reverse_iterator

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

◆ ThisType

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

Member Enumeration Documentation

◆ anonymous enum

template<class _elementType>
anonymous enum
Enumerator
DIMENSION 

Constructor & Destructor Documentation

◆ vctDynamicConstMatrixRef() [1/17]

template<class _elementType>
vctDynamicConstMatrixRef< _elementType >::vctDynamicConstMatrixRef ( )
inline

◆ vctDynamicConstMatrixRef() [2/17]

template<class _elementType>
vctDynamicConstMatrixRef< _elementType >::vctDynamicConstMatrixRef ( const ThisType & other)
inline

Copy constructor

◆ vctDynamicConstMatrixRef() [3/17]

template<class _elementType>
vctDynamicConstMatrixRef< _elementType >::vctDynamicConstMatrixRef ( 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.

◆ vctDynamicConstMatrixRef() [4/17]

template<class _elementType>
vctDynamicConstMatrixRef< _elementType >::vctDynamicConstMatrixRef ( size_type rows,
size_type cols,
stride_type rowStride,
stride_type colStride,
const_pointer dataPointer )
inline

◆ vctDynamicConstMatrixRef() [5/17]

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

◆ vctDynamicConstMatrixRef() [6/17]

template<class _elementType>
vctDynamicConstMatrixRef< _elementType >::vctDynamicConstMatrixRef ( const nsize_type & matrixSize,
stride_type rowStride,
stride_type colStride,
const_pointer dataPointer )
inline

◆ vctDynamicConstMatrixRef() [7/17]

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

◆ vctDynamicConstMatrixRef() [8/17]

template<class _elementType>
vctDynamicConstMatrixRef< _elementType >::vctDynamicConstMatrixRef ( const nsize_type & matrixSize,
const nstride_type & matrixStride,
const_pointer dataPointer )
inline

◆ vctDynamicConstMatrixRef() [9/17]

template<class _elementType>
vctDynamicConstMatrixRef< _elementType >::vctDynamicConstMatrixRef ( 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).

◆ vctDynamicConstMatrixRef() [10/17]

template<class _elementType>
vctDynamicConstMatrixRef< _elementType >::vctDynamicConstMatrixRef ( size_type rows,
size_type cols,
const_pointer dataPointer,
bool storageOrder = VCT_DEFAULT_STORAGE )
inline

◆ vctDynamicConstMatrixRef() [11/17]

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

◆ vctDynamicConstMatrixRef() [12/17]

template<class _elementType>
vctDynamicConstMatrixRef< _elementType >::vctDynamicConstMatrixRef ( const nsize_type & matrixSize,
const_pointer dataPointer,
bool storageOrder = VCT_DEFAULT_STORAGE )
inline

◆ vctDynamicConstMatrixRef() [13/17]

template<class _elementType>
template<size_type __rows, size_type __cols, stride_type __rowStride, stride_type __colStride, typename __dataPtrType>
vctDynamicConstMatrixRef< _elementType >::vctDynamicConstMatrixRef ( const vctFixedSizeConstMatrixBase< __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).

◆ vctDynamicConstMatrixRef() [14/17]

template<class _elementType>
template<size_type __rows, size_type __cols, stride_type __rowStride, stride_type __colStride, typename __dataPtrType>
vctDynamicConstMatrixRef< _elementType >::vctDynamicConstMatrixRef ( const vctFixedSizeConstMatrixBase< __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 submatrix of a fixed-size matrix.

Parameters
otherMatrixa fixed size matrix to which a reference is created.
startRowrow index of the position where the reference will start.
startColcolumn index of the position where the reference will start.
rowsthe number of rows being referenced
colsthe 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).

◆ vctDynamicConstMatrixRef() [15/17]

template<class _elementType>
template<class __ownerType>
vctDynamicConstMatrixRef< _elementType >::vctDynamicConstMatrixRef ( const vctDynamicConstMatrixBase< __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 SetRef methods).

◆ vctDynamicConstMatrixRef() [16/17]

template<class _elementType>
template<class __ownerType>
vctDynamicConstMatrixRef< _elementType >::vctDynamicConstMatrixRef ( const vctDynamicConstMatrixBase< __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
otherMatrixa fixed size matrix to which a reference is created.
startRowrow index of the position where the reference will start.
startColcolumn index of the position where the reference will start.
rowsthe number of rows being referenced
colsthe 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).

◆ vctDynamicConstMatrixRef() [17/17]

template<class _elementType>
template<class __ownerType>
vctDynamicConstMatrixRef< _elementType >::vctDynamicConstMatrixRef ( const vctDynamicConstMatrixBase< __ownerType, _elementType > & otherMatrix,
const nsize_type & start,
const nsize_type & matrixSize )
inline

Member Function Documentation

◆ SetRef() [1/15]

template<class _elementType>
void vctDynamicConstMatrixRef< _elementType >::SetRef ( const nsize_type & matrixSize,
const nstride_type & matrixStride,
const_pointer dataPointer )
inline

◆ SetRef() [2/15]

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

◆ SetRef() [3/15]

template<class _elementType>
void vctDynamicConstMatrixRef< _elementType >::SetRef ( const nsize_type & matrixSize,
stride_type rowStride,
stride_type colStride,
const_pointer dataPointer )
inline

◆ SetRef() [4/15]

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

◆ SetRef() [5/15]

template<class _elementType>
void vctDynamicConstMatrixRef< _elementType >::SetRef ( const nsize_type & sizes,
const_pointer dataPointer,
bool storageOrder = VCT_DEFAULT_STORAGE )
inline

◆ SetRef() [6/15]

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

◆ SetRef() [7/15]

template<class _elementType>
template<class __ownerType>
void vctDynamicConstMatrixRef< _elementType >::SetRef ( const vctDynamicConstMatrixBase< __ownerType, _elementType > & otherMatrix)
inline

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

◆ SetRef() [8/15]

template<class _elementType>
template<class __ownerType>
void vctDynamicConstMatrixRef< _elementType >::SetRef ( const vctDynamicConstMatrixBase< __ownerType, _elementType > & otherMatrix,
const nsize_type & start,
const nsize_type & matrixSize )
inline

◆ SetRef() [9/15]

template<class _elementType>
template<class __ownerType>
void vctDynamicConstMatrixRef< _elementType >::SetRef ( const vctDynamicConstMatrixBase< __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
otherMatrixa fixed size matrix to which a reference is created.
startRowrow index of the position where the reference will start.
startColcolumn index of the position where the reference will start.
rowsthe number of rows being referenced
colsthe 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).

◆ SetRef() [10/15]

template<class _elementType>
template<size_type __rows, size_type __cols, stride_type __rowStride, stride_type __colStride, typename __dataPtrType>
void vctDynamicConstMatrixRef< _elementType >::SetRef ( const vctFixedSizeConstMatrixBase< __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.

◆ SetRef() [11/15]

template<class _elementType>
template<size_type __rows, size_type __cols, stride_type __rowStride, stride_type __colStride, typename __dataPtrType>
void vctDynamicConstMatrixRef< _elementType >::SetRef ( const vctFixedSizeConstMatrixBase< __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
otherMatrixa fixed size matrix to which a reference is created.
startRowrow index of the position where the reference will start.
startColcolumn index of the position where the reference will start.
rowsthe number of rows being referenced
colsthe 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).

◆ SetRef() [12/15]

template<class _elementType>
void vctDynamicConstMatrixRef< _elementType >::SetRef ( size_type rows,
size_type cols,
const_pointer dataPointer,
bool storageOrder = VCT_DEFAULT_STORAGE )
inline

◆ SetRef() [13/15]

template<class _elementType>
void vctDynamicConstMatrixRef< _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.

◆ SetRef() [14/15]

template<class _elementType>
void vctDynamicConstMatrixRef< _elementType >::SetRef ( size_type rows,
size_type cols,
stride_type rowStride,
stride_type colStride,
const_pointer dataPointer )
inline

◆ SetRef() [15/15]

template<class _elementType>
void vctDynamicConstMatrixRef< _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.

◆ VCT_CONTAINER_TRAITS_TYPEDEFS()

template<class _elementType>
vctDynamicConstMatrixRef< _elementType >::VCT_CONTAINER_TRAITS_TYPEDEFS ( _elementType )

◆ VCT_NARRAY_TRAITS_TYPEDEFS()

template<class _elementType>
vctDynamicConstMatrixRef< _elementType >::VCT_NARRAY_TRAITS_TYPEDEFS ( DIMENSION )

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