cisst-saw
Loading...
Searching...
No Matches
cisstVector

Files

file  tmp/cisst-saw/cisst/cisstVector/vctContainerTraits.h
 Basic traits for the cisstVector containers.
file  tmp/cisst-saw/cisst/cisstVector/vctForwardDeclarations.h
 Forward declarations and #define for cisstVector.

Classes

class  vctAngleRotation2
 Define a rotation based on an angle for a space of dimension 2. More...
class  vctAxisAngleRotation3< _elementType >
 Define a rotation based on an axis and an angle for a space of dimension 3. More...
class  vctBarycentricVector< _elementType, _size >
class  vctDynamicConstMatrixRef< _elementType >
 Dynamic matrix referencing existing memory (const). More...
class  vctDynamicConstNArrayRef< _elementType, _dimension >
 Dynamic nArray referencing existing memory (const). More...
class  vctDynamicConstVectorRef< _elementType >
 Dynamic vector referencing existing memory (const). More...
class  vctDynamicMatrixRef< _elementType >
 Dynamic matrix referencing existing memory. More...
class  vctDynamicNArrayRef< _elementType, _dimension >
 Dynamic nArray referencing existing memory. More...
class  vctReturnDynamicVector< _elementType >
class  vctDynamicVectorRef< _elementType >
 Dynamic vector referencing existing memory. More...
class  vctDynamicVectorRefOwner< _elementType >
class  vctFixedSizeMatrix< _elementType, _rows, _cols, _rowMajor >
 Implementation of a fixed-size matrix using template metaprogramming. More...
class  vctFixedSizeVector< _elementType, _size >
 Implementation of a fixed-size vector using template metaprogramming. More...
class  vctMatrixRotation2< _elementType >
 Define a rotation matrix for a space of dimension 2. More...
class  vctMatrixRotation3< _elementType, _rowMajor >
 Define a rotation matrix for a space of dimension 3. More...
class  vctMatrixRotation3ConstRef< _elementType, _rowStride, _colStride >
 Define a rotation matrix for a space of dimension 3. More...
class  vctMatrixRotation3Ref< _elementType, _rowStride, _colStride >
 Define a rotation matrix for a space of dimension 3. More...
class  vctQuaternion< _elementType >
 Define a quaternion container. More...
class  vctQuaternionRotation3< _elementType >
 Define a rotation quaternion for a space of dimension 3. More...
class  vctRodriguezRotation3< _elementType >
 Define a rotation based on the rodriguez representation for a space of dimension 3. This representation is based on a vector. The direction of the vector determines the axis of rotation and its norm defines the amplitude of the rotation. More...

Functions

 vctDynamicMatrix ()
 A matrix object of dynamic size.
 VCT_CONTAINER_TRAITS_TYPEDEFS (_elementType)
 An nArray object of dynamic size.
 vctDynamicVector ()
 A vector object of dynamic size.
 vctFixedSizeConstVectorRef ()
 An implementation of the ``abstract'' vctFixedSizeConstVectorBase.
 vctFixedSizeVectorRef ()
 An implementation of the ``abstract'' vctFixedSizeVectorBase.
template<class _matrixOwnerType, typename _elementType>
void vctRandom (vctDynamicMatrixBase< _matrixOwnerType, _elementType > &matrix, const typename vctDynamicMatrixBase< _matrixOwnerType, _elementType >::value_type min, const typename vctDynamicMatrixBase< _matrixOwnerType, _elementType >::value_type max)
template<class _nArrayOwnerType, typename _elementType, vct::size_type _dimension>
void vctRandom (vctDynamicNArrayBase< _nArrayOwnerType, _elementType, _dimension > &nArray, const typename vctDynamicNArrayBase< _nArrayOwnerType, _elementType, _dimension >::value_type min, const typename vctDynamicNArrayBase< _nArrayOwnerType, _elementType, _dimension >::value_type max)
template<class _vectorOwnerType, typename _elementType>
void vctRandom (vctDynamicVectorBase< _vectorOwnerType, _elementType > &vector, const typename vctDynamicVectorBase< _vectorOwnerType, _elementType >::value_type min, const typename vctDynamicVectorBase< _vectorOwnerType, _elementType >::value_type max)
template<vct::size_type _rows, vct::size_type _cols, vct::stride_type _rowStride, vct::stride_type _colStride, class _elementType, class _dataPtrType>
void vctRandom (vctFixedSizeMatrixBase< _rows, _cols, _rowStride, _colStride, _elementType, _dataPtrType > &matrix, const _elementType min, const _elementType max)
template<vct::size_type _size, vct::stride_type _stride, class _elementType, class _dataPtrType>
void vctRandom (vctFixedSizeVectorBase< _size, _stride, _elementType, _dataPtrType > &vector, const _elementType min, const _elementType max)
template<class _containerType>
void vctRandom (vctMatrixRotation3Base< _containerType > &matrixRotation)

Detailed Description

Vectors and matrices, including all the tools for simple 3D computations. The main features of cisstVector are:

Note
All the classes and global functions of cisstVector start with the prefix vct. To use cisstVector, you can either include a specific file with:
#include <cisstVector/vctXyz.h>
or include all the files with:

Function Documentation

◆ VCT_CONTAINER_TRAITS_TYPEDEFS()

VCT_CONTAINER_TRAITS_TYPEDEFS ( _elementType )

An nArray object of dynamic size.

An implementation of the ``abstract'' vctFixedSizeMatrixBase.

An implementation of the ``abstract'' vctFixedSizeConstMatrixBase.

This class defines a nArray object of dynamic size with memory allocation.

The algebraic operations are mostly inherited from the base classes vctDynamicNArrayBase and vctDynamicConstNArrayBase. Here, we will briefly describe the specific properties of vctDynamicNArray, with a few usage examples.

  1. The class is templated by its element type, that is, the nArray element. Normally, the element should be an arithmetic type, that is, support all the standard arithmetic operations: +, -, *, /, =, ==, <, >, <=, >=, ...
  2. The class is templated by dimension, i.e. for a vector-like nArray the dimension would be 1, 2 for a matrix-like nArray, 3 for a volume, ...
  3. The types nsize_type, nindex_type and nstride_type are defined within the scope of the nArray classes and used in their interfaces to set the sizes, access elements or manipulate the layout.
  4. The class uses dynamically allocated memory, and, more importantly, owns the memory. That is, a vctDynamicNArray object automatically frees the allocated memory it owns when it is destroyed.
  5. To allocate the memory, use one of the following operations.
    // define a typical element type and a couple of useful other types
    typedef double ElementType;
    enum {DIMENSION = 3};
    typedef typename ArrayType::nsize_type SizeType;
    // constructor allocation, empty array
    ArrayType a1;
    // Create an empty nArray and later allocate memory.
    ArrayType a2;
    a2.SetSize(SizeType(5, 7, 8));
    vctRandom(a2, ElementType(0), ElementType(10));
    // Create an nArray of some size and change it later.
    // This operation does not preserve any elements in the resized
    // nArray
    ArrayType a3(SizeType(7, 8, 9));
    a3.SetSize(a2.sizes());
    vctRandom(a3, ElementType(-10), ElementType(0));
    // Store an algebraic result to a new nArray. In this case,
    // memory is allocated by the algebraic operation, and then
    // attached to the nArray object.
    ArrayType a4 = a3 - a2;
    Definition vctForwardDeclarations.h:183
    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
    @ DIMENSION
    Definition vctDynamicConstMatrixBase.h:82
  6. NArray assignment can be facilitated through the Assign method (defined in the base class) or as follows.
    // Initialize all elements to the same value
    ArrayType a5(a3.sizes(), 2.0);
    // Assign one matrix to another.
    nArrayInt.Assign(a5); // preferred syntax
    nArrayInt = a5; // same operation
    vctDynamicNArray()
    Definition vctDynamicNArray.h:137

A few more notes.

  • The elements lie in contiguous increasing memory addresses.
  • There is no direct way of ``disowning'' a vctDynamicNArray, that is taking ownership of its memory.
  • When a function returns an allocating dynamic nArray object, it is better to return a vctReturnDynamicNArray, which is a helper class designed for transfering the ownership of the allocated memory without reallocation.
Parameters
_elementTypethe type of an element in the nArray.
_dimensionthe dimension the multi-dimensional array.
See also
vctDynamicNArrayBase vctDynamicConstNArrayBase */ template<class _elementType, vct::size_type _dimension> class vctDynamicNArray : public vctDynamicNArrayBase<vctDynamicNArrayOwner<_elementType, _dimension>, _elementType, _dimension> {

friend class vctReturnDynamicNArray<_elementType, _dimension>;

public: /* define most types from vctContainerTraits and vctNArrayTraits

This implementations uses a pointer to the matrix beginning as the matrix defining data member. An instantiation of this type can be used as a matrix reference with TransposeRef().

Note that the class provides only const operations, except for assigning the matrix start, which does not affect the matrix. This is despite the fact that the stored pointer is non-const.

See the base class (vctFixedSizeConstMatrixBase) for template parameter details. */ template <class _elementType, vct::size_type _rows, vct::size_type _cols, vct::stride_type _rowStride, vct::stride_type _colStride> class vctFixedSizeConstMatrixRef : public vctFixedSizeConstMatrixBase <_rows, _cols,_rowStride, _colStride, _elementType, typename vctFixedSizeMatrixTraits<_elementType, _rows, _cols, _rowStride, _colStride>::pointer> { public: /* define most types from vctContainerTraits

This implementations uses a pointer to the matrix beginning as the matrix defining data member. An instantiation of this type can be used as a matrix reference with TransposeRef().

See the base class (vctFixedSizeMatrixBase) for template parameter details.

See also
vctFixedSizeConstMatrixRef */ template <class _elementType, vct::size_type _rows, vct::size_type _cols, vct::stride_type _rowStride, vct::stride_type _colStride> class vctFixedSizeMatrixRef : public vctFixedSizeMatrixBase <_rows, _cols,_rowStride, _colStride, _elementType, typename vctFixedSizeMatrixTraits<_elementType, _rows, _cols, _rowStride, _colStride>::pointer> { public: /* define most types from vctContainerTraits

◆ vctDynamicMatrix()

vctDynamicMatrix ( )

A matrix object of dynamic size.

This class defines a matrix object of dynamic size with memory allocation.

The algebraic operations are mostly inherited from the base classes vctDynamicMatrixBase and vctDynamicConstMatrixBase. Here, we will briefly describe the specific properties of vctDynamicMatrix, with a few usage examples.

  1. The class is templated by its element type, that is, the matrix element. Normally, the element should be an arithmetic type, that is, support all the standard arithmetic operations: +, -, *, /, =, ==, <, >, <=, >=, ...
  2. The class uses dynamically allocated memory, and, more importantly, owns the memory. That is, a vctDynamicMatrix object automatically frees the allocated memory it owns when it is destroyed.
  3. To allocate the memory, use one of the following operations.
    // define a typical element type
    typedef double ElementType;
    // the matrixRows and matrixCols variables can be set to any value at
    // any time before creating the matrix.
    size_t matrixRows = 12;
    size_t matrixCols = 9;
    // constructor allocation
    vctDynamicMatrix<ElementType> m1(matrixRows, matrixCols);
    // Create an empty matrix and later allocate memory.
    m2.SetSize(matrixRows, matrixCols);
    // Create a dynamic matrix of some size and then change it.
    // This operation does not preserve any elements in the resized
    // matrix
    vctDynamicMatrix<Elements> m3(3 * matrixRows, 3 * matrixCols);
    m3.SetSize(2 * matrixRows, 2 * matrixCols);
    // resize a matrix and keep as many elements as possible.
    m3.resize(matrixRows, matrixCols);
    // Store an algebraic result to a new matrix. In this case,
    // memory is allocated by the algebraic operation, and then
    // attached to the matrix object.
    vctDynamicMatrix()
    A matrix object of dynamic size.
    Definition vctDynamicMatrix.h:151
  4. The default storage order is row first. This can be modified using the different constructors as well as the method SetSize with the flags VCT_ROW_MAJOR or VCT_COL_MAJOR.
    // 12 by 7 matrix stored column first
    // a similar matrix filled with zeroes
    // resize the matrix and change its storage order
    m1.SetSize(5, 7, VCT_ROW_MAJOR);
    const bool VCT_COL_MAJOR
    Definition vctForwardDeclarations.h:44
    const bool VCT_ROW_MAJOR
    Definition vctForwardDeclarations.h:41
  5. Matrix assignment can be facilitated through the Assign method (defined in the base class) or as follows.
    // Initialize all elements to the same value
    vctDynamicMatrix<ElementType> v5(matrixRows, matrixCols, 2.0);
    // Initialize the elements by specific values. NOTE: All the
    // arguments MUST be of type ElementType
    matrix.Assign(7.0, 1.0, 2.0, 3.0,
    4.0, 5.0, 6.0, 7.0); // correct
    matrix.Assign(7, 1, 2, 3,
    4, 5, 6, 7); // WRONG, missing dot
    // Assign one matrix to another.
    matrixInt.Assign(matrix);
    matrixInt = matrix; // same operation

A few more notes.

  • The elements lie in contiguous increasing memory addresses.
  • There is no direct way of ``disowning'' a vctDynamicMatrix, that is taking ownership of its memory.
  • When a function returns an allocating dynamic matrix object, it is better to return a vctReturnDynamicMatrix, which is a helper class designed for transfering the ownership of the allocated memory without reallocation.
Parameters
_elementTypethe type of an element in the matrix
See also
vctDynamicMatrixBase vctDynamicConstMatrixBase */ template <class _elementType> class vctDynamicMatrix : public vctDynamicMatrixBase<vctDynamicMatrixOwner<_elementType>, _elementType> {

friend class vctReturnDynamicMatrix<_elementType>;

public: VCT_CONTAINER_TRAITS_TYPEDEFS(_elementType); enum {DIMENSION = 2}; VCT_NARRAY_TRAITS_TYPEDEFS(DIMENSION);

typedef vctDynamicMatrixBase<vctDynamicMatrixOwner<_elementType>, _elementType> BaseType; typedef vctDynamicMatrix<_elementType> ThisType;

/*! Default constructor. Initialize an empty matrix.

◆ vctDynamicVector()

vctDynamicVector ( )

A vector object of dynamic size.

This class defines a vector object of dynamic size with memory allocation. Note that unlike the STL vector class (std::vector), this class is not meant to be used as a dynamic container, but in vector algebra.

The algebraic operations are mostly inherited from the base classes vctDynamicVectorBase and vctDynamicConstVectorBase. Here, we will briefly describe the specific properties of vctDynamicVector, with a few usage examples.

  1. The class is templated by its element type, that is, the vector element. Normally, the element should be an arithmetic type, that is, support all the standard arithmetic operations: +, -, *, /, =, ==, <, >, <=, >=, ...
  2. The class uses dynamically allocated memory, and, more importantly, owns the memory. That is, a vctDynamicVector object automatically frees the allocated memory it owns when it is destroyed.
  3. To allocate the memory, use one of the following operations.
    // define a typical element type
    typedef double ElementType;
    // the vectorSize variable can be set to any value at any time
    // before creating the vector.
    size_t vectorSize = 12;
    // constructor allocation
    // Create an empty vector and later allocate memory.
    v2.SetSize(vectorSize);
    // Create a dynamic vector of some size and then change it.
    // This operation does not preserve any elements in the resized
    // vector
    vctDynamicVector<Elements> v3(3 * vectorSize);
    v3.SetSize(2 * vectorSize);
    // resize a vector and keep as many elements as possible.
    v3.resize(vectorSize);
    // Store an algebraic result to a new vector. In this case,
    // memory is allocated by the algebraic operation, and then
    // attached to the vector object.
    vctDynamicVector()
    A vector object of dynamic size.
    Definition vctDynamicVector.h:139
  4. Vector assignment can be facilitated through the Assign method (defined in the base class) or as follows.
    // Initialize all elements to the same value
    vctDynamicVector<ElementType> v5(vectorSize, 2.0);
    // Initialize the elements by specific value. NOTE: All the
    // arguments MUST be of type ElementType
    1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0);
    // Assign one vector to another. This operation reallocates
    // space for the target vector. Note that the right-hand-side
    // object can be any ``dynamic'' vector of any element type,
    // not just a vctDynamicVector<ElementType>
    vctDynamicMatrix<int> someNumbers(numRows, numCols);
    v1 = someNumbers.Column(2);
    Definition vctForwardDeclarations.h:157

A few more notes.

  • The stride is always 1, that is, the elements lie in contiguous increasing memory addresses.
  • There is no direct way of ``disowning'' a vctDynamicVector, that is taking ownership of its memory.
  • When a function returns an allocating dynamic vector object, it is better to return a vctReturnDynamicVector, which is a helper class designed for transfering the ownership of the allocated memory without reallocation.
Parameters
_elementTypethe type of an element in the vector
See also
vctDynamicVectorBase vctDynamicConstVectorBase */ template <class _elementType> class vctDynamicVector : public vctDynamicVectorBase<vctDynamicVectorOwner<_elementType>, _elementType> {

friend class vctReturnDynamicVector<_elementType>;

public: VCT_CONTAINER_TRAITS_TYPEDEFS(_elementType); typedef vctDynamicVector<_elementType> ThisType; typedef vctDynamicVectorBase<vctDynamicVectorOwner<_elementType>, _elementType> BaseType; typedef typename BaseType::CopyType CopyType; typedef typename BaseType::TypeTraits TypeTraits; typedef typename BaseType::ElementVaArgPromotion ElementVaArgPromotion;

/*! Default constructor. Initialize an empty vector.

◆ vctFixedSizeConstVectorRef()

vctFixedSizeConstVectorRef ( )

An implementation of the ``abstract'' vctFixedSizeConstVectorBase.

This implementations uses a pointer to the vector beginning as the vector defining data member. An instantiation of this type can be used as a subsequence with GetConstSubsequence().

Note that the class provides only const operations, except for assigning the vector start, which does not affect the vector. This is despite the fact that the stored pointer is non-const.

See the base class (vctFixedSizeConstVectorBase) for template parameter details. */ template <class _elementType, vct::size_type _size, vct::stride_type _stride> class vctFixedSizeConstVectorRef : public vctFixedSizeConstVectorBase< _size, _stride, _elementType, typename vctFixedSizeVectorTraits<_elementType, _size, _stride>::pointer > { public: VCT_CONTAINER_TRAITS_TYPEDEFS(_elementType); typedef vctFixedSizeVectorTraits<_elementType, _size, _stride> VectorTraits; typedef vctFixedSizeConstVectorRef<value_type, _size, _stride> ThisType; typedef vctFixedSizeConstVectorBase<_size, _stride, value_type, pointer> BaseType; typedef typename BaseType::CopyType CopyType;

/*! Default constructor: create an uninitialized vector

◆ vctFixedSizeVectorRef()

vctFixedSizeVectorRef ( )

An implementation of the ``abstract'' vctFixedSizeVectorBase.

This implementations uses a pointer to the vector beginning as the vector defining data member. An instantiation of this type can be used as a subsequence with GetSubsequence().

See the base class (vctFixedSizeVectorBase) for template parameter details.

See also
vctFixedSizeConstVectorRef */ template <class _elementType, vct::size_type _size, vct::stride_type _stride> class vctFixedSizeVectorRef : public vctFixedSizeVectorBase< _size, _stride, _elementType, typename vctFixedSizeVectorTraits<_elementType, _size, _stride>::pointer > { public: VCT_CONTAINER_TRAITS_TYPEDEFS(_elementType); typedef vctFixedSizeVectorTraits<_elementType, _size, _stride> VectorTraits; typedef vctFixedSizeVectorRef<value_type, _size, _stride> ThisType; typedef vctFixedSizeVectorBase<_size, _stride, value_type, pointer> BaseType; typedef typename BaseType::CopyType CopyType;

/*! Default constructor: create an uninitialized vector

◆ vctRandom() [1/6]

template<class _matrixOwnerType, typename _elementType>
void vctRandom ( vctDynamicMatrixBase< _matrixOwnerType, _elementType > & matrix,
const typename vctDynamicMatrixBase< _matrixOwnerType, _elementType >::value_type min,
const typename vctDynamicMatrixBase< _matrixOwnerType, _elementType >::value_type max )

Define the global function vctRandom to initialize a dynamic matrix with random elements. The function takes a range from which to choose random elements.

Note
The function uses the global instance of cmnRandomSequence to extract random values. As we have a vague plan to allow for multiple random sequence objects to coexist, these interfaces may need to be changed.

◆ vctRandom() [2/6]

template<class _nArrayOwnerType, typename _elementType, vct::size_type _dimension>
void vctRandom ( vctDynamicNArrayBase< _nArrayOwnerType, _elementType, _dimension > & nArray,
const typename vctDynamicNArrayBase< _nArrayOwnerType, _elementType, _dimension >::value_type min,
const typename vctDynamicNArrayBase< _nArrayOwnerType, _elementType, _dimension >::value_type max )

Define the global function vctRandom to initialize a dynamic nArray with random elements. The function takes a range from which to choose random elements.

Note
The function uses the global instance of cmnRandomSequence to extract random values. As we have a vague plan to allow for multiple random sequence objects to coexist, these interfaces may need to be changed.

◆ vctRandom() [3/6]

template<class _vectorOwnerType, typename _elementType>
void vctRandom ( vctDynamicVectorBase< _vectorOwnerType, _elementType > & vector,
const typename vctDynamicVectorBase< _vectorOwnerType, _elementType >::value_type min,
const typename vctDynamicVectorBase< _vectorOwnerType, _elementType >::value_type max )

Define the global function vctRandom to initialize a dynamic vector with random elements. The function takes a range from which to choose random elements.

Note
The function uses the global instance of cmnRandomSequence to extract random values. As we have a vague plan to allow for multiple random sequence objects to coexist, these interfaces may need to be changed.

◆ vctRandom() [4/6]

template<vct::size_type _rows, vct::size_type _cols, vct::stride_type _rowStride, vct::stride_type _colStride, class _elementType, class _dataPtrType>
void vctRandom ( vctFixedSizeMatrixBase< _rows, _cols, _rowStride, _colStride, _elementType, _dataPtrType > & matrix,
const _elementType min,
const _elementType max )

Define the global function vctRandom to initialize a fixed size matrix with random elements. The function takes a range from which to choose random elements.

Note
The function uses the global instance of cmnRandomSequence to extract random values. As we have a vague plan to allow for multiple random sequence objects to coexist, these interfaces may need to be changed.

◆ vctRandom() [5/6]

template<vct::size_type _size, vct::stride_type _stride, class _elementType, class _dataPtrType>
void vctRandom ( vctFixedSizeVectorBase< _size, _stride, _elementType, _dataPtrType > & vector,
const _elementType min,
const _elementType max )

Define the global function vctRandom to initialize a fixed size vector with random elements. The function takes a range from which to choose random elements.

Note
The function uses the global instance of cmnRandomSequence to extract random values. As we have a vague plan to allow for multiple random sequence objects to coexist, these interfaces may need to be changed.

◆ vctRandom() [6/6]

template<class _containerType>
void vctRandom ( vctMatrixRotation3Base< _containerType > & matrixRotation)

Define the global function vctRandom to initialize different types of transformation with a random value.

Note
The function uses the global instance of cmnRandomSequence to extract random values. As we have a vague plan to allow for multiple random sequence objects to coexist, these interfaces may need to be changed.