ERC CISST - cisst software

vctDynamicNArrayRef< _elementType, _dimension > Class Template Reference
[Vectors]

#include <vctDynamicNArrayRef.h>

Inheritance diagram for vctDynamicNArrayRef< _elementType, _dimension >:

Inheritance graph
[legend]
Collaboration diagram for vctDynamicNArrayRef< _elementType, _dimension >:

Collaboration graph
[legend]
List of all members.

Detailed Description

template<class _elementType, vct::size_type _dimension>
class vctDynamicNArrayRef< _elementType, _dimension >

Dynamic nArray referencing existing memory.

The class vctDynamicNArrayRef allows to create a nArray 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 nArray, one can do:

  vctDynamicNArray<double, 2> wholeNArray(size_type(10, 10));
  vctRandom(wholeNArray, -10.0, 10.0);
  vctDynamicNArrayRef<double, 2> first5x5;
  first5x5.SetRef(wholeNArray, size_type(0, 0), size_type(5, 5));
  first5x5.SetAll(5.0);

Note:
On top of the SetRef methods provided for the cisst vectors and matrices (see vctDynamicVectorRef and vctDynamicMatrixRef), the ref classes for nArrays provides the methods SubarrayOf (re-size, same dimension), PermutationOf (same dimension, same sizes but different ordering of dimensions), SliceOf (reduce dimension by 1). By combining different Refs created using a mix of these methods, one can create any desired overlay.

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.

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

See also:
vctDynamicNArray, vctDynamicConstNArrayRef
Parameters:
_elementType Type of elements referenced. Also defined as value_type.
_dimension Dimension of the nArray ref.

Definition at line 88 of file vctDynamicNArrayRef.h.

Public Types

Public Member Functions

Assignment operation into an nArray reference
Parameters:
other the nArray to be copied.


Public Attributes


Member Typedef Documentation

template<class _elementType, vct::size_type _dimension>
typedef vctDynamicNArrayRef<_elementType, DIMENSION> vctDynamicNArrayRef< _elementType, _dimension >::ThisType

Type of the nArray itself

Reimplemented from vctDynamicNArrayBase< vctDynamicNArrayRefOwner< _elementType, _dimension >, _elementType, _dimension >.

Definition at line 98 of file vctDynamicNArrayRef.h.

template<class _elementType, vct::size_type _dimension>
typedef vctDynamicNArrayBase<vctDynamicNArrayRefOwner<_elementType, DIMENSION>, _elementType, DIMENSION> vctDynamicNArrayRef< _elementType, _dimension >::BaseType

Type of the base class

Reimplemented from vctDynamicNArrayBase< vctDynamicNArrayRefOwner< _elementType, _dimension >, _elementType, _dimension >.

Definition at line 100 of file vctDynamicNArrayRef.h.


Constructor & Destructor Documentation

template<class _elementType, vct::size_type _dimension>
vctDynamicNArrayRef< _elementType, _dimension >::vctDynamicNArrayRef ( 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 vctDynamicNArrayRef 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 118 of file vctDynamicNArrayRef.h.

References vctDynamicNArrayBase< _nArrayOwnerType, _elementType, _dimension >::Pointer(), vctDynamicNArrayRef< _elementType, _dimension >::SetRef(), vctDynamicConstNArrayBase< _nArrayOwnerType, _elementType, _dimension >::sizes(), and vctDynamicConstNArrayBase< _nArrayOwnerType, _elementType, _dimension >::strides().

template<class _elementType, vct::size_type _dimension>
vctDynamicNArrayRef< _elementType, _dimension >::vctDynamicNArrayRef ( pointer  dataPointer,
const nsize_type &  sizes,
const nstride_type &  strides 
) [inline]

Create a reference to a memory location.

Note:
see corresponding SetRef method below

Definition at line 127 of file vctDynamicNArrayRef.h.

References vctDynamicNArrayRef< _elementType, _dimension >::SetRef().

template<class _elementType, vct::size_type _dimension>
template<class __ownerType>
vctDynamicNArrayRef< _elementType, _dimension >::vctDynamicNArrayRef ( vctDynamicNArrayBase< __ownerType, _elementType, DIMENSION > &  otherNArray  )  [inline]

Create a reference to an nArray.

Note:
see corresponding SetRef method below

Definition at line 136 of file vctDynamicNArrayRef.h.

References vctDynamicNArrayRef< _elementType, _dimension >::SetRef().

template<class _elementType, vct::size_type _dimension>
template<class __ownerType>
vctDynamicNArrayRef< _elementType, _dimension >::vctDynamicNArrayRef ( vctDynamicConstVectorBase< __ownerType, _elementType > &  vector  )  [inline]

Create a reference to a dynamic vector.

Note:
see corresponding SetRef method below

Definition at line 145 of file vctDynamicNArrayRef.h.

References vctDynamicNArrayRef< _elementType, _dimension >::SetRef().

template<class _elementType, vct::size_type _dimension>
template<size_type __size, stride_type __stride, typename __dataPtrType>
vctDynamicNArrayRef< _elementType, _dimension >::vctDynamicNArrayRef ( vctFixedSizeConstVectorBase< __size, __stride, _elementType, __dataPtrType > &  vector  )  [inline]

Create a reference to a fixed-size vector.

Note:
see corresponding SetRef method below

Definition at line 154 of file vctDynamicNArrayRef.h.

References vctDynamicNArrayRef< _elementType, _dimension >::SetRef().

template<class _elementType, vct::size_type _dimension>
template<class __ownerType>
vctDynamicNArrayRef< _elementType, _dimension >::vctDynamicNArrayRef ( vctDynamicConstMatrixBase< __ownerType, _elementType > &  matrix  )  [inline]

Create a reference to a dynamic matrix.

Note:
see corresponding SetRef method below

Definition at line 163 of file vctDynamicNArrayRef.h.

References vctDynamicNArrayRef< _elementType, _dimension >::SetRef().

template<class _elementType, vct::size_type _dimension>
template<size_type __rows, size_type __cols, stride_type __rowStride, stride_type __colStride, typename __dataPtrType>
vctDynamicNArrayRef< _elementType, _dimension >::vctDynamicNArrayRef ( vctFixedSizeConstMatrixBase< __rows, __cols, __rowStride, __colStride, _elementType, __dataPtrType > &  matrix  )  [inline]

Create a reference to a fixed-size matrix.

Note:
see corresponding SetRef method below

Definition at line 172 of file vctDynamicNArrayRef.h.

References vctDynamicNArrayRef< _elementType, _dimension >::SetRef().


Member Function Documentation

template<class _elementType, vct::size_type _dimension>
void vctDynamicNArrayRef< _elementType, _dimension >::SetRef ( pointer  dataPointer,
const nsize_type &  sizes,
const nstride_type &  strides 
) [inline]

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

Definition at line 181 of file vctDynamicNArrayRef.h.

References vctDynamicConstNArrayBase< vctDynamicNArrayRefOwner< _elementType, _dimension >, _elementType, _dimension >::NArray, and vctDynamicNArrayRefOwner< _elementType, _dimension >::SetRef().

Referenced by vctDynamicNArrayRef< _elementType, _dimension >::PermutationOf(), vctDynamicNArrayRef< _elementType, _dimension >::SetRef(), vctDynamicNArrayRef< _elementType, _dimension >::SliceOf(), vctDynamicNArrayRef< _elementType, _dimension >::SubarrayOf(), and vctDynamicNArrayRef< _elementType, _dimension >::vctDynamicNArrayRef().

template<class _elementType, vct::size_type _dimension>
template<class __ownerType>
void vctDynamicNArrayRef< _elementType, _dimension >::SetRef ( vctDynamicNArrayBase< __ownerType, _elementType, DIMENSION > &  otherNArray  )  [inline]

Set a reference to an nArray. The reference will have identical dimensions, sizes and strides as the input nArray.

Definition at line 190 of file vctDynamicNArrayRef.h.

References vctDynamicNArrayBase< _nArrayOwnerType, _elementType, _dimension >::Pointer(), vctDynamicNArrayRef< _elementType, _dimension >::SetRef(), vctDynamicConstNArrayBase< _nArrayOwnerType, _elementType, _dimension >::sizes(), and vctDynamicConstNArrayBase< _nArrayOwnerType, _elementType, _dimension >::strides().

template<class _elementType, vct::size_type _dimension>
template<class __ownerType>
void vctDynamicNArrayRef< _elementType, _dimension >::SubarrayOf ( vctDynamicNArrayBase< __ownerType, _elementType, DIMENSION > &  otherNArray,
const nsize_type &  startPosition,
const nsize_type &  lengths 
) [inline]

Set a reference to a subarray of an nArray.

Parameters:
otherNArray the nArray over which to set this reference
startPosition vector of indices of the element position where the reference will start
lengths the number of elements to reference in each dimension
Note:
Preserves the number of dimensions.

Definition at line 203 of file vctDynamicNArrayRef.h.

References CMN_ASSERT, vctDynamicConstNArrayBase< vctDynamicNArrayRefOwner< _elementType, _dimension >, _elementType, _dimension >::LesserOrEqual(), vctDynamicNArrayBase< _nArrayOwnerType, _elementType, _dimension >::Pointer(), vctDynamicNArrayRef< _elementType, _dimension >::SetRef(), vctDynamicConstNArrayBase< _nArrayOwnerType, _elementType, _dimension >::sizes(), and vctDynamicConstNArrayBase< _nArrayOwnerType, _elementType, _dimension >::strides().

Referenced by vctDynamicNArrayBase< vctDynamicNArrayRefOwner< _elementType, _dimension >, _elementType, _dimension >::Subarray().

template<class _elementType, vct::size_type _dimension>
template<class __ownerType>
void vctDynamicNArrayRef< _elementType, _dimension >::PermutationOf ( vctDynamicNArrayBase< __ownerType, _elementType, DIMENSION > &  otherNArray,
const ndimension_type &  dimensions 
) [inline]

Set a reference to an nArray with a permutation of its strides.

Parameters:
otherNArray the nArray over which to set this reference
dimensions a sequence of dimension numbers representing the permuted order of strides
Note:
Preserves the number of dimensions.

Definition at line 219 of file vctDynamicNArrayRef.h.

References vctDynamicNArrayBase< _nArrayOwnerType, _elementType, _dimension >::Pointer(), vctDynamicNArrayRef< _elementType, _dimension >::SetRef(), vctDynamicConstNArrayBase< _nArrayOwnerType, _elementType, _dimension >::size(), vctDynamicConstNArrayBase< vctDynamicNArrayRefOwner< _elementType, _dimension >, _elementType, _dimension >::sizes(), vctDynamicConstNArrayBase< _nArrayOwnerType, _elementType, _dimension >::stride(), and vctDynamicConstNArrayBase< vctDynamicNArrayRefOwner< _elementType, _dimension >, _elementType, _dimension >::strides().

Referenced by vctDynamicNArrayBase< vctDynamicNArrayRefOwner< _elementType, _dimension >, _elementType, _dimension >::Permutation().

template<class _elementType, vct::size_type _dimension>
template<class __ownerType>
void vctDynamicNArrayRef< _elementType, _dimension >::SliceOf ( vctDynamicNArrayBase< __ownerType, _elementType, DIMENSION+1 > &  otherNArray,
dimension_type  dimension,
size_type  index 
) [inline]

Set a reference to an (n-1)-dimension slice of an n-dimension nArray.

Parameters:
otherNArray the nArray over which to set this reference
dimension the dimension number of the direction by which to reduce
slice the index number in the dimension specified by which to set the reference
Note:
The number of dimensions is reduced by one.

Definition at line 249 of file vctDynamicNArrayRef.h.

References vctDynamicNArrayBase< _nArrayOwnerType, _elementType, _dimension >::Pointer(), vctDynamicNArrayRef< _elementType, _dimension >::SetRef(), vctDynamicConstNArrayBase< _nArrayOwnerType, _elementType, _dimension >::sizes(), vctDynamicConstNArrayBase< vctDynamicNArrayRefOwner< _elementType, _dimension >, _elementType, _dimension >::sizes(), vctDynamicConstNArrayBase< vctDynamicNArrayRefOwner< _elementType, _dimension >, _elementType, _dimension >::strides(), and vctDynamicConstNArrayBase< _nArrayOwnerType, _elementType, _dimension >::strides().

template<class _elementType, vct::size_type _dimension>
template<class __ownerType>
void vctDynamicNArrayRef< _elementType, _dimension >::SetRef ( vctDynamicConstVectorBase< __ownerType, _elementType > &  vector  )  [inline]

Set a reference to a dynamic vector. The reference will have identical size and stride as the input vector.

Definition at line 306 of file vctDynamicNArrayRef.h.

References vctDynamicConstVectorBase< _vectorOwnerType, _elementType >::Pointer(), vctDynamicNArrayRef< _elementType, _dimension >::SetRef(), vctDynamicConstVectorBase< _vectorOwnerType, _elementType >::size(), and vctDynamicConstVectorBase< _vectorOwnerType, _elementType >::stride().

template<class _elementType, vct::size_type _dimension>
template<size_type __size, stride_type __stride, typename __dataPtrType>
void vctDynamicNArrayRef< _elementType, _dimension >::SetRef ( vctFixedSizeConstVectorBase< __size, __stride, _elementType, __dataPtrType > &  vector  )  [inline]

Set a reference to a fixed-size vector. The reference will have identical size and stride as the input vector.

Definition at line 315 of file vctDynamicNArrayRef.h.

References vctFixedSizeConstVectorBase< _size, _stride, _elementType, _dataPtrType >::Pointer(), and vctDynamicNArrayRef< _elementType, _dimension >::SetRef().

template<class _elementType, vct::size_type _dimension>
template<class __ownerType>
void vctDynamicNArrayRef< _elementType, _dimension >::SetRef ( vctDynamicConstMatrixBase< __ownerType, _elementType > &  matrix  )  [inline]

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

Definition at line 324 of file vctDynamicNArrayRef.h.

References vctDynamicConstMatrixBase< _matrixOwnerType, _elementType >::col_stride(), vctDynamicConstMatrixBase< _matrixOwnerType, _elementType >::cols(), vctDynamicConstMatrixBase< _matrixOwnerType, _elementType >::Pointer(), vctDynamicConstMatrixBase< _matrixOwnerType, _elementType >::row_stride(), vctDynamicConstMatrixBase< _matrixOwnerType, _elementType >::rows(), and vctDynamicNArrayRef< _elementType, _dimension >::SetRef().

template<class _elementType, vct::size_type _dimension>
template<size_type __rows, size_type __cols, stride_type __rowStride, stride_type __colStride, typename __dataPtrType>
void vctDynamicNArrayRef< _elementType, _dimension >::SetRef ( vctFixedSizeConstMatrixBase< __rows, __cols, __rowStride, __colStride, _elementType, __dataPtrType > &  matrix  )  [inline]

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

Definition at line 335 of file vctDynamicNArrayRef.h.

References vctDynamicNArrayRef< _elementType, _dimension >::SetRef().

template<class _elementType, vct::size_type _dimension>
ThisType& vctDynamicNArrayRef< _elementType, _dimension >::operator= ( const value_type &  value  )  [inline]

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

Definition at line 366 of file vctDynamicNArrayRef.h.

References vctDynamicNArrayBase< vctDynamicNArrayRefOwner< _elementType, _dimension >, _elementType, _dimension >::SetAll().


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