Vector Class Reference

This class handles basic vector calculations that are needed for the system. More...

List of all members.


Public Member Functions

 Vector (Vector *vect1, Vector *vect2, Vector *vect3)
 Vector (int length=ASR_DEFAULT_VECTORSIZE)
 Vector (int length, double *th)
 Vector (FILE *inFile, int length=ASR_DEFAULT_VECTORSIZE, bool inputIsFloat=false)
 ~Vector ()
double getValue (int element) const
double * getVectorArray () const
int len () const
double calculateEPart (Vector *mean, Vector *variance)
void * getKey ()
void addValue (int element, double val)
void setValue (int element, double val)
void setAllValues (double val)
void isSmaller (Vector *compare, Vector *mask)
void borrowVector (Vector *totVect, int first, int last)
void setAllValues (const Vector *inVector)
double distance (Vector *inVector)
double multiplyVector (Vector *m)
VectormultiplyElements (bool toSelf, Vector *m)
VectordivideElements (bool toSelf, Vector *m)
VectoraddElements (bool toSelf, Vector *m)
VectormultiplyElements (bool toSelf, double m)
VectorsubstractElements (bool toSelf, Vector *m)
VectoraddElements (bool toSelf, double m)
VectorsqrtElements (bool toSelf)
Vectorpow2Elements (bool toSelf)
VectorcopyVector (void)
double getDeterminant (void)
bool checkNegativeElements (void)
bool minimizeElements (double min)
Vectoradapt ()
void storeData (FILE *outFile)
void storeFloatData (FILE *outFile, int maxIndex=-1)
int readData (FILE *inFile)
int readFloatData (FILE *inFile)
VectorgetMaxElement (bool toSelf)
void printVector ()

Protected Attributes

double * theVector
int vectorSize

Detailed Description

This class handles basic vector calculations that are needed for the system.

Audio feature data is stored as a Vector, but also the Gaussian (and MixGaussian) parameters mean and variance are stored in Vector format. All methods are optimized for use in Shout. It is possible to store and load data from disc or send and receive them over a socket connection.


Constructor & Destructor Documentation

Vector::Vector ( Vector vect1,
Vector vect2,
Vector vect3 
)

This constructor will concatinate the two vectors in a new vector.

References theVector, and vectorSize.

Referenced by adapt(), addElements(), copyVector(), divideElements(), getMaxElement(), multiplyElements(), pow2Elements(), sqrtElements(), and substractElements().

Vector::Vector ( int  length = ASR_DEFAULT_VECTORSIZE  ) 

This constructor will initialize the Vector with value 0.0

References setValue(), theVector, and vectorSize.

Here is the call graph for this function:

Vector::Vector ( int  length,
double *  th 
)

This constructor will initialize the Vector with an alternative length and will copy the values of th as values for the vector.

References theVector, and vectorSize.

Vector::Vector ( FILE *  inFile,
int  length = ASR_DEFAULT_VECTORSIZE,
bool  inputIsFloat = false 
)

This constructor will set the vector size and will read the Vector from file.

References readData(), readFloatData(), theVector, and vectorSize.

Here is the call graph for this function:

Vector::~Vector (  ) 

The destructor is empty. No vector data is stored dynamically and therefore no data needs to be deleted.

References theVector.


Member Function Documentation

Vector * Vector::adapt (  ) 

Adapts a vector

References theVector, Vector(), and vectorSize.

Here is the call graph for this function:

Vector* Vector::addElements ( bool  toSelf,
double  m 
) [inline]

The input parameter m (double) is added to all of the values of this Vector object. The results are either stored in a new Vector object, of in the current object, depending on the value of the boolean input variable 'toSelf'.

References theVector, Vector(), and vectorSize.

Here is the call graph for this function:

Vector* Vector::addElements ( bool  toSelf,
Vector m 
) [inline]

All elements of input Vector m are added to the values of this Vector object. The results are either stored in a new Vector object, of in the current object, depending on the value of the boolean input variable 'toSelf'.

References len(), theVector, Vector(), and vectorSize.

Referenced by Gaussian::adapt_setVarTrans(), Gaussian::addAccumulators(), Gaussian::appendSAT(), Gaussian::Gaussian(), MixGaussian::getSumHist(), Gaussian::mapAdaptMean(), Gaussian::moveModel(), Gaussian::printInfo(), Gaussian::shiftMean(), Shout_MakeTrainSet::Shout_MakeTrainSet(), Gaussian::train(), and Gaussian::trainMMI().

Here is the call graph for this function:

void Vector::addValue ( int  element,
double  val 
) [inline]

Adds 'val' to vector element 'element'. The elements from the Vector are in the range of zero to vectorSize-1.

References theVector, and vectorSize.

Referenced by MixGaussian::getSumHist().

void Vector::borrowVector ( Vector totVect,
int  first,
int  last 
) [inline]

Borrows the vector of another object.. Be sure to set it to NULL before you kill this object!

References theVector, and vectorSize.

Referenced by MultiMixGaussian::createVector().

double Vector::calculateEPart ( Vector mean,
Vector variance 
) [inline]

Part of the used formula is: sum of all elements(e) { epow((vector[e]-mean[e])^2 / variance[e] ) } This method calculates this part of the formula for the Gaussian object.

References theVector, and vectorSize.

Referenced by Gaussian::getLogP(), and Gaussian::getP().

bool Vector::checkNegativeElements ( void   )  [inline]

Checks if one of the elements of this Vector is negative. If so, the method returns true, otherwise it returns false.

References theVector, and vectorSize.

Vector* Vector::copyVector ( void   )  [inline]

Makes a copy of the current Vector object and returns it.

References theVector, Vector(), and vectorSize.

Referenced by Gaussian::adapt_adapt(), Gaussian::adapt_setVarTrans(), FeaturePool::fillBuffer_fromFeatureExtraction(), Gaussian::Gaussian(), ShoutOnline::ShoutOnline(), and Gaussian::train().

Here is the call graph for this function:

double Vector::distance ( Vector inVector  )  [inline]

Calculates the distance between the input vector and this vector, using: Sum( (v1[i]-v2[i])^2 )

References len(), theVector, and vectorSize.

Referenced by MixGaussian::fillDistanceArray(), and Gaussian::getCoSim().

Here is the call graph for this function:

Vector* Vector::divideElements ( bool  toSelf,
Vector m 
) [inline]

All elements of this Vector object are divided by the elements of input Vector m. The results are either stored in a new Vector object, of in the current object, depending on the value of the boolean input variable 'toSelf'.

References len(), theVector, Vector(), and vectorSize.

Referenced by Gaussian::adapt_setHelperMatrices(), Gaussian::adapt_setVarTrans(), FeatureExtraction::createFeaturesUntilFrame(), FeatureExtraction::doFeatureExtraction(), FeaturePool::fillBuffer_TextFormat(), FeatureExtraction::finishExtraction(), FeatureExtraction::getOnlineVector(), MixGaussian::getSumHist(), and FeatureExtraction::performClusterCMVNUntilFrame().

Here is the call graph for this function:

double Vector::getDeterminant ( void   )  [inline]

Returns the determinant of the current Vector object.

References theVector, and vectorSize.

Referenced by Gaussian::mapAdaptMean(), Gaussian::trainFinish(), and Gaussian::trainMMI().

void* Vector::getKey (  )  [inline]

Todo:
docs

References theVector.

Referenced by MixGaussian::getP(), and MixGaussian::train().

Vector * Vector::getMaxElement ( bool  toSelf  ) 

Todo:
Docs

References setAllValues(), setValue(), theVector, Vector(), and vectorSize.

Referenced by Gaussian::Gaussian(), and Gaussian::shiftMean().

Here is the call graph for this function:

double* Vector::getVectorArray (  )  const [inline]

References theVector.

Referenced by MixGaussian::getLogP(), and MixGaussian::getP().

void Vector::isSmaller ( Vector compare,
Vector mask 
) [inline]

Todo:
Docs

References theVector, and vectorSize.

bool Vector::minimizeElements ( double  min  )  [inline]

Used in order to make sure that all elements of the Vector are bigger than 'min'. If one of the elements is too small, calculating the determinant will return zero. And dividing by the determinant would mean crashing.. Therefore, elements from the variance Vector may not be too small.

References theVector, and vectorSize.

Referenced by Gaussian::trainFinish(), and Gaussian::trainMMI().

Vector* Vector::multiplyElements ( bool  toSelf,
double  m 
) [inline]

All elements of of this Vector object are multiplied with the input variable m (double). The results are either stored in a new Vector object, of in the current object, depending on the value of the boolean input variable 'toSelf'.

References theVector, Vector(), and vectorSize.

Here is the call graph for this function:

Vector* Vector::multiplyElements ( bool  toSelf,
Vector m 
) [inline]

All elements of input Vector m are multiplied with the values of this Vector object. The results are either stored in a new Vector object, of in the current object, depending on the value of the boolean input variable 'toSelf'.

References len(), theVector, Vector(), and vectorSize.

Referenced by Gaussian::adapt_adaptVar(), Gaussian::adapt_setVarTrans(), FeatureExtraction::createMfccFrame(), Gaussian::Gaussian(), MixGaussian::getSumHist(), Gaussian::mapAdaptMean(), Gaussian::moveModel(), Gaussian::shiftMean(), Gaussian::train(), Gaussian::trainFinish(), and Gaussian::trainMMI().

Here is the call graph for this function:

double Vector::multiplyVector ( Vector m  )  [inline]

This method returns the multiplication of the Vector object and the input parameter Vector m.

References len(), theVector, and vectorSize.

Referenced by Gaussian::getCoSim(), and TrainPhoneModel::train().

Here is the call graph for this function:

Vector* Vector::pow2Elements ( bool  toSelf  )  [inline]

References theVector, Vector(), and vectorSize.

Here is the call graph for this function:

void Vector::printVector (  ) 

Prints the Vector. Only used for debugging purposes.

References getValue(), and vectorSize.

Referenced by FeaturePool::createNewPool(), and Gaussian::printGaussian().

Here is the call graph for this function:

int Vector::readData ( FILE *  inFile  ) 

ReadData() will read Vector data from an open file handler. This function is used to read Vector data embedded in the acoustic model (mean vector of Gaussian etc) It returns the number of bytes actually read.

References WriteFileLittleBigEndian::freadEndianSafe(), theVector, and vectorSize.

Referenced by Vector().

Here is the call graph for this function:

int Vector::readFloatData ( FILE *  inFile  ) 

ReadFloatData() is used to read Vector data from a feature file. In feature files, the vector data is stored as a floating number. Internaly, Vector uses double numbers. It will return the actual number of bytes read.

References WriteFileLittleBigEndian::freadEndianSafe(), theVector, and vectorSize.

Referenced by FeaturePool::readHeader_ShoutFormat(), and Vector().

Here is the call graph for this function:

void Vector::setAllValues ( const Vector inVector  )  [inline]

Sets all vector elements with the same value as in the input vector.

References len(), theVector, and vectorSize.

Here is the call graph for this function:

void Vector::storeData ( FILE *  outFile  ) 

With StoreData(), the vector data is stored to an open file handle. This function is used to store Vector data embedded in the acoustic model (mean vector of Gaussian etc)

References theVector, and vectorSize.

Referenced by MergeTrainSet::MergeTrainSet(), Shout_MakeTrainSet::Shout_MakeTrainSet(), Gaussian::storeData(), Shout_MakeTrainSet::storePhone(), Gaussian::storeSAT(), and Gaussian::writeAccumulators().

void Vector::storeFloatData ( FILE *  outFile,
int  maxIndex = -1 
)

With StoreFloatData(), the vector data is stored to an open file handle. All components are written in 'float' format. This is usefull for storing feature vectors.

References theVector, and vectorSize.

Referenced by FeatureExtraction::doFeatureExtraction(), and FeatureExtraction::storeFeatureVectors().

Vector* Vector::substractElements ( bool  toSelf,
Vector m 
) [inline]

All elements of input Vector m are substracted from the values of this Vector object. The results are either stored in a new Vector object, of in the current object, depending on the value of the boolean input variable 'toSelf'.

References len(), theVector, Vector(), and vectorSize.

Referenced by Gaussian::adapt_setVarTrans(), FeatureExtraction::createFeaturesUntilFrame(), FeatureExtraction::doFeatureExtraction(), FeaturePool::fillBuffer_TextFormat(), FeatureExtraction::finishExtraction(), Gaussian::getCoSim(), FeatureExtraction::getOnlineVector(), MixGaussian::getSumHist(), FeatureExtraction::performClusterCMVNUntilFrame(), Gaussian::train(), Gaussian::trainFinish(), and Gaussian::trainMMI().

Here is the call graph for this function:


Member Data Documentation