MDSTk Libraries  1.1.0
Medical Data Segmentation Toolkit
Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes
mds::math::CVector< T > Class Template Reference

Class template providing basic dense vector operations. More...

#include <mdsVector.h>

Inheritance diagram for mds::math::CVector< T >:
Inheritance graph
[legend]

List of all members.

Public Types

enum  { CLASS_OBJECT }
 Templates that require members of the CObject class can use this enum to check the existence. More...
enum  { CLASS_VECTOR }
 Templates that require members of the CVector class can use this enum to check the existence. More...
enum  { HEAP_OBJECT = 0x70616568 }
 Signature used to recognize objects on the heap. More...
typedef CVectorBase< CVector< T > > tBase
 Base class.
typedef T tElement
 Vector element type.
typedef Eigen::Matrix
< tElement, Eigen::Dynamic,
1, Eigen::ColMajor|Eigen::AutoAlign > 
tStorage
 Underlying data (see the Eigen math library).
typedef CVector< T > tVector
 Vector type.

Public Member Functions

CVectorabs ()
 Absolute value of all elements.
tStorageasEigen ()
 Returns reference to the underlying data (see the Eigen math library).
const tStorageasEigen () const
T & at (tSize i)
 Returns reference to the element [i].
const T & at (tSize i) const
CVectorconcat (const CVector &Vector1, const CVector &Vector2)
 Concatenates two vectors.
template<typename T >
CVector< T > & create (tSize Size)
CVectorcreate (tSize Size)
 Re-creates the vector of a given length.
template<typename T >
CVector< T > & create (const CVector< T > &Vector, tSize First, tSize Size)
CVectorcreate (const CVector &Vector, tSize First, tSize Size)
 Creates a subvector of a given vector.
template<typename Derived >
CVectorcreate (const CVectorBase< Derived > &Vector)
 Re-creates the vector.
template<typename Derived >
CVectorcreate (const Eigen::MatrixBase< Derived > &Vector)
 Re-creates the vector.
template<typename Derived >
CVector< T > & create (const CVectorBase< Derived > &Vector)
template<typename Derived >
CVector< T > & create (const Eigen::MatrixBase< Derived > &Vector)
template<typename T >
 CVector ()
template<typename T >
 CVector (tSize Size)
template<typename T >
 CVector (const CVector< T > &Vector, tSize First, tSize Size)
template<typename T >
 CVector (const CVector< T > &Vector)
 CVector ()
 Declare iterator types tIterator and tConstIterator.
template<typename Derived >
 CVector (const Eigen::MatrixBase< Derived > &Vector)
 CVector (tSize Size)
 Constructor.
 CVector (const CVector &Vector, tSize First, tSize Size)
 Constructor.
 CVector (const CVector &Vector)
 Copy constructor.
template<typename Derived >
 CVector (const Eigen::MatrixBase< Derived > &Vector)
 Conversion constructor.
CVectorfill (const T &Value)
 Sets vector elements to a given value.
template<class Function >
Function forEach (Function Func)
 Calls a function object for every vector element.
template<class Function >
Function forEach (Function Func) const
 Calls a function object for every vector element.
template<class Function >
Function forEach (Function Func)
 Calls a function object for every vector element.
template<class Function >
Function forEach (Function Func) const
 Calls a function object for every vector element.
tVectorgetImpl ()
 Returns reference to the vector implementation.
const tVectorgetImpl () const
T * getPtr ()
 Returns pointer to the vector data.
const T * getPtr () const
T * getPtr (tSize i)
 Returns pointer to a given element.
const T * getPtr (tSize i) const
int getReferencesCount () const
 Returns the number of references.
tSize getSize () const
 Returns the vector size.
tSize getStride () const
 Returns stride between two neigbouring vector elements.
bool isOnHeap () const
 Returns true if the object is allocated on the heap.
CVectorlimit (const T &Lower, const T &Upper)
 Limit range of elements.
 MDS_SHAREDPTR (CVector)
 Smart pointer type.
CVectormult (const CMatrix< T > &Matrix, const CVector &Vector)
 Matrix vs.
CVectormult (const CVector &Vector, const CMatrix< T > &Matrix)
 Row vector vs.
CVectormultAdd (const CVector &Vector, const T &Scalar)
 Provides operation this += Vector * Scalar.
CVectorones ()
 The vector initialization method.
T & operator() (tSize i)
 Returns reference to the subscripted element [i].
const T & operator() (tSize i) const
template<typename T >
CVector< T > & operator*= (const CVector< T > &Vector)
CVectoroperator*= (const CVector &Vector)
 Element wise product.
template<typename U >
CVectoroperator*= (const CScalar< U > &c)
 Multiplies all elements by scalar.
template<typename U >
CVector< T > & operator*= (const CScalar< U > &c)
template<typename T >
CVector< T > & operator+= (const CVector< T > &Vector)
CVectoroperator+= (const CVector &Vector)
 Element wise addition.
template<typename U >
CVectoroperator+= (const CScalar< U > &c)
 Adds scalar to all elements.
template<typename U >
CVector< T > & operator+= (const CScalar< U > &c)
template<typename T >
CVector< T > & operator-= (const CVector< T > &Vector)
CVectoroperator-= (const CVector &Vector)
 Element wise subtraction.
template<typename U >
CVectoroperator-= (const CScalar< U > &c)
 Subtracts scalar from all elements.
template<typename U >
CVector< T > & operator-= (const CScalar< U > &c)
CVectoroperator/= (const CVector &Vector)
 Element wise addition.
template<typename T >
CVector< T > & operator/= (const CVector< T > &Vector)
template<typename U >
CVectoroperator/= (const CScalar< U > &c)
 Divides all elements by scalar.
template<typename U >
CVector< T > & operator/= (const CScalar< U > &c)
CVectoroperator= (const CVector &Vector)
 Assignment operator.
template<typename Derived >
CVectoroperator= (const Eigen::MatrixBase< Derived > &Vector)
 Assignment operator.
template<typename T >
CVector< T > & operator= (const CVector< T > &Vector)
template<typename Derived >
CVector< T > & operator= (const Eigen::MatrixBase< Derived > &Vector)
tVectorset (tSize i, const tElement &Value)
 Sets the vector element at the position [i].
CVectorset (tSize i, const T &Value)
 Sets the vector element at the position [i].
tSize size () const
 Returns the vector size.
CVectorsubSample (const CVector &Vector, tSize k=2)
 Initializes this subsampling a given vector.
CVectorzeros ()
 The vector initialization method.
 ~CVector ()
 Destructor.

Static Public Member Functions

static void * operator new (std::size_t Size)
 Allocates a new object on the heap.

Protected Member Functions

void addReference () const
 Increase the reference counter.
bool delReference () const
 Decrease the reference counter.

Protected Attributes

int m_iHeapObject
 Flag initialized if the object is on the heap.
int m_iReferences
 The number of references to the object.
tStorage m_Vector
 Vector data.

Detailed Description

template<typename T>
class mds::math::CVector< T >

Class template providing basic dense vector operations.


Member Typedef Documentation

template<typename T>
typedef CVectorBase<CVector<T> > mds::math::CVector< T >::tBase

Base class.

template<typename T>
typedef T mds::math::CVector< T >::tElement

Vector element type.

Reimplemented from mds::math::CVectorBase< CVector< T > >.

template<typename T>
typedef Eigen::Matrix<tElement, Eigen::Dynamic, 1, Eigen::ColMajor | Eigen::AutoAlign> mds::math::CVector< T >::tStorage

Underlying data (see the Eigen math library).

typedef CVector< T > mds::math::CVectorBase< CVector< T > >::tVector [inherited]

Vector type.


Member Enumeration Documentation

anonymous enum [inherited]

Templates that require members of the CObject class can use this enum to check the existence.

Enumerator:
CLASS_OBJECT 
template<typename T>
anonymous enum

Templates that require members of the CVector class can use this enum to check the existence.

Enumerator:
CLASS_VECTOR 
anonymous enum [inherited]

Signature used to recognize objects on the heap.

Enumerator:
HEAP_OBJECT 

Constructor & Destructor Documentation

template<typename T >
mds::math::CVector< T >::CVector ( )

Declare iterator types tIterator and tConstIterator.

Default constructor.

template<typename T >
mds::math::CVector< T >::CVector ( tSize  Size) [explicit]

Constructor.

  • Creates a new vector of a given size.
template<typename T >
mds::math::CVector< T >::CVector ( const CVector< T > &  Vector,
tSize  First,
tSize  Size 
)

Constructor.

  • Creates subvector of a given vector.
  • Makes a new copy of the data.
template<typename T >
mds::math::CVector< T >::CVector ( const CVector< T > &  Vector)

Copy constructor.

  • Makes a new copy of the data.
template<typename T >
template<typename Derived >
mds::math::CVector< T >::CVector ( const Eigen::MatrixBase< Derived > &  Vector)

Conversion constructor.

  • Makes a new copy of the data.
template<typename T >
CVector::~CVector ( )

Destructor.

template<typename T>
template<typename T >
mds::math::CVector< T >::CVector ( )
template<typename T>
template<typename T >
mds::math::CVector< T >::CVector ( tSize  Size)
template<typename T>
template<typename T >
mds::math::CVector< T >::CVector ( const CVector< T > &  Vector,
tSize  First,
tSize  Size 
)
template<typename T>
template<typename T >
mds::math::CVector< T >::CVector ( const CVector< T > &  Vector)
template<typename T>
template<typename Derived >
mds::math::CVector< T >::CVector ( const Eigen::MatrixBase< Derived > &  Vector)

Member Function Documentation

template<typename T >
CVector< T > & CVector::abs ( )

Absolute value of all elements.

  • Returns reference to this.
void mds::base::CObject::addReference ( ) const [protected, inherited]

Increase the reference counter.

template<typename T>
tStorage& mds::math::CVector< T >::asEigen ( )

Returns reference to the underlying data (see the Eigen math library).

template<typename T>
const tStorage& mds::math::CVector< T >::asEigen ( ) const
template<typename T>
T& mds::math::CVector< T >::at ( tSize  i)

Returns reference to the element [i].

Reimplemented from mds::math::CVectorBase< CVector< T > >.

template<typename T>
const T& mds::math::CVector< T >::at ( tSize  i) const
template<typename T >
CVector< T > & CVector::concat ( const CVector< T > &  Vector1,
const CVector< T > &  Vector2 
)

Concatenates two vectors.

  • Returns reference to this.
template<typename T>
template<typename T >
CVector<T>& mds::math::CVector< T >::create ( tSize  Size)
template<typename T >
CVector< T > & mds::math::CVector< T >::create ( tSize  Size)

Re-creates the vector of a given length.

template<typename T>
template<typename T >
CVector<T>& mds::math::CVector< T >::create ( const CVector< T > &  Vector,
tSize  First,
tSize  Size 
)
template<typename T >
CVector< T > & mds::math::CVector< T >::create ( const CVector< T > &  Vector,
tSize  First,
tSize  Size 
)

Creates a subvector of a given vector.

  • Makes a new copy of the data.
template<typename T >
template<typename Derived >
CVector< T > & mds::math::CVector< T >::create ( const CVectorBase< Derived > &  Vector)

Re-creates the vector.

  • Makes a new copy of the data.
template<typename T >
template<typename Derived >
CVector< T > & mds::math::CVector< T >::create ( const Eigen::MatrixBase< Derived > &  Vector)

Re-creates the vector.

  • Makes a new copy of the data.
template<typename T>
template<typename Derived >
CVector<T>& mds::math::CVector< T >::create ( const CVectorBase< Derived > &  Vector)
template<typename T>
template<typename Derived >
CVector<T>& mds::math::CVector< T >::create ( const Eigen::MatrixBase< Derived > &  Vector)
bool mds::base::CObject::delReference ( ) const [protected, inherited]

Decrease the reference counter.

  • Returns true if the decremented number of references is lower or equal to zero and object must be deleted.
template<typename T>
CVector< T > & CVector::fill ( const T &  Value)

Sets vector elements to a given value.

  • Returns reference to this.
template<typename T >
template<class Function >
Function mds::math::CVector< T >::forEach ( Function  Func)

Calls a function object for every vector element.

Reimplemented from mds::math::CVectorBase< CVector< T > >.

template<typename T >
template<class Function >
Function mds::math::CVector< T >::forEach ( Function  Func) const

Calls a function object for every vector element.

Reimplemented from mds::math::CVectorBase< CVector< T > >.

template<typename T>
template<class Function >
Function mds::math::CVector< T >::forEach ( Function  Func)

Calls a function object for every vector element.

Reimplemented from mds::math::CVectorBase< CVector< T > >.

template<typename T>
template<class Function >
Function mds::math::CVector< T >::forEach ( Function  Func) const

Calls a function object for every vector element.

Reimplemented from mds::math::CVectorBase< CVector< T > >.

tVector& mds::math::CVectorBase< CVector< T > >::getImpl ( ) [inherited]

Returns reference to the vector implementation.

const tVector& mds::math::CVectorBase< CVector< T > >::getImpl ( ) const [inherited]
template<typename T>
T* mds::math::CVector< T >::getPtr ( )

Returns pointer to the vector data.

template<typename T>
const T* mds::math::CVector< T >::getPtr ( ) const
template<typename T>
T* mds::math::CVector< T >::getPtr ( tSize  i)

Returns pointer to a given element.

template<typename T>
const T* mds::math::CVector< T >::getPtr ( tSize  i) const

Returns the number of references.

template<typename T>
tSize mds::math::CVector< T >::getSize ( ) const

Returns the vector size.

Reimplemented from mds::math::CVectorBase< CVector< T > >.

template<typename T>
tSize mds::math::CVector< T >::getStride ( ) const

Returns stride between two neigbouring vector elements.

Reimplemented from mds::math::CVectorBase< CVector< T > >.

bool mds::base::CObject::isOnHeap ( ) const [inherited]

Returns true if the object is allocated on the heap.

template<typename T>
CVector< T > & CVector::limit ( const T &  Lower,
const T &  Upper 
)

Limit range of elements.

  • Returns reference to this.
template<typename T>
mds::math::CVector< T >::MDS_SHAREDPTR ( CVector< T >  )

Smart pointer type.

  • Declares type tSmartPtr.
template<typename T>
CVector< T > & mds::math::CVector< T >::mult ( const CMatrix< T > &  Matrix,
const CVector< T > &  Vector 
)

Matrix vs.

column vector multiplication.

  • Throws CMultFailed() exception on failure.
  • Returns reference to this.
template<typename T>
CVector< T > & mds::math::CVector< T >::mult ( const CVector< T > &  Vector,
const CMatrix< T > &  Matrix 
)

Row vector vs.

matrix multiplication.

  • Throws CMultFailed() exception on failure.
  • Returns reference to this.
template<typename T>
CVector< T > & CVector::multAdd ( const CVector< T > &  Vector,
const T &  Scalar 
)

Provides operation this += Vector * Scalar.

  • Throws CMultFailed() exception on failure.
  • Returns reference to this.
template<typename T >
CVector< T > & CVector::ones ( )

The vector initialization method.

  • Returns reference to this.
static void* mds::base::CObject::operator new ( std::size_t  Size) [static, inherited]

Allocates a new object on the heap.

template<typename T>
T& mds::math::CVector< T >::operator() ( tSize  i)

Returns reference to the subscripted element [i].

Reimplemented from mds::math::CVectorBase< CVector< T > >.

template<typename T>
const T& mds::math::CVector< T >::operator() ( tSize  i) const
template<typename T>
template<typename T >
CVector<T>& mds::math::CVector< T >::operator*= ( const CVector< T > &  Vector)
template<typename T >
CVector< T > & mds::math::CVector< T >::operator*= ( const CVector< T > &  Vector)

Element wise product.

template<typename T >
template<typename U >
CVector< T > & mds::math::CVector< T >::operator*= ( const CScalar< U > &  c)

Multiplies all elements by scalar.

template<typename T>
template<typename U >
CVector<T>& mds::math::CVector< T >::operator*= ( const CScalar< U > &  c)
template<typename T>
template<typename T >
CVector<T>& mds::math::CVector< T >::operator+= ( const CVector< T > &  Vector)
template<typename T >
CVector< T > & mds::math::CVector< T >::operator+= ( const CVector< T > &  Vector)

Element wise addition.

template<typename T >
template<typename U >
CVector< T > & mds::math::CVector< T >::operator+= ( const CScalar< U > &  c)

Adds scalar to all elements.

template<typename T>
template<typename U >
CVector<T>& mds::math::CVector< T >::operator+= ( const CScalar< U > &  c)
template<typename T>
template<typename T >
CVector<T>& mds::math::CVector< T >::operator-= ( const CVector< T > &  Vector)
template<typename T >
CVector< T > & mds::math::CVector< T >::operator-= ( const CVector< T > &  Vector)

Element wise subtraction.

template<typename T >
template<typename U >
CVector< T > & mds::math::CVector< T >::operator-= ( const CScalar< U > &  c)

Subtracts scalar from all elements.

template<typename T>
template<typename U >
CVector<T>& mds::math::CVector< T >::operator-= ( const CScalar< U > &  c)
template<typename T >
CVector< T > & mds::math::CVector< T >::operator/= ( const CVector< T > &  Vector)

Element wise addition.

template<typename T>
template<typename T >
CVector<T>& mds::math::CVector< T >::operator/= ( const CVector< T > &  Vector)
template<typename T >
template<typename U >
CVector< T > & mds::math::CVector< T >::operator/= ( const CScalar< U > &  c)

Divides all elements by scalar.

template<typename T>
template<typename U >
CVector<T>& mds::math::CVector< T >::operator/= ( const CScalar< U > &  c)
template<typename T >
CVector< T > & mds::math::CVector< T >::operator= ( const CVector< T > &  Vector)

Assignment operator.

template<typename T >
template<typename Derived >
CVector< T > & mds::math::CVector< T >::operator= ( const Eigen::MatrixBase< Derived > &  Vector)

Assignment operator.

template<typename T>
template<typename T >
CVector<T>& mds::math::CVector< T >::operator= ( const CVector< T > &  Vector)
template<typename T>
template<typename Derived >
CVector<T>& mds::math::CVector< T >::operator= ( const Eigen::MatrixBase< Derived > &  Vector)
tVector& mds::math::CVectorBase< CVector< T > >::set ( tSize  i,
const tElement Value 
) [inherited]

Sets the vector element at the position [i].

template<typename T>
CVector& mds::math::CVector< T >::set ( tSize  i,
const T &  Value 
)

Sets the vector element at the position [i].

template<typename T>
tSize mds::math::CVector< T >::size ( ) const

Returns the vector size.

Reimplemented from mds::math::CVectorBase< CVector< T > >.

template<typename T >
CVector< T > & CVector::subSample ( const CVector< T > &  Vector,
tSize  k = 2 
)

Initializes this subsampling a given vector.

  • Returns reference to this.
template<typename T >
CVector< T > & CVector::zeros ( )

The vector initialization method.

  • Returns reference to this.

Member Data Documentation

int mds::base::CObject::m_iHeapObject [mutable, protected, inherited]

Flag initialized if the object is on the heap.

int mds::base::CObject::m_iReferences [mutable, protected, inherited]

The number of references to the object.

  • Zero if there is no reference.
template<typename T>
tStorage mds::math::CVector< T >::m_Vector [protected]

Vector data.


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