Public Member Functions | Static Public Member Functions | Private Member Functions | Static Private Member Functions | Private Attributes | Friends

alize::RealVector< T > Class Template Reference

#include <RealVector.h>

Inheritance diagram for alize::RealVector< T >:
Inheritance graph
[legend]
Collaboration diagram for alize::RealVector< T >:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 RealVector (unsigned long capacity=0, unsigned long size=0)
 RealVector (const RealVector< T > &v)
const RealVector< T > & operator= (const RealVector< T > &v)
const RealVector< T > & operator+= (const RealVector< T > &v)
const RealVector< T > & operator-= (const RealVector< T > &v)
bool operator== (const RealVector< T > &v) const
bool operator!= (const RealVector< T > &v) const
virtual ~RealVector ()
unsigned long size () const
void clear ()
void setSize (const unsigned long size, const bool updateCapacity=false)
void addValue (T v)
void addValue (const RealVector< T > &v)
void setValues (const RealVector< T > &v)
void setAllValues (T v)
computeSum () const
const RealVector< T > & operator*= (double s)
T & operator[] (unsigned long i)
operator[] (unsigned long i) const
void ascendingSort () const
unsigned long getIndexOfLargestValue ()
T * getArray () const
virtual String getClassName () const
virtual String toString () const

Static Public Member Functions

static RealVector< T > & create (unsigned long capacity=0, unsigned long size=0)

Private Member Functions

T * createArray () const

Static Private Member Functions

static int compare (const void *s1, const void *s2)

Private Attributes

unsigned long _size
unsigned long _capacity
T * _array

Friends

class TestDoubleVector
class TestFloatVector
class TestRealVector

Detailed Description

template<class T>
class alize::RealVector< T >

This class implements a growable array of real (float/double) values.

Author:
Frederic Wils frederic.wils@lia.univ-avignon.fr
Version:
1.0
Date:
2003

Definition at line 83 of file RealVector.h.


Constructor & Destructor Documentation

template<class T>
alize::RealVector< T >::RealVector ( unsigned long  capacity = 0,
unsigned long  size = 0 
) [inline, explicit]

Create a vector of type double values.

Parameters:
sizeinitial size of the array
capacitymaximum number of elements in the array
The capacity will grow automatically when the size will overtake the capacity

Definition at line 99 of file RealVector.h.

template<class T>
alize::RealVector< T >::RealVector ( const RealVector< T > &  v ) [inline]

Definition at line 106 of file RealVector.h.

template<class T>
virtual alize::RealVector< T >::~RealVector (  ) [inline, virtual]

Definition at line 171 of file RealVector.h.


Member Function Documentation

template<class T>
void alize::RealVector< T >::addValue ( v ) [inline]

Appends a real data to the end of the vector

Parameters:
vthe real value to add

Definition at line 216 of file RealVector.h.

Referenced by alize::Histo::accumulateValue(), alize::LabelSet::addLabel(), and alize::ViterbiAccum::computeAndAccumulate().

template<class T>
void alize::RealVector< T >::addValue ( const RealVector< T > &  v ) [inline]

Appends a real data vector to the end of the vector

Parameters:
vthe real vector to add

Definition at line 234 of file RealVector.h.

template<class T>
void alize::RealVector< T >::ascendingSort (  ) const [inline]

Sorts the internal vector (ascending)

Definition at line 309 of file RealVector.h.

Referenced by alize::Histo::computeHisto().

template<class T>
void alize::RealVector< T >::clear (  ) [inline]
template<class T>
static int alize::RealVector< T >::compare ( const void *  s1,
const void *  s2 
) [inline, static, private]

Definition at line 372 of file RealVector.h.

template<class T>
T alize::RealVector< T >::computeSum (  ) const [inline]

Computes and returns the sum of all values

Returns:
the sum of all values

Definition at line 267 of file RealVector.h.

template<class T>
static RealVector<T>& alize::RealVector< T >::create ( unsigned long  capacity = 0,
unsigned long  size = 0 
) [inline, static]

Definition at line 113 of file RealVector.h.

template<class T>
T* alize::RealVector< T >::createArray (  ) const [inline, private]

Definition at line 365 of file RealVector.h.

template<class T>
T* alize::RealVector< T >::getArray (  ) const [inline]

Use this method to access directly to the internal vector

Returns:
a pointer on the first element
Warning:
Fast but dangerous ! Use preferably operator [].

Definition at line 339 of file RealVector.h.

Referenced by alize::FrameAcc::computeAll(), alize::DistribGD::computeAll(), alize::DistribGF::computeLK(), alize::DistribGD::computeLK(), alize::DoubleSquareMatrix::invert(), alize::Feature::setData(), and alize::Matrix< T >::transpose().

template<class T>
virtual String alize::RealVector< T >::getClassName (  ) const [inline, virtual]

Returns the name of the class

Returns:
the name of the class of the object as a String

Implements alize::Object.

Definition at line 344 of file RealVector.h.

template<class T>
unsigned long alize::RealVector< T >::getIndexOfLargestValue (  ) [inline]

Returns the index of largest value in the vector

Returns:
the index of the largest value
Exceptions:
Exceptionif the vector is empty

Definition at line 319 of file RealVector.h.

template<class T>
bool alize::RealVector< T >::operator!= ( const RealVector< T > &  v ) const [inline]

Definition at line 166 of file RealVector.h.

template<class T>
const RealVector<T>& alize::RealVector< T >::operator*= ( double  s ) [inline]

Multiplies each value by a scalar

Parameters:
sa scalar
Returns:
this vector

Definition at line 279 of file RealVector.h.

template<class T>
const RealVector<T>& alize::RealVector< T >::operator+= ( const RealVector< T > &  v ) [inline]

Definition at line 137 of file RealVector.h.

template<class T>
const RealVector<T>& alize::RealVector< T >::operator-= ( const RealVector< T > &  v ) [inline]

Definition at line 145 of file RealVector.h.

template<class T>
const RealVector<T>& alize::RealVector< T >::operator= ( const RealVector< T > &  v ) [inline]

Definition at line 121 of file RealVector.h.

template<class T>
bool alize::RealVector< T >::operator== ( const RealVector< T > &  v ) const [inline]

Definition at line 154 of file RealVector.h.

template<class T>
T& alize::RealVector< T >::operator[] ( unsigned long  i ) [inline]

Overloaded operator[] to access an element in the vector.

Parameters:
iindex of the element to access
Returns:
a reference to the element
Exceptions:
IndexOutOfBoundsException

Definition at line 291 of file RealVector.h.

template<class T>
T alize::RealVector< T >::operator[] ( unsigned long  i ) const [inline]

like the other operator[] but for constant RealVector object.

Definition at line 300 of file RealVector.h.

template<class T>
void alize::RealVector< T >::setAllValues ( v ) [inline]

Sets all the values to a a particular value

Parameters:
vthe real value to set

Definition at line 258 of file RealVector.h.

template<class T>
void alize::RealVector< T >::setSize ( const unsigned long  size,
const bool  updateCapacity = false 
) [inline]

Set a new size. If updateCapacity is set to true, update the capacity of the vector (useful to save memory)

Parameters:
sizenew size
updateMemory

Definition at line 191 of file RealVector.h.

Referenced by alize::ViterbiAccum::addState(), alize::DistribGD::computeAll(), alize::DistribGD::getCovVect(), and alize::DistribGD::reset().

template<class T>
void alize::RealVector< T >::setValues ( const RealVector< T > &  v ) [inline]

Sets all the values

Parameters:
vthe vector that contains the values
Exceptions:
Exceptionif vector sizes are different

Definition at line 247 of file RealVector.h.

template<class T>
unsigned long alize::RealVector< T >::size (  ) const [inline]
template<class T>
virtual String alize::RealVector< T >::toString (  ) const [inline, virtual]

This method is frequently overridden in the derived classes. If it is not, it returns the name of the class of the object and the address of the object

Returns:
a description of the object

Reimplemented from alize::Object.

Definition at line 349 of file RealVector.h.


Friends And Related Function Documentation

template<class T>
friend class TestDoubleVector [friend]

Definition at line 85 of file RealVector.h.

template<class T>
friend class TestFloatVector [friend]

Definition at line 88 of file RealVector.h.

template<class T>
friend class TestRealVector [friend]

Definition at line 89 of file RealVector.h.


Member Data Documentation

template<class T>
T* alize::RealVector< T >::_array [private]
template<class T>
unsigned long alize::RealVector< T >::_capacity [private]

Definition at line 362 of file RealVector.h.

template<class T>
unsigned long alize::RealVector< T >::_size [private]

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