Machine Learning Library
|
Template object for vectors of single and double precision and integer. More...
#include <CDenseVector.h>
Public Member Functions | |
CDenseVector (int iDim=0) | |
CDenseVector (int iDim, const Type *ptData) | |
CDenseVector (int iDim, Type tValue) | |
CDenseVector (const vector< Type > &rtVec) | |
CDenseVector (const CDenseVector< Type > &tVec) | |
CDenseVector (const CVector< Type > &vec) | |
virtual string | className () const |
Returns the class name. More... | |
virtual | ~CDenseVector () |
CVector< Type > * | clone () const |
destructor More... | |
void | zeros (void) |
void | ones (void) |
CVector< double > * | toDouble () const |
CVector< float > * | toFloat () const |
vector< Type > | toSTL () const |
CDenseVector< int > | sort () |
CDenseVector< Type > & | operator= (const CDenseVector< Type > &tSrc) |
int | dimension () const |
CMatrix< Type > | asMatrix () const |
Type | getElement (int iIndex) const |
const Type & | operator[] (int i) const |
return constant reference to n'th vector element More... | |
Type & | operator[] (int i) |
void | setElement (int iIndex, Type tValue) |
void | resize (int iNewDim) |
void | operator+= (Type tScalar) |
bool | isNaN () const |
CVector< Type > & | operator*= (const CVector< Type > &v2) |
CVector< Type > & | operator/= (const CVector< Type > &v2) |
virtual CVector< Type > & | operator*= (const Type &) |
multiply every element with scalar More... | |
virtual CVector< Type > & | operator/= (const Type &) |
divide every element by scalar More... | |
void | operator-= (Type tScalar) |
CDenseVector< Type > & | operator+= (const CVector< Type > &tVec) |
CDenseVector< Type > & | operator-= (const CVector< Type > &tVec) |
Type | manhattenDistance (const CDenseVector< Type > &rtVec) const |
Type | maximumDistance (const CDenseVector< Type > &rtVec) const |
Type | sumElements () const |
void | cat (const CDenseVector< Type > &tVec) |
Type | minElement () const |
Type | maxElement () const |
int | minElementIndex () const |
int | maxElementIndex () const |
CDenseVector< Type > | squareroot () const |
CDenseVector< Type > | power (int iPower=2) const |
CDenseVector< Type > | maxElements (const CDenseVector< Type > &rtVec) const |
CDenseVector< Type > | minElements (const CDenseVector< Type > &rtVec) const |
CDenseVector< Type > | subVector (int iStart, int iElements) const |
Type | mean () const |
Type | stdDev () const |
CDenseVector< Type > | shiftLeft (int iNumElements=1) |
CDenseVector< Type > | shiftRight (int iNumElements=1) |
CDenseVector< Type > | scale (const CDenseVector< Type > &tCurrentMin, const CDenseVector< Type > &tCurrentMax, const CDenseVector< Type > &tNewMin, const CDenseVector< Type > &tNewMax) const |
int | importFromMatFile (const char *acPath, const char *acVarname) |
bool | exportToMatFile (const char *acPath, const char *acVarname, bool bAppend) |
void | dump (ostream &ostr=cout) const |
Type * | _data () const |
void | _setData (Type *ptNewData) |
bool | serialize (fstream &stream, IO_MODE mode=READ) |
Read/write from binary stream. More... | |
bool | serialize2 (CArchiv &tA) |
bool | isSparse () const |
int | getNumNonZero () const |
returns the number of non-zero entries More... | |
Type | euclideanLength (bool bQuad=false) const |
returns euclidean length of vector More... | |
Type * | begin () |
Type * | end () |
Type const * | begin () const |
Type const * | end () const |
![]() | |
virtual | ~CVector () |
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... | |
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) |
![]() | |
CObject () | |
Constructor. More... | |
virtual | ~CObject () |
Destructor. More... | |
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... | |
Protected Member Functions | |
void | copy (const CVector< Type > &vec) |
Protected Attributes | |
int | iDim |
Type * | ptData |
![]() | |
unsigned char | ucVerbose |
Additional Inherited Members | |
![]() | |
static const CVectorOperations < Type > & | op_table |
Template object for vectors of single and double precision and integer.
|
explicit |
Constructor – Constructs a new instance of a vector object.
iDim | Dimension of vector. |
CDenseVector< Type >::CDenseVector | ( | int | iDim, |
const Type * | ptData | ||
) |
Constructor – Constructs a new instance of a vector object.
iDim | Dimension of vector (default 1). |
ptData | Array of dimension iDim with initial data |
CDenseVector< Type >::CDenseVector | ( | int | iDim, |
Type | tValue | ||
) |
Constructor – Constructs a new instance of a vector object. Each element is initialized with value of tValue.
iDim | Dimension of vector (default 1). |
ptData | Array of dimension iDim with initial data (default: NULL) |
CDenseVector< Type >::CDenseVector | ( | const vector< Type > & | rtVec | ) |
Constructor – Constructs a new vector instance of a vector. The vector is initialized with the values from a stl vector.
rtVec | Reference on a stl vector to clone. |
CDenseVector< Type >::CDenseVector | ( | const CDenseVector< Type > & | tVec | ) |
Constructor – Constructs a new vector instance which is an exact clone of a second vector.
tVec | Reference on vector to clone. |
CDenseVector< Type >::CDenseVector | ( | const CVector< Type > & | vec | ) |
|
virtual |
Destructor
|
inline |
Return pointer to data array. NO FORGET IT, DON'T USE IT !!
void CDenseVector< Type >::_setData | ( | Type * | ptNewData | ) |
CMatrix<Type> CDenseVector< Type >::asMatrix | ( | ) | const |
Returns vector as dim x 1 matrix.
|
inline |
|
inline |
void CDenseVector< Type >::cat | ( | const CDenseVector< Type > & | tVec | ) |
Append vector
|
inlinevirtual |
Returns the class name.
Reimplemented from CVector< Type >.
|
virtual |
|
protected |
|
inlinevirtual |
void CDenseVector< Type >::dump | ( | ostream & | ostr = cout | ) | const |
Sets the elements of the vector to zero Makes a dump of the vector to Sets the elements of the vector to zero
|
inline |
|
inline |
|
virtual |
returns euclidean length of vector
Implements CVector< Type >.
bool CDenseVector< Type >::exportToMatFile | ( | const char * | acPath, |
const char * | acVarname, | ||
bool | bAppend | ||
) |
Save vector with name acVarname in the MAT-formated file acPath. if bAppend is true, the data is appended to an existing file
|
virtual |
Returns the element of the vector at position iIndex. The index of the vector elements starts with 0.
Implements CVector< Type >.
|
virtual |
returns the number of non-zero entries
Implements CVector< Type >.
int CDenseVector< Type >::importFromMatFile | ( | const char * | acPath, |
const char * | acVarname | ||
) |
Import vector named acVarname from Matlab MAT-formated file acPath
|
virtual |
Checks for NaN elements
Implements CVector< Type >.
|
inline |
Type CDenseVector< Type >::manhattenDistance | ( | const CDenseVector< Type > & | rtVec | ) | const |
Calculates the manhatten distance between two vectors.
Reference | to vector instance B. |
Type CDenseVector< Type >::maxElement | ( | ) | const |
Returns the greatest value of the vector elements.
int CDenseVector< Type >::maxElementIndex | ( | ) | const |
Returns the index of the element containing the smallest value.
CDenseVector<Type> CDenseVector< Type >::maxElements | ( | const CDenseVector< Type > & | rtVec | ) | const |
Returns the vector of componentwise maximum values of two vectors.
Type CDenseVector< Type >::maximumDistance | ( | const CDenseVector< Type > & | rtVec | ) | const |
Calculates the maximum distance between two vectors.
Reference | to vector instance B. |
Type CDenseVector< Type >::mean | ( | ) | const |
Returns the mean value of the vector elements.
Type CDenseVector< Type >::minElement | ( | ) | const |
Returns the smallest value of the vector elements.
int CDenseVector< Type >::minElementIndex | ( | ) | const |
Returns the index of the element containing the smallest value.
CDenseVector<Type> CDenseVector< Type >::minElements | ( | const CDenseVector< Type > & | rtVec | ) | const |
Returns the vector of componentwise maximum values of two vectors.
void CDenseVector< Type >::ones | ( | void | ) |
Initializes all vector elements with 1.
|
inline |
|
virtual |
multiply every element with scalar
Implements CVector< Type >.
void CDenseVector< Type >::operator+= | ( | Type | tScalar | ) |
Adds a scalar to each vector element.
tScalar |
CDenseVector<Type>& CDenseVector< Type >::operator+= | ( | const CVector< Type > & | tVec | ) |
Adds two vectors.
tVec |
void CDenseVector< Type >::operator-= | ( | Type | tScalar | ) |
Subtract scalar from each vector element.
tScalar |
CDenseVector<Type>& CDenseVector< Type >::operator-= | ( | const CVector< Type > & | tVec | ) |
Subtracts two vectors.
tVec |
|
inline |
|
virtual |
divide every element by scalar
Implements CVector< Type >.
CDenseVector<Type>& CDenseVector< Type >::operator= | ( | const CDenseVector< Type > & | tSrc | ) |
Assignment operator – Assigns a vector instance A to a varible B. The dimension of B does not have to match the dimension of B, since the size of B is adjusted according A.
Reference | on vector B. |
|
inlinevirtual |
return constant reference to n'th vector element
Implements CVector< Type >.
|
inline |
Returns a reference on the element of the vector at position iIndex. The index of the vector elements starts with 0.
CDenseVector<Type> CDenseVector< Type >::power | ( | int | iPower = 2 | ) | const |
Return vector of elementwise power.
void CDenseVector< Type >::resize | ( | int | iNewDim | ) |
Resizes dimension of vector. If the new vector is smaller, elements at the end of the vector are removed according the new size. If the new vector is larger, elements with value zero are appended to the existing vector data.
iNewDim | New vector dimension |
CDenseVector<Type> CDenseVector< Type >::scale | ( | const CDenseVector< Type > & | tCurrentMin, |
const CDenseVector< Type > & | tCurrentMax, | ||
const CDenseVector< Type > & | tNewMin, | ||
const CDenseVector< Type > & | tNewMax | ||
) | const |
Scales each element according the give intervall edition. If the current value of element i is in the interval tCurrentMin_i to tCurrentMax_i, the new element value is calculated by scaling tCurrentMin, tCurrentMax to tNewMin, tNewMax.
tCurrentMin,tCurrentMax | Min/max values of the intervals from which each element value can be taken. |
tNewMin,tNewMax | New min/max values for the elementwise intervals. |
|
virtual |
Read/write from binary stream.
The functions handles different data types e.g for reading float objects in a double instance, etc.
fstream | Reference to binary stream |
mode | Switches between reading and writing |
Reimplemented from CVector< Type >.
Referenced by CDataset< Type >::serialize().
|
virtual |
Reimplemented from CObject< Type >.
void CDenseVector< Type >::setElement | ( | int | iIndex, |
Type | tValue | ||
) |
Assigns the element at postion iIndex a new value.
iIndex | Index of element. |
tValue | New value of element. |
Referenced by CDataset< Type >::read().
CDenseVector<Type> CDenseVector< Type >::shiftLeft | ( | int | iNumElements = 1 | ) |
Returns a new vector contraining the elements of the current vector shifted by iNumElements to the left. Elements pushed out at the left end will be inserted at the right end.
Number | of elements to shift. |
CDenseVector<Type> CDenseVector< Type >::shiftRight | ( | int | iNumElements = 1 | ) |
Returns a new vector contraining the elements of the current vector shifted by iNumElements to the right. Elements pushed out at the right end will be inserted at the left end.
Number | of elements to shift. |
|
virtual |
Implements CVector< Type >.
CDenseVector<Type> CDenseVector< Type >::squareroot | ( | ) | const |
Return vector of elementwise squareroot.
Type CDenseVector< Type >::stdDev | ( | ) | const |
Returns the standard deviation of the vector elements.
CDenseVector<Type> CDenseVector< Type >::subVector | ( | int | iStart, |
int | iElements | ||
) | const |
Return a subvector containing iElements elements starting from iStart (inclusive iStart)
Type CDenseVector< Type >::sumElements | ( | ) | const |
Sum of elements
|
virtual |
Returns copy of vector using double values
Implements CVector< Type >.
|
virtual |
Returns copy of vector using float values
Implements CVector< Type >.
|
virtual |
Reimplemented from CVector< Type >.
void CDenseVector< Type >::zeros | ( | void | ) |
Initializes all vector elements with 0.
|
protected |
Referenced by CDenseVector< T >::dimension(), CDenseVector< T >::end(), and CDenseVector< T >::operator[]().
|
protected |