Public Types | Public Member Functions | Public Attributes | Static Private Member Functions | Private Attributes

cmtk::Vector< T > Class Template Reference
[cmtkBase Library]

Numerical vector class. More...

#include <cmtkVector.h>

Collaboration diagram for cmtk::Vector< T >:
Collaboration graph
[legend]

List of all members.

Public Types

typedef Vector< T > Self
 This class.
typedef SmartPointer< SelfSmartPtr
 Smart pointer to igsFloatVector.

Public Member Functions

VectorClone (const size_t len=0, const size_t from=0) const
 Clone (sub)vector.
 ~Vector ()
 Destructor.
VectorSetDim (const size_t dim, const bool zero=true)
 Set vector dimension.
VectorAdjustDimension (const size_t dim, const bool zero=true)
 Adjust vector dimension.
Vectoroperator= (const Vector &other)
 Vector assignment.
void CopyToOffset (const Vector &other, const size_t offs=0, size_t len=0)
 Copy another vector to given offset.
int operator== (const Vector &other) const
 Test for vector equality.
int operator!= (const Vector &other) const
 Test for vector inequality.
EuclidNorm () const
 Calculate Euclid's vector norm.
MaxNorm () const
 Calculate maximum vector norm.
void Clear ()
 Set all vector elements to zero.
void SetAll (const T value)
 Set all vector elements to constant value.
T & operator[] (const size_t index)
 Get vector element by coordinate index.
const T & operator[] (const size_t index) const
 Get constant vector element by coordinate index.
Vector< T > & operator+= (const Vector< T > &delta)
 Increment vector by another.
Vector< T > & operator-= (const Vector< T > &delta)
 Decrement vector by another.
Vector< T > & operator*= (const T a)
 Multiply by a scalar.
void Print (FILE *const fp=NULL, const char *format=" %f") const
void Sort (const size_t from=0, const size_t len=0)
 Sort values in the vector.
Constructors
 Vector (const size_t dim=0, const T value=0)
 Create constant (zero-)vector.
 Vector (const size_t dim, T *const elements, const bool freeElements=true)
 Create vector from existing array.
 Vector (const Vector &other, const size_t len=0, const size_t from=0)
 Create vector from other vector (also subvector).

Public Attributes

size_t Dim
 Vector dimension.
T * Elements
 Vector elements.

Static Private Member Functions

static int Compare (const void *a, const void *b)
 Compare two vector elements; this is needed for sorting.

Private Attributes

bool FreeElements
 Flag for memory deallocation of value array.

Detailed Description

template<class T>
class cmtk::Vector< T >

Numerical vector class.

Author:
Torsten Rohlfing

Definition at line 61 of file cmtkVector.h.


Member Typedef Documentation

template<class T>
typedef Vector<T> cmtk::Vector< T >::Self

This class.

Definition at line 71 of file cmtkVector.h.

template<class T>
typedef SmartPointer<Self> cmtk::Vector< T >::SmartPtr

Smart pointer to igsFloatVector.

Definition at line 74 of file cmtkVector.h.


Constructor & Destructor Documentation

template<class T>
cmtk::Vector< T >::Vector ( const size_t  dim = 0,
const T  value = 0 
) [inline]

Create constant (zero-)vector.

Definition at line 79 of file cmtkVector.h.

template<class T>
cmtk::Vector< T >::Vector ( const size_t  dim,
T *const   elements,
const bool  freeElements = true 
) [inline]

Create vector from existing array.

Definition at line 101 of file cmtkVector.h.

template<class T>
cmtk::Vector< T >::Vector ( const Vector< T > &  other,
const size_t  len = 0,
const size_t  from = 0 
) [inline]

Create vector from other vector (also subvector).

Definition at line 109 of file cmtkVector.h.

template<class T>
cmtk::Vector< T >::~Vector (  ) [inline]

Destructor.

Definition at line 129 of file cmtkVector.h.


Member Function Documentation

template<class T>
Vector& cmtk::Vector< T >::AdjustDimension ( const size_t  dim,
const bool  zero = true 
) [inline]

Adjust vector dimension.

Unlike SetDim(), this function preserves the values of elements in the vector if they are still in the valid index range after size adjustment.

Parameters:
dimThe number of elements to be stored in this vector after returning from this function.
zeroIf this parameter is true, all new vector elements are set to the zero value in their respective data type.
Returns:
A reference to this object after changing the dimension.

Definition at line 184 of file cmtkVector.h.

Referenced by cmtk::Xform::GetParamVector().

template<class T>
void cmtk::Vector< T >::Clear (  ) [inline]

Set all vector elements to zero.

Definition at line 299 of file cmtkVector.h.

Referenced by cmtk::GroupwiseRegistrationFunctionalBase::ForceZeroSumGradient().

template<class T>
Vector* cmtk::Vector< T >::Clone ( const size_t  len = 0,
const size_t  from = 0 
) const [inline]

Clone (sub)vector.

Definition at line 123 of file cmtkVector.h.

template<class T>
static int cmtk::Vector< T >::Compare ( const void *  a,
const void *  b 
) [inline, static, private]

Compare two vector elements; this is needed for sorting.

Definition at line 403 of file cmtkVector.h.

template<class T>
void cmtk::Vector< T >::CopyToOffset ( const Vector< T > &  other,
const size_t  offs = 0,
size_t  len = 0 
) [inline]

Copy another vector to given offset.

Parameters:
otherVector from which the specified elements are copied.
offsDestination offset. Copying starts at this position in this instance.
lenNumber of elements to be copied. If zero, all elements are copied until the end of one of the vectors is reached.

Definition at line 241 of file cmtkVector.h.

Referenced by cmtk::SymmetricElasticFunctional_Template< VM >::GetParamVector(), cmtk::ImagePairSymmetricNonrigidRegistrationFunctionalTemplate< VM, W >::GetParamVector(), and cmtk::Xform::GetParamVector().

template<class T>
T cmtk::Vector< T >::EuclidNorm (  ) const [inline]

Calculate Euclid's vector norm.

Definition at line 269 of file cmtkVector.h.

Referenced by cmtk::ActiveShapeModel::Decompose(), and cmtk::BestDirectionOptimizer::Optimize().

template<class T>
T cmtk::Vector< T >::MaxNorm (  ) const [inline]
template<class T>
int cmtk::Vector< T >::operator!= ( const Vector< T > &  other ) const [inline]

Test for vector inequality.

Definition at line 263 of file cmtkVector.h.

template<class T>
Vector<T>& cmtk::Vector< T >::operator*= ( const T  a ) [inline]

Multiply by a scalar.

Definition at line 355 of file cmtkVector.h.

template<class T>
Vector<T>& cmtk::Vector< T >::operator+= ( const Vector< T > &  delta ) [inline]

Increment vector by another.

Definition at line 327 of file cmtkVector.h.

template<class T>
Vector<T>& cmtk::Vector< T >::operator-= ( const Vector< T > &  delta ) [inline]

Decrement vector by another.

Definition at line 341 of file cmtkVector.h.

template<class T>
Vector& cmtk::Vector< T >::operator= ( const Vector< T > &  other ) [inline]

Vector assignment.

Definition at line 213 of file cmtkVector.h.

template<class T>
int cmtk::Vector< T >::operator== ( const Vector< T > &  other ) const [inline]

Test for vector equality.

Definition at line 250 of file cmtkVector.h.

template<class T>
T& cmtk::Vector< T >::operator[] ( const size_t  index ) [inline]

Get vector element by coordinate index.

Definition at line 315 of file cmtkVector.h.

template<class T>
const T& cmtk::Vector< T >::operator[] ( const size_t  index ) const [inline]

Get constant vector element by coordinate index.

Definition at line 321 of file cmtkVector.h.

template<class T>
void cmtk::Vector< T >::Print ( FILE *const   fp = NULL,
const char *  format = " %f" 
) const [inline]

Definition at line 366 of file cmtkVector.h.

template<class T>
void cmtk::Vector< T >::SetAll ( const T  value ) [inline]
template<class T>
Vector& cmtk::Vector< T >::SetDim ( const size_t  dim,
const bool  zero = true 
) [inline]

Set vector dimension.

If the current vector dimension is not equal to the requested dimension, the elements array is deleted and a new one is allocated. In any case, there is no guarantee that the data stored in the vector before this call remains unchanged. This is even true for initial elements.

Parameters:
dimThe number of elements to be stored in this vector after returning from this function.
zeroIf this parameter is true, all vector elements are set to the zero value in their respective data type.
Returns:
A reference to this object after changing the dimension.

Definition at line 148 of file cmtkVector.h.

Referenced by cmtk::ParametricPlane::GetParameters(), cmtk::SymmetricElasticFunctional_Template< VM >::GetParamVector(), cmtk::ImagePairSymmetricNonrigidRegistrationFunctionalTemplate< VM, W >::GetParamVector(), and cmtk::GroupwiseRegistrationFunctionalBase::GetParamVector().

template<class T>
void cmtk::Vector< T >::Sort ( const size_t  from = 0,
const size_t  len = 0 
) [inline]

Sort values in the vector.

Using the two parameters, from and len, this function can be used to sort only a subrange of values in this vector. In particular, it can be used to sort the first len elements if from == 0.

Parameters:
fromIndex of first element in the range to sort.
lenNumber of elements to be sorted.

Definition at line 389 of file cmtkVector.h.

Referenced by cmtk::ReformatVolume::GetTransformedReferenceJacobianAvgThread().


Member Data Documentation

template<class T>
size_t cmtk::Vector< T >::Dim
template<class T>
T* cmtk::Vector< T >::Elements

Vector elements.

Definition at line 68 of file cmtkVector.h.

Referenced by cmtk::CoordMult(), cmtk::Vector< Types::Coordinate >::CopyToOffset(), cmtk::SymmetricElasticFunctional_Template< VM >::EvaluateAt(), cmtk::ImagePairSymmetricNonrigidRegistrationFunctionalTemplate< VM, W >::EvaluateAt(), cmtk::SymmetricElasticFunctional_Template< VM >::EvaluateWithGradient(), cmtk::SplineWarpMultiChannelRegistrationFunctional< TMetricFunctional >::EvaluateWithGradient(), cmtk::SplineWarpGroupwiseRegistrationRMIFunctional::EvaluateWithGradient(), cmtk::SplineWarpCongealingFunctional::EvaluateWithGradient(), cmtk::ParallelElasticFunctional< VM >::EvaluateWithGradient(), cmtk::ImagePairSymmetricNonrigidRegistrationFunctionalTemplate< VM, W >::EvaluateWithGradient(), cmtk::ImagePairNonrigidRegistrationFunctionalTemplate< VM >::EvaluateWithGradient(), cmtk::operator*(), cmtk::operator+(), cmtk::Vector< Types::Coordinate >::operator+=(), cmtk::operator-(), cmtk::Vector< Types::Coordinate >::operator-=(), cmtk::Vector< Types::Coordinate >::operator=(), cmtk::Vector< Types::Coordinate >::operator==(), cmtk::operator>>(), cmtk::ImagePairAffineRegistrationCommandLine::OutputResult(), cmtk::AffineRegistrationCommandLine::OutputResult(), cmtk::ImagePairAffineRegistrationCommandLine::OutputResultParameters(), cmtk::AffineRegistrationCommandLine::OutputResultParameters(), cmtk::Registration2d2d::Register(), cmtk::GroupwiseRegistrationFunctionalBase::SetParamVector(), and cmtk::Vector< Types::Coordinate >::Vector().

template<class T>
bool cmtk::Vector< T >::FreeElements [private]

Flag for memory deallocation of value array.

Definition at line 400 of file cmtkVector.h.


The documentation for this class was generated from the following file:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines