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

Class template providing basic vector operations. More...

#include <mdsArray.h>

Inheritance diagram for mds::img::CArray< T >:
Inheritance graph
[legend]

List of all members.

Public Types

enum  { CLASS_VECTOR }
 Templates that require members of the CArray class can use this enum to check the existence. More...
enum  { CLASS_OBJECT }
 Templates that require members of the CObject class can use this enum to check the existence. More...
enum  { HEAP_OBJECT = 0x70616568 }
 Signature used to recognize objects on the heap. More...
typedef mds::math::CVectorBase
< CArray< T > > 
tBase
 Base class.
typedef mds::base::CRefData< T > tDataStorage
 Array data.
typedef T tElement
 Array element type.
typedef CArray< T > tVector
 Vector type.

Public Member Functions

CArrayabs ()
 Absolute value of all elements.
T & at (tSize i)
 Returns reference to the element [i].
const T & at (tSize i) const
 CArray ()
 Declare iterator types tIterator and tConstIterator.
 CArray (tSize Size)
 Constructor.
 CArray (const CArray &Vector, tSize First, tSize Size)
 Constructor.
 CArray (const CArray &Vector, tSize First, tSize Size, EMakeRef)
 Constructor.
 CArray (const CArray &Vector)
 Copy constructor.
 CArray (const CArray &Vector, EMakeRef)
 Copy constructor.
CArrayconcat (const CArray &Vector1, const CArray &Vector2)
 Concatenates two vectors.
template<typename Derived >
CArrayconvert (const mds::math::CVectorBase< Derived > &Vector)
 Conversion between vectors of different type.
template<typename Derived >
CArray< T > & convert (const mds::math::CVectorBase< Derived > &Vector)
CArraycreate (tSize Size)
 Resizes the vector.
CArraycreate (const CArray &Vector, tSize First, tSize Size)
 Re-creates the vector.
CArraycreate (const CArray &Vector, tSize First, tSize Size, EMakeRef)
 Re-creates the vector as a reference to specified data.
CArraycreate (const CArray &Vector)
 Re-creates the vector.
CArraycreate (const CArray &Vector, EMakeRef)
 Re-creates the vector.
CArrayfill (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 the subscripted 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.
CArraylimit (const T &Lower, const T &Upper)
 Limit range of elements.
 MDS_SHAREDPTR (CArray)
 Smart pointer type.
CArraymult (const mds::math::CMatrix< T > &Matrix, const CArray &Vector)
 Matrix vs.
CArraymult (const CArray &Vector, const mds::math::CMatrix< T > &Matrix)
 Row vector vs.
CArraymultAdd (const CArray &Vector, const T &Scalar)
 Provides operation this += Vector * Scalar.
CArrayones ()
 The vector initialization method.
T & operator() (tSize i)
 Returns reference to the subscripted element [i].
const T & operator() (tSize i) const
template<class Derived >
CArrayoperator*= (const mds::math::CVectorBase< Derived > &Vector)
 Element wise product.
template<typename U >
CArrayoperator*= (const CScalar< U > &c)
 Multiplies all elements by scalar.
template<class Derived >
CArray< T > & operator*= (const mds::math::CVectorBase< Derived > &Vector)
template<typename U >
CArray< T > & operator*= (const CScalar< U > &c)
template<class Derived >
CArrayoperator+= (const mds::math::CVectorBase< Derived > &Vector)
 Element wise addition.
template<typename U >
CArrayoperator+= (const CScalar< U > &c)
 Adds scalar to all elements.
template<class Derived >
CArray< T > & operator+= (const mds::math::CVectorBase< Derived > &Vector)
template<typename U >
CArray< T > & operator+= (const CScalar< U > &c)
template<class Derived >
CArrayoperator-= (const mds::math::CVectorBase< Derived > &Vector)
 Element wise subtraction.
template<typename U >
CArrayoperator-= (const CScalar< U > &c)
 Subtracts scalar from all elements.
template<class Derived >
CArray< T > & operator-= (const mds::math::CVectorBase< Derived > &Vector)
template<typename U >
CArray< T > & operator-= (const CScalar< U > &c)
template<class Derived >
CArrayoperator/= (const mds::math::CVectorBase< Derived > &Vector)
 Element wise addition.
template<typename U >
CArrayoperator/= (const CScalar< U > &c)
 Divides all elements by scalar.
template<class Derived >
CArray< T > & operator/= (const mds::math::CVectorBase< Derived > &Vector)
template<typename U >
CArray< T > & operator/= (const CScalar< U > &c)
CArrayoperator= (const CArray &Vector)
 Assignment operator.
template<class Function >
Function pforEach (Function Func)
 Calls a function object for every vector element.
template<class Function >
Function pforEach (Function Func) const
 Calls a function object for every vector element.
template<class Function >
Function pforEach (Function Func)
template<class Function >
Function pforEach (Function Func) const
tVectorset (tSize i, const tElement &Value)
 Sets the vector element at the position [i].
CArrayset (tSize i, const T &Value)
 Sets the vector element at the position [i].
tSize size () const
 Returns the vector size.
CArraysubSample (const CArray &Vector, tSize k=2)
 Initializes this subsampling a given vector.
CArrayzeros ()
 The vector initialization method.
 ~CArray ()
 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

tDataStorage m_DataStorage
 Vector data.
int m_iHeapObject
 Flag initialized if the object is on the heap.
int m_iReferences
 The number of references to the object.
T * m_pData
 Direct pointer to the data.
tSize m_Size
 Vector dimension.
tSize m_Stride
 Stride between two neighbouring vector values.

Detailed Description

template<typename T>
class mds::img::CArray< T >

Class template providing basic vector operations.


Member Typedef Documentation

template<typename T >
typedef mds::math::CVectorBase<CArray<T> > mds::img::CArray< T >::tBase

Base class.

template<typename T >
typedef mds::base::CRefData<T> mds::img::CArray< T >::tDataStorage

Array data.

template<typename T >
typedef T mds::img::CArray< T >::tElement

Array element type.

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

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

Vector type.


Member Enumeration Documentation

template<typename T >
anonymous enum

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

Enumerator:
CLASS_VECTOR 
anonymous enum [inherited]

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

Enumerator:
CLASS_OBJECT 
anonymous enum [inherited]

Signature used to recognize objects on the heap.

Enumerator:
HEAP_OBJECT 

Constructor & Destructor Documentation

template<typename T >
CArray::CArray ( )

Declare iterator types tIterator and tConstIterator.

Default constructor.

template<typename T >
CArray::CArray ( tSize  Size) [explicit]

Constructor.

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

Constructor.

  • Creates subvector of a given vector.
  • Makes a new copy of the data.
template<typename T >
mds::img::CArray< T >::CArray ( const CArray< T > &  Vector,
tSize  First,
tSize  Size,
EMakeRef   
)

Constructor.

  • Creates subvector of a given vector.
  • Makes only reference to the data.
template<typename T >
mds::img::CArray< T >::CArray ( const CArray< T > &  Vector)

Copy constructor.

  • Makes a new copy of the data.
template<typename T >
mds::img::CArray< T >::CArray ( const CArray< T > &  Vector,
EMakeRef   
)

Copy constructor.

  • Makes only reference to the data.
template<typename T >
CArray::~CArray ( )

Destructor.


Member Function Documentation

template<typename T >
CArray< T > & CArray::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 >
T& mds::img::CArray< T >::at ( tSize  i)

Returns reference to the element [i].

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

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

Concatenates two vectors.

  • Returns reference to this.
template<typename T >
template<typename Derived >
CArray< T > & mds::img::CArray< T >::convert ( const mds::math::CVectorBase< Derived > &  Vector)

Conversion between vectors of different type.

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

Resizes the vector.

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

Re-creates the vector.

template<typename T >
CArray< T > & mds::img::CArray< T >::create ( const CArray< T > &  Vector,
tSize  First,
tSize  Size,
EMakeRef   
)

Re-creates the vector as a reference to specified data.

template<typename T >
CArray< T > & mds::img::CArray< T >::create ( const CArray< T > &  Vector)

Re-creates the vector.

  • Makes a new copy of the data.
template<typename T >
CArray< T > & mds::img::CArray< T >::create ( const CArray< T > &  Vector,
EMakeRef   
)

Re-creates the vector.

  • Makes only reference to the data.
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 >
CArray< T > & CArray::fill ( const T &  Value)

Sets vector elements to a given value.

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

Calls a function object for every vector element.

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

template<typename T >
template<class Function >
Function mds::img::CArray< T >::forEach ( Function  Func) const

Calls a function object for every vector element.

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

template<typename T >
template<class Function >
Function mds::img::CArray< T >::forEach ( Function  Func)

Calls a function object for every vector element.

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

template<typename T >
template<class Function >
Function mds::img::CArray< T >::forEach ( Function  Func) const

Calls a function object for every vector element.

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

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

Returns reference to the vector implementation.

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

Returns pointer to the vector data.

template<typename T >
const T* mds::img::CArray< T >::getPtr ( ) const
template<typename T >
T* mds::img::CArray< T >::getPtr ( tSize  i)

Returns pointer to the subscripted element.

template<typename T >
const T* mds::img::CArray< T >::getPtr ( tSize  i) const

Returns the number of references.

template<typename T >
tSize mds::img::CArray< T >::getSize ( ) const

Returns the vector size.

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

template<typename T >
tSize mds::img::CArray< T >::getStride ( ) const

Returns stride between two neigbouring vector elements.

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

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

Returns true if the object is allocated on the heap.

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

Limit range of elements.

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

Smart pointer type.

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

Matrix vs.

column vector multiplication.

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

Row vector vs.

matrix multiplication.

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

Provides operation this += Vector * Scalar.

  • Throws CMultFailed() exception on failure.
  • Returns reference to this.
template<typename T >
CArray< T > & CArray::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::img::CArray< T >::operator() ( tSize  i)

Returns reference to the subscripted element [i].

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

template<typename T >
const T& mds::img::CArray< T >::operator() ( tSize  i) const
template<typename T >
template<class Derived >
CArray< T > & mds::img::CArray< T >::operator*= ( const mds::math::CVectorBase< Derived > &  Vector)

Element wise product.

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

Multiplies all elements by scalar.

template<typename T >
template<class Derived >
CArray<T>& mds::img::CArray< T >::operator*= ( const mds::math::CVectorBase< Derived > &  Vector)
template<typename T >
template<typename U >
CArray<T>& mds::img::CArray< T >::operator*= ( const CScalar< U > &  c)
template<typename T >
template<class Derived >
CArray< T > & mds::img::CArray< T >::operator+= ( const mds::math::CVectorBase< Derived > &  Vector)

Element wise addition.

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

Adds scalar to all elements.

template<typename T >
template<class Derived >
CArray<T>& mds::img::CArray< T >::operator+= ( const mds::math::CVectorBase< Derived > &  Vector)
template<typename T >
template<typename U >
CArray<T>& mds::img::CArray< T >::operator+= ( const CScalar< U > &  c)
template<typename T >
template<class Derived >
CArray< T > & mds::img::CArray< T >::operator-= ( const mds::math::CVectorBase< Derived > &  Vector)

Element wise subtraction.

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

Subtracts scalar from all elements.

template<typename T >
template<class Derived >
CArray<T>& mds::img::CArray< T >::operator-= ( const mds::math::CVectorBase< Derived > &  Vector)
template<typename T >
template<typename U >
CArray<T>& mds::img::CArray< T >::operator-= ( const CScalar< U > &  c)
template<typename T >
template<class Derived >
CArray< T > & mds::img::CArray< T >::operator/= ( const mds::math::CVectorBase< Derived > &  Vector)

Element wise addition.

template<typename T >
template<typename U >
CArray< T > & mds::img::CArray< T >::operator/= ( const CScalar< U > &  c)

Divides all elements by scalar.

template<typename T >
template<class Derived >
CArray<T>& mds::img::CArray< T >::operator/= ( const mds::math::CVectorBase< Derived > &  Vector)
template<typename T >
template<typename U >
CArray<T>& mds::img::CArray< T >::operator/= ( const CScalar< U > &  c)
template<typename T >
CArray< T > & CArray::operator= ( const CArray< T > &  Vector)

Assignment operator.

template<typename T >
template<class Function >
Function mds::img::CArray< T >::pforEach ( Function  Func)

Calls a function object for every vector element.

  • Parallel version.
template<typename T >
template<class Function >
Function mds::img::CArray< T >::pforEach ( Function  Func) const

Calls a function object for every vector element.

  • Parallel version.
template<typename T >
template<class Function >
Function mds::img::CArray< T >::pforEach ( Function  Func)
template<typename T >
template<class Function >
Function mds::img::CArray< T >::pforEach ( Function  Func) const
tVector& mds::math::CVectorBase< CArray< T > >::set ( tSize  i,
const tElement Value 
) [inherited]

Sets the vector element at the position [i].

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

Sets the vector element at the position [i].

template<typename T >
tSize mds::img::CArray< T >::size ( ) const

Returns the vector size.

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

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

Initializes this subsampling a given vector.

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

The vector initialization method.

  • Returns reference to this.

Member Data Documentation

template<typename T >
tDataStorage mds::img::CArray< T >::m_DataStorage [protected]

Vector data.

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 >
T* mds::img::CArray< T >::m_pData [protected]

Direct pointer to the data.

template<typename T >
tSize mds::img::CArray< T >::m_Size [protected]

Vector dimension.

template<typename T >
tSize mds::img::CArray< T >::m_Stride [protected]

Stride between two neighbouring vector values.


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