Machine Learning Library
Public Member Functions | Static Protected Attributes | List of all members
CVector< Type > Class Template Referenceabstract

templatized vector for numerical applications More...

#include <CMatrix.h>

Inheritance diagram for CVector< Type >:
CObject< Type > CDenseVector< Type > CDenseVector< double > CSparseVector< Type >

Public Member Functions

virtual ~CVector ()
 
virtual CVector< Type > * clone () const =0
 destructor More...
 
virtual CVector< double > * toDouble () const =0
 create a copy with every element stored as 'double' More...
 
virtual CVector< float > * toFloat () const =0
 create a copy with every element stored as 'float' More...
 
virtual vector< Type > toSTL () const
 
virtual CDenseVector< int > sort ()=0
 
virtual bool operator== (const CVector< Type > &rhs) const
 returns true if rhs has the same elements More...
 
Type operator* (const CVector< Type > &) const
 scalar product with vector More...
 
CVector< Type > & operator*= (const CVector< Type > &)
 multiply vectors elementwise More...
 
CVector< Type > & operator/= (const CVector< Type > &)
 divide vectors elementwise More...
 
virtual CVector< Type > & operator*= (const Type &)=0
 multiply every element with scalar More...
 
virtual CVector< Type > & operator/= (const Type &)=0
 divide every element by scalar More...
 
virtual int dimension (void) const =0
 return vector dimension More...
 
virtual int getNumNonZero () const =0
 returns the number of non-zero entries More...
 
virtual bool isNaN () const =0
 returns true if vector contains nan elements More...
 
virtual Type euclideanLength (bool bQuad=false) const =0
 returns euclidean length of vector More...
 
virtual const Type & operator[] (int n) const =0
 return constant reference to n'th vector element More...
 
virtual Type getElement (int n) const =0
 return copy of n'th vector element More...
 
virtual string className () const
 Returns the class name. More...
 
Type euclideanDistance (const CVector< Type > &, bool b=false) const
 
Type coCosineDistance (const CVector< Type > &) const
 returns common cosine distance of the two vectors More...
 
void adaptToVec (const CVector< Type > &, float fEps1, float fEps2)
 
virtual bool serialize (fstream &stream, IO_MODE mode)
 Read/write from binary stream. More...
 
- Public Member Functions inherited from CObject< Type >
 CObject ()
 Constructor. More...
 
virtual ~CObject ()
 Destructor. More...
 
virtual bool serialize2 (CArchiv &tArchiv)
 
void setVerbose (VERBOSE_LEVEL tVerbose)
 Set the verbose level. More...
 
VERBOSE_LEVEL verbose (void) const
 Return current verbose level. More...
 
virtual bool isA (const char *acClass) const
 Check if the object is an instance of the class with given name. More...
 
DATATYPE dataType () const
 Returns the template data type. More...
 

Static Protected Attributes

static const CVectorOperations
< Type > & 
op_table
 

Additional Inherited Members

- Protected Attributes inherited from CObject< Type >
unsigned char ucVerbose
 

Detailed Description

template<class Type>
class CVector< Type >

templatized vector for numerical applications

base class for a generalized vector. specifies all operations that can be performed on a vector of any type.

Constructor & Destructor Documentation

template<class Type>
virtual CVector< Type >::~CVector ( )
inlinevirtual

Member Function Documentation

template<class Type>
void CVector< Type >::adaptToVec ( const CVector< Type > &  ,
float  fEps1,
float  fEps2 
)

adapt vector according to v1 = v1 + eps * (v2-v1)

since v2 might be sparse, we achieve a major speedup, if we formulate the adaptation rule slightly different: v1 = eps2 * v1 + eps1 * v2, where eps2 = 1-eps1

Parameters
v2- vector to adapt to
fEps1- eps1
fEps2- eps2
template<class Type>
virtual string CVector< Type >::className ( ) const
inlinevirtual

Returns the class name.

Reimplemented from CObject< Type >.

Reimplemented in CDenseVector< Type >, CDenseVector< double >, CDenseVector< T >, and CSparseVector< Type >.

template<class Type>
virtual CVector<Type>* CVector< Type >::clone ( ) const
pure virtual
template<class Type>
Type CVector< Type >::coCosineDistance ( const CVector< Type > &  ) const

returns common cosine distance of the two vectors

template<class Type>
virtual int CVector< Type >::dimension ( void  ) const
pure virtual

return vector dimension

Implemented in CDenseVector< Type >, CDenseVector< double >, CDenseVector< T >, and CSparseVector< Type >.

Referenced by operator+(), and operator-().

template<class Type>
Type CVector< Type >::euclideanDistance ( const CVector< Type > &  ,
bool  b = false 
) const

euclidean distance of the two vectors

Parameters
bQuadtrue - return sum of squares; false - return sqrt of that
template<class Type>
virtual Type CVector< Type >::euclideanLength ( bool  bQuad = false) const
pure virtual

returns euclidean length of vector

Implemented in CDenseVector< Type >, CDenseVector< double >, CDenseVector< T >, and CSparseVector< Type >.

template<class Type>
virtual Type CVector< Type >::getElement ( int  n) const
pure virtual

return copy of n'th vector element

Implemented in CDenseVector< Type >, CDenseVector< double >, CDenseVector< T >, and CSparseVector< Type >.

template<class Type>
virtual int CVector< Type >::getNumNonZero ( ) const
pure virtual

returns the number of non-zero entries

Implemented in CDenseVector< Type >, CDenseVector< double >, CDenseVector< T >, and CSparseVector< Type >.

template<class Type>
virtual bool CVector< Type >::isNaN ( ) const
pure virtual

returns true if vector contains nan elements

Implemented in CDenseVector< Type >, CDenseVector< double >, CDenseVector< T >, and CSparseVector< Type >.

template<class Type>
Type CVector< Type >::operator* ( const CVector< Type > &  ) const

scalar product with vector

template<class Type>
CVector<Type>& CVector< Type >::operator*= ( const CVector< Type > &  )

multiply vectors elementwise

Referenced by CSparseVector< Type >::operator*=(), and CDenseVector< T >::operator*=().

template<class Type>
virtual CVector<Type>& CVector< Type >::operator*= ( const Type &  )
pure virtual

multiply every element with scalar

Implemented in CDenseVector< Type >, CDenseVector< T >, and CSparseVector< Type >.

template<class Type>
CVector<Type>& CVector< Type >::operator/= ( const CVector< Type > &  )

divide vectors elementwise

Referenced by CSparseVector< Type >::operator/=(), and CDenseVector< T >::operator/=().

template<class Type>
virtual CVector<Type>& CVector< Type >::operator/= ( const Type &  )
pure virtual

divide every element by scalar

Implemented in CDenseVector< Type >, CDenseVector< T >, and CSparseVector< Type >.

template<class Type>
virtual bool CVector< Type >::operator== ( const CVector< Type > &  rhs) const
virtual

returns true if rhs has the same elements

template<class Type>
virtual const Type& CVector< Type >::operator[] ( int  n) const
pure virtual

return constant reference to n'th vector element

Implemented in CDenseVector< Type >, CDenseVector< double >, CDenseVector< T >, and CSparseVector< Type >.

template<class Type>
virtual bool CVector< Type >::serialize ( fstream &  stream,
IO_MODE  mode 
)
virtual

Read/write from binary stream.

The functions handles different data types e.g for reading float objects in a double instance, etc.

Parameters
fstreamReference to binary stream
modeSwitches between reading and writing
Returns
True if successful, false otherwise

Reimplemented from CObject< Type >.

Reimplemented in CDenseVector< Type >, CDenseVector< double >, and CDenseVector< T >.

template<class Type>
virtual CDenseVector<int> CVector< Type >::sort ( )
pure virtual
template<class Type>
virtual CVector<double>* CVector< Type >::toDouble ( ) const
pure virtual

create a copy with every element stored as 'double'

Implemented in CDenseVector< Type >, CDenseVector< double >, CDenseVector< T >, and CSparseVector< Type >.

template<class Type>
virtual CVector<float>* CVector< Type >::toFloat ( ) const
pure virtual

create a copy with every element stored as 'float'

Implemented in CDenseVector< Type >, CDenseVector< double >, CDenseVector< T >, and CSparseVector< Type >.

template<class Type>
virtual vector<Type> CVector< Type >::toSTL ( ) const
virtual

Member Data Documentation

template<class Type>
const CVectorOperations<Type>& CVector< Type >::op_table
staticprotected

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