cisst-saw
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Types | Public Member Functions | List of all members
vctDynamicConstNArrayRef< _elementType, _dimension > Class Template Reference

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

#include <vctDynamicConstNArrayRef.h>

Inheritance diagram for vctDynamicConstNArrayRef< _elementType, _dimension >:
vctDynamicConstNArrayBase< vctDynamicNArrayRefOwner< _elementType, _dimension >, _elementType, _dimension >

Public Types

enum  { DIMENSION = _dimension }
 
typedef
vctDynamicConstNArrayRef
< _elementType, DIMENSION
ThisType
 
typedef
vctDynamicNArrayRefOwner
< _elementType, DIMENSION
NArrayOwnerType
 
typedef
vctDynamicConstNArrayBase
< vctDynamicNArrayRefOwner
< _elementType, DIMENSION >
, _elementType, DIMENSION
BaseType
 
typedef NArrayOwnerType::iterator iterator
 
typedef
NArrayOwnerType::const_iterator 
const_iterator
 
typedef
NArrayOwnerType::reverse_iterator 
reverse_iterator
 
typedef
NArrayOwnerType::const_reverse_iterator 
const_reverse_iterator
 
- Public Types inherited from vctDynamicConstNArrayBase< vctDynamicNArrayRefOwner< _elementType, _dimension >, _elementType, _dimension >
enum  
 
typedef
vctDynamicConstNArrayBase
< vctDynamicNArrayRefOwner
< _elementType, _dimension >
, _elementType, _dimension > 
ThisType
 
typedef
vctDynamicNArrayRefOwner
< _elementType, _dimension > 
OwnerType
 
typedef vctReturnDynamicNArray
< value_type, DIMENSION
NArrayValueType
 
typedef vctDynamicNArray
< value_type, DIMENSION
NArrayReturnType
 
typedef cmnTypeTraits< value_type > TypeTraits
 
typedef TypeTraits::BoolType BoolType
 
typedef vctReturnDynamicNArray
< BoolType, DIMENSION
BoolNArrayReturnType
 
typedef OwnerType::iterator iterator
 
typedef OwnerType::const_iterator const_iterator
 
typedef OwnerType::reverse_iterator reverse_iterator
 
typedef
OwnerType::const_reverse_iterator 
const_reverse_iterator
 
typedef
vctDynamicConstNArrayRef
< value_type, DIMENSION
ConstSubarrayRefType
 
typedef vctDynamicNArrayRef
< value_type, DIMENSION
SubarrayRefType
 
typedef
vctDynamicConstNArrayRef
< value_type, DIMENSION
ConstPermutationRefType
 
typedef vctDynamicNArrayRef
< value_type, DIMENSION
PermutationRefType
 
typedef vctDynamicNArrayTypes
< DIMENSION >::template
SlicesTypes< _elementType > 
SlicesTypes
 
typedef
SlicesTypes::ConstSliceRefType 
ConstSliceRefType
 
typedef SlicesTypes::SliceRefType SliceRefType
 

Public Member Functions

 VCT_CONTAINER_TRAITS_TYPEDEFS (_elementType)
 
 VCT_NARRAY_TRAITS_TYPEDEFS (DIMENSION)
 
 vctDynamicConstNArrayRef ()
 
 vctDynamicConstNArrayRef (const ThisType &other)
 
 vctDynamicConstNArrayRef (const_pointer dataPointer, const nsize_type &sizes, const nstride_type &strides)
 
 vctDynamicConstNArrayRef (pointer dataPointer, const nsize_type &sizes, const nstride_type &strides)
 
template<class __ownerType >
 vctDynamicConstNArrayRef (const vctDynamicConstNArrayBase< __ownerType, value_type, DIMENSION > &otherNArray)
 
template<class __ownerType >
 vctDynamicConstNArrayRef (const vctDynamicConstVectorBase< __ownerType, value_type > &vector)
 
template<size_type __size, stride_type __stride, typename __dataPtrType >
 vctDynamicConstNArrayRef (const vctFixedSizeConstVectorBase< __size, __stride, value_type, __dataPtrType > &vector)
 
template<class __ownerType >
 vctDynamicConstNArrayRef (const vctDynamicConstMatrixBase< __ownerType, value_type > &matrix)
 
template<size_type __rows, size_type __cols, stride_type __rowStride, stride_type __colStride, typename __dataPtrType >
 vctDynamicConstNArrayRef (const vctFixedSizeConstMatrixBase< __rows, __cols, __rowStride, __colStride, value_type, __dataPtrType > &matrix)
 
void SetRef (const_pointer dataPointer, const nsize_type &sizes, const nstride_type &strides)
 
template<class __ownerType >
void SetRef (const vctDynamicConstNArrayBase< __ownerType, value_type, DIMENSION > &otherNArray)
 
template<class __ownerType >
void SubarrayOf (const vctDynamicConstNArrayBase< __ownerType, value_type, DIMENSION > &otherNArray, const nsize_type &startPosition, const nsize_type &lengths)
 
template<class __ownerType >
void PermutationOf (const vctDynamicConstNArrayBase< __ownerType, value_type, DIMENSION > &otherNArray, const ndimension_type &dimensions)
 
template<class __ownerType >
void SliceOf (const vctDynamicConstNArrayBase< __ownerType, value_type, DIMENSION+1 > &otherNArray, dimension_type dimension, size_type index)
 
template<class __ownerType >
void SetRef (const vctDynamicConstVectorBase< __ownerType, value_type > &vector)
 
template<size_type __size, stride_type __stride, typename __dataPtrType >
void SetRef (const vctFixedSizeConstVectorBase< __size, __stride, value_type, __dataPtrType > &vector)
 
template<class __ownerType >
void SetRef (const vctDynamicConstMatrixBase< __ownerType, value_type > &matrix)
 
template<size_type __rows, size_type __cols, stride_type __rowStride, stride_type __colStride, typename __dataPtrType >
void SetRef (const vctFixedSizeConstMatrixBase< __rows, __cols, __rowStride, __colStride, value_type, __dataPtrType > &matrix)
 
- Public Member Functions inherited from vctDynamicConstNArrayBase< vctDynamicNArrayRefOwner< _elementType, _dimension >, _elementType, _dimension >
 VCT_CONTAINER_TRAITS_TYPEDEFS (_elementType)
 
 VCT_NARRAY_TRAITS_TYPEDEFS (_dimension)
 
const_iterator begin (void) const
 
const_iterator end (void) const
 
const_reverse_iterator rbegin (void) const
 
const_reverse_iterator rend (void) const
 
size_type size (void) const
 
size_type size (dimension_type dimension) const
 
const nsize_type & sizes (void) const
 
const nstride_type & strides (void) const
 
difference_type stride (dimension_type dimension) const
 
dimension_type dimension (void) const
 
bool empty (void) const
 
bool ValidDimension (dimension_type dimension) const
 
bool ValidDimensionIndex (dimension_type dimensionIndex) const
 
bool ValidIndex (size_type index) const
 
bool ValidIndex (const nsize_type &indices) const
 
bool ValidIndex (dimension_type dimension, size_type index) const
 
const_reference at (size_type metaIndex) const throw (std::out_of_range)
 
const_reference at (const nsize_type &coordinates) const throw (std::out_of_range)
 
const_reference operator() (const nsize_type &coordinates) const throw (std::out_of_range)
 
const OwnerTypeOwner (void) const
 
const_pointer Pointer (void) const
 
const_pointer Pointer (const nsize_type &indices) const
 
const_reference Element (const nsize_type &coordinates) const
 
ConstSubarrayRefType Subarray (const nsize_type &startPosition, const nsize_type &lengths) const
 
ConstPermutationRefType Permutation (const ndimension_type &dimensions) const
 
ConstSliceRefType Slice (dimension_type dimension, size_type index) const throw (std::runtime_error, std::out_of_range)
 
ConstSliceRefType operator[] (size_type index) const
 
bool FastCopyCompatible (const vctDynamicConstNArrayBase< __nArrayOwnerType, value_type, DIMENSION > &source) const
 
std::string ToString (void)
 
void ToStream (std::ostream &outputStream) const
 
value_type SumOfElements (void) const
 
value_type ProductOfElements (void) const
 
value_type NormSquare (void) const
 
NormType Norm (void) const
 
value_type L1Norm (void) const
 
value_type LinfNorm (void) const
 
value_type MaxElement (void) const
 
value_type MinElement (void) const
 
value_type MaxAbsElement (void) const
 
value_type MinAbsElement (void) const
 
void MinAndMaxElement (value_type &minElement, value_type &maxElement) const
 
bool IsPositive (void) const
 
bool IsNonNegative (void) const
 
bool IsNonPositive (void) const
 
bool IsNegative (void) const
 
bool All (void) const
 
bool Any (void) const
 
bool IsFinite (void) const
 
bool HasNaN (void) const
 
bool IsCompact (void) const
 
bool Equal (const vctDynamicConstNArrayBase< __nArrayOwnerType, value_type, DIMENSION > &otherNArray) const
 
bool operator== (const vctDynamicConstNArrayBase< __nArrayOwnerType, value_type, DIMENSION > &otherNArray) const
 
bool AlmostEqual (const vctDynamicConstNArrayBase< __nArrayOwnerType, value_type, DIMENSION > &otherNArray, value_type tolerance) const
 
bool AlmostEqual (const vctDynamicConstNArrayBase< __nArrayOwnerType, value_type, DIMENSION > &otherNArray) const
 
bool NotEqual (const vctDynamicConstNArrayBase< __nArrayOwnerType, value_type, DIMENSION > &otherNArray) const
 
bool operator!= (const vctDynamicConstNArrayBase< __nArrayOwnerType, value_type, DIMENSION > &otherNArray) const
 
bool Lesser (const vctDynamicConstNArrayBase< __nArrayOwnerType, value_type, DIMENSION > &otherNArray) const
 
bool LesserOrEqual (const vctDynamicConstNArrayBase< __nArrayOwnerType, value_type, DIMENSION > &otherNArray) const
 
bool Greater (const vctDynamicConstNArrayBase< __nArrayOwnerType, value_type, DIMENSION > &otherNArray) const
 
bool GreaterOrEqual (const vctDynamicConstNArrayBase< __nArrayOwnerType, value_type, DIMENSION > &otherNArray) const
 
bool Equal (const value_type &scalar) const
 
bool operator== (const value_type &scalar) const
 
bool NotEqual (const value_type &scalar) const
 
bool operator!= (const value_type &scalar) const
 
bool Lesser (const value_type &scalar) const
 
bool LesserOrEqual (const value_type &scalar) const
 
bool Greater (const value_type &scalar) const
 
bool GreaterOrEqual (const value_type &scalar) const
 
BoolNArrayReturnType ElementwiseEqual (const value_type &scalar) const
 
BoolNArrayReturnType ElementwiseNotEqual (const value_type &scalar) const
 
BoolNArrayReturnType ElementwiseLesser (const value_type &scalar) const
 
BoolNArrayReturnType ElementwiseLesserOrEqual (const value_type &scalar) const
 
BoolNArrayReturnType ElementwiseGreater (const value_type &scalar) const
 
BoolNArrayReturnType ElementwiseGreaterOrEqual (const value_type &scalar) const
 
BoolNArrayReturnType ElementwiseEqual (const vctDynamicConstNArrayBase< __nArrayOwnerType, value_type, DIMENSION > &otherNArray) const
 
BoolNArrayReturnType ElementwiseNotEqual (const vctDynamicConstNArrayBase< __nArrayOwnerType, value_type, DIMENSION > &otherNArray) const
 
BoolNArrayReturnType ElementwiseLesser (const vctDynamicConstNArrayBase< __nArrayOwnerType, value_type, DIMENSION > &otherNArray) const
 
BoolNArrayReturnType ElementwiseLesserOrEqual (const vctDynamicConstNArrayBase< __nArrayOwnerType, value_type, DIMENSION > &otherNArray) const
 
BoolNArrayReturnType ElementwiseGreater (const vctDynamicConstNArrayBase< __nArrayOwnerType, value_type, DIMENSION > &otherNArray) const
 
BoolNArrayReturnType ElementwiseGreaterOrEqual (const vctDynamicConstNArrayBase< __nArrayOwnerType, value_type, DIMENSION > &otherNArray) const
 
NArrayReturnType Abs (void) const
 
NArrayReturnType Negation (void) const
 
NArrayReturnType Floor (void) const
 
NArrayReturnType Ceil (void) const
 

Additional Inherited Members

- Protected Member Functions inherited from vctDynamicConstNArrayBase< vctDynamicNArrayRefOwner< _elementType, _dimension >, _elementType, _dimension >
void ThrowUnlessValidDimensionIndex (dimension_type dimensionIndex) const throw (std::out_of_range)
 
void ThrowUnlessValidIndex (size_type index) const throw (std::out_of_range)
 
void ThrowUnlessValidIndex (const nsize_type &indices) const throw (std::out_of_range)
 
void ThrowUnlessValidIndex (dimension_type dimension, size_type index) const throw (std::out_of_range)
 
- Protected Attributes inherited from vctDynamicConstNArrayBase< vctDynamicNArrayRefOwner< _elementType, _dimension >, _elementType, _dimension >
OwnerType NArray
 

Detailed Description

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

Dynamic nArray referencing existing memory (const)

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

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 elements of a nArray, one can do:

vctRandom(wholeNArray, -10.0, 10.0);
first5x5.SetRef(wholeNArray, size_type(0, 0), size_type(5, 5));
std::cout << first5x5 << " " << first5x5.SumOfElements() << std::endl;
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.
vctDynamicConstNArrayRef 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 vctDynamicNArrayRef.
See Also
vctDynamicNArray, vctDynamicNArrayRef
Parameters
_elementTypeType of elements referenced. Also defined as value_type.
_dimensionDimension of the const nArray ref.

Member Typedef Documentation

template<class _elementType, vct::size_type _dimension>
typedef vctDynamicConstNArrayBase<vctDynamicNArrayRefOwner<_elementType, DIMENSION>, _elementType, DIMENSION> vctDynamicConstNArrayRef< _elementType, _dimension >::BaseType
template<class _elementType, vct::size_type _dimension>
typedef NArrayOwnerType::const_iterator vctDynamicConstNArrayRef< _elementType, _dimension >::const_iterator
template<class _elementType, vct::size_type _dimension>
typedef NArrayOwnerType::const_reverse_iterator vctDynamicConstNArrayRef< _elementType, _dimension >::const_reverse_iterator
template<class _elementType, vct::size_type _dimension>
typedef NArrayOwnerType::iterator vctDynamicConstNArrayRef< _elementType, _dimension >::iterator
template<class _elementType, vct::size_type _dimension>
typedef vctDynamicNArrayRefOwner<_elementType, DIMENSION> vctDynamicConstNArrayRef< _elementType, _dimension >::NArrayOwnerType
template<class _elementType, vct::size_type _dimension>
typedef NArrayOwnerType::reverse_iterator vctDynamicConstNArrayRef< _elementType, _dimension >::reverse_iterator
template<class _elementType, vct::size_type _dimension>
typedef vctDynamicConstNArrayRef<_elementType, DIMENSION> vctDynamicConstNArrayRef< _elementType, _dimension >::ThisType

Member Enumeration Documentation

template<class _elementType, vct::size_type _dimension>
anonymous enum
Enumerator
DIMENSION 

Constructor & Destructor Documentation

template<class _elementType, vct::size_type _dimension>
vctDynamicConstNArrayRef< _elementType, _dimension >::vctDynamicConstNArrayRef ( )
inline
template<class _elementType, vct::size_type _dimension>
vctDynamicConstNArrayRef< _elementType, _dimension >::vctDynamicConstNArrayRef ( const ThisType other)
inline

Copy constructor

template<class _elementType, vct::size_type _dimension>
vctDynamicConstNArrayRef< _elementType, _dimension >::vctDynamicConstNArrayRef ( const_pointer  dataPointer,
const nsize_type &  sizes,
const nstride_type &  strides 
)
inline

Create a reference to a memory location.

Note
see corresponding SetRef method below
template<class _elementType, vct::size_type _dimension>
vctDynamicConstNArrayRef< _elementType, _dimension >::vctDynamicConstNArrayRef ( pointer  dataPointer,
const nsize_type &  sizes,
const nstride_type &  strides 
)
inline

Create a reference to a memory location.

Note
see corresponding SetRef method below
template<class _elementType, vct::size_type _dimension>
template<class __ownerType >
vctDynamicConstNArrayRef< _elementType, _dimension >::vctDynamicConstNArrayRef ( const vctDynamicConstNArrayBase< __ownerType, value_type, DIMENSION > &  otherNArray)
inline

Create a reference to an nArray.

Note
see corresponding SetRef method below
template<class _elementType, vct::size_type _dimension>
template<class __ownerType >
vctDynamicConstNArrayRef< _elementType, _dimension >::vctDynamicConstNArrayRef ( const vctDynamicConstVectorBase< __ownerType, value_type > &  vector)
inline

Create a reference to a dynamic vector.

Note
see corresponding SetRef method below
template<class _elementType, vct::size_type _dimension>
template<size_type __size, stride_type __stride, typename __dataPtrType >
vctDynamicConstNArrayRef< _elementType, _dimension >::vctDynamicConstNArrayRef ( const vctFixedSizeConstVectorBase< __size, __stride, value_type, __dataPtrType > &  vector)
inline

Create a reference to a fixed-size vector.

Note
see corresponding SetRef method below
template<class _elementType, vct::size_type _dimension>
template<class __ownerType >
vctDynamicConstNArrayRef< _elementType, _dimension >::vctDynamicConstNArrayRef ( const vctDynamicConstMatrixBase< __ownerType, value_type > &  matrix)
inline

Create a reference to a dynamic matrix.

Note
see corresponding SetRef method below
template<class _elementType, vct::size_type _dimension>
template<size_type __rows, size_type __cols, stride_type __rowStride, stride_type __colStride, typename __dataPtrType >
vctDynamicConstNArrayRef< _elementType, _dimension >::vctDynamicConstNArrayRef ( const vctFixedSizeConstMatrixBase< __rows, __cols, __rowStride, __colStride, value_type, __dataPtrType > &  matrix)
inline

Create a reference to a fixed-size matrix.

Note
see corresponding SetRef method below

Member Function Documentation

template<class _elementType, vct::size_type _dimension>
template<class __ownerType >
void vctDynamicConstNArrayRef< _elementType, _dimension >::PermutationOf ( const vctDynamicConstNArrayBase< __ownerType, value_type, DIMENSION > &  otherNArray,
const ndimension_type &  dimensions 
)
inline

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

Parameters
otherNArraythe nArray over which to set this reference
dimensionsa sequence of dimension numbers representing the permuted order of strides
Note
Preserves the number of dimensions.
template<class _elementType, vct::size_type _dimension>
void vctDynamicConstNArrayRef< _elementType, _dimension >::SetRef ( const_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.

template<class _elementType, vct::size_type _dimension>
template<class __ownerType >
void vctDynamicConstNArrayRef< _elementType, _dimension >::SetRef ( const vctDynamicConstNArrayBase< __ownerType, value_type, DIMENSION > &  otherNArray)
inline

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

template<class _elementType, vct::size_type _dimension>
template<class __ownerType >
void vctDynamicConstNArrayRef< _elementType, _dimension >::SetRef ( const vctDynamicConstVectorBase< __ownerType, value_type > &  vector)
inline

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

template<class _elementType, vct::size_type _dimension>
template<size_type __size, stride_type __stride, typename __dataPtrType >
void vctDynamicConstNArrayRef< _elementType, _dimension >::SetRef ( const vctFixedSizeConstVectorBase< __size, __stride, value_type, __dataPtrType > &  vector)
inline

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

template<class _elementType, vct::size_type _dimension>
template<class __ownerType >
void vctDynamicConstNArrayRef< _elementType, _dimension >::SetRef ( const vctDynamicConstMatrixBase< __ownerType, value_type > &  matrix)
inline

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

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

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

template<class _elementType, vct::size_type _dimension>
template<class __ownerType >
void vctDynamicConstNArrayRef< _elementType, _dimension >::SliceOf ( const vctDynamicConstNArrayBase< __ownerType, value_type, 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
otherNArraythe nArray over which to set this reference
dimensionthe dimension number of the direction by which to reduce
slicethe index number in the dimension specified by which to set the reference
Note
The number of dimensions is reduced by one.
template<class _elementType, vct::size_type _dimension>
template<class __ownerType >
void vctDynamicConstNArrayRef< _elementType, _dimension >::SubarrayOf ( const vctDynamicConstNArrayBase< __ownerType, value_type, DIMENSION > &  otherNArray,
const nsize_type &  startPosition,
const nsize_type &  lengths 
)
inline

Set a reference to a subarray of an nArray.

Parameters
otherNArraythe nArray over which to set this reference
startPositionvector of indices of the element position where the reference will start
lengthsthe number of elements to reference in each dimension
Note
Preserves the number of dimensions.
template<class _elementType, vct::size_type _dimension>
vctDynamicConstNArrayRef< _elementType, _dimension >::VCT_CONTAINER_TRAITS_TYPEDEFS ( _elementType  )
template<class _elementType, vct::size_type _dimension>
vctDynamicConstNArrayRef< _elementType, _dimension >::VCT_NARRAY_TRAITS_TYPEDEFS ( DIMENSION  )

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