Vector Class Reference
This class handles basic vector calculations that are needed for the system. More...
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) |
Vector * | multiplyElements (bool toSelf, Vector *m) |
Vector * | divideElements (bool toSelf, Vector *m) |
Vector * | addElements (bool toSelf, Vector *m) |
Vector * | multiplyElements (bool toSelf, double m) |
Vector * | substractElements (bool toSelf, Vector *m) |
Vector * | addElements (bool toSelf, double m) |
Vector * | sqrtElements (bool toSelf) |
Vector * | pow2Elements (bool toSelf) |
Vector * | copyVector (void) |
double | getDeterminant (void) |
bool | checkNegativeElements (void) |
bool | minimizeElements (double min) |
Vector * | adapt () |
void | storeData (FILE *outFile) |
void | storeFloatData (FILE *outFile, int maxIndex=-1) |
int | readData (FILE *inFile) |
int | readFloatData (FILE *inFile) |
Vector * | getMaxElement (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
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.

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.

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.

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.

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().

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().
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().

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().

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().

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] |
Vector * Vector::getMaxElement | ( | bool | toSelf | ) |
- Todo:
- Docs
References setAllValues(), setValue(), theVector, Vector(), and vectorSize.
Referenced by Gaussian::Gaussian(), and Gaussian::shiftMean().

double Vector::getValue | ( | int | element | ) | const [inline] |
References theVector, and vectorSize.
Referenced by Gaussian::adapt_adapt(), Gaussian::adapt_setHelperMatrices(), Gaussian::calculateCP(), FeatureExtraction::calculateDelta(), FeatureExtraction::createMfccFrame(), FeaturePool::createNewPool(), FeaturePool::getAverageEnergy(), FeaturePool::getCurSegmentEnergy(), Gaussian::getKLDistance(), Gaussian::getNormDistance(), MixGaussian::getSumHist(), MixGaussian::initializeFastCalc(), Train_Segmenter::mergeClusters(), MergeTrainSet::MergeTrainSet(), TrainPhoneModel::normalize(), FeatureExtraction::performHistNormUntilFrame(), Gaussian::printModel(), printVector(), FeaturePool::removeLowEnergy(), SpeakerRecognition::runTrials(), FeaturePool::setFilter(), FeatureExtraction::setNormalization(), ShoutOnline::ShoutOnline(), SpeakerRecognition::SpeakerRecognition(), FeaturePool::splitOnEnergy(), Shout_MakeTrainSet::storePhone(), TrainPhoneModel::train(), and Gaussian::writeAccumulators().
double* Vector::getVectorArray | ( | ) | const [inline] |
int Vector::len | ( | ) | const [inline] |
References vectorSize.
Referenced by Gaussian::adapt_adapt(), Gaussian::adapt_setHelperMatrices(), Gaussian::addAccumulators(), addElements(), Gaussian::appendSAT(), Gaussian::calculateCP(), Gaussian::dim(), distance(), divideElements(), Gaussian::enterTrainingMode(), Gaussian::getCoSim(), Gaussian::getKLDistance(), Gaussian::getNormDistance(), MixGaussian::getSumHist(), Gaussian::mapAdaptMean(), multiplyElements(), multiplyVector(), FeatureExtraction::performHistNormUntilFrame(), Gaussian::printModel(), LexicalTree::processVector_processNodes(), setAllValues(), FeatureExtraction::setNormalization(), MixGaussian::setVariance(), substractElements(), Gaussian::trainFinish(), Gaussian::trainMMI(), and Gaussian::writeAccumulators().
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.

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().

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().

Vector* Vector::pow2Elements | ( | bool | toSelf | ) | [inline] |
void Vector::printVector | ( | ) |
Prints the Vector. Only used for debugging purposes.
References getValue(), and vectorSize.
Referenced by FeaturePool::createNewPool(), and Gaussian::printGaussian().

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().

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().

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.

void Vector::setAllValues | ( | double | val | ) | [inline] |
Sets all vector elements with value 'val'. The elements from the Vector are in the range of zero to vectorSize-1.
References theVector, and vectorSize.
Referenced by Adapt_AM_TreeNode::Adapt_AM_TreeNode(), Gaussian::adapt_clear(), Gaussian::adapt_setHelperMatrices(), Gaussian::enterTrainingMode(), FeatureExtraction::FeatureExtraction(), Gaussian::Gaussian(), Gaussian::getCoSim(), getMaxElement(), MixGaussian::getSumHist(), Gaussian::mapAdaptMean(), FeaturePool::setCurSegmentVector(), Gaussian::setMean(), Gaussian::setVariance(), Shout_MakeTrainSet::Shout_MakeTrainSet(), Gaussian::trainFinish(), and Gaussian::trainMMI().
void Vector::setValue | ( | int | element, | |
double | val | |||
) | [inline] |
Sets vector element 'element' with value 'val'. The elements from the Vector are in the range of zero to vectorSize-1.
References theVector, and vectorSize.
Referenced by Gaussian::adapt_adapt(), FeatureExtraction::calculateDelta(), FeatureExtraction::createFeaturesUntilFrame(), FeatureExtraction::createMfccFrame(), FeatureExtraction::doFeatureExtraction(), FeatureExtraction::FeatureExtraction(), FeaturePool::fillBuffer_TextFormat(), FeatureExtraction::finishClusterCMVN(), FeatureExtraction::finishExtraction(), getMaxElement(), MixGaussian::getSumHist(), Train_Segmenter::mergeClusters(), TrainPhoneModel::normalize(), FeatureExtraction::performHistNormUntilFrame(), FeatureExtraction::performPCA(), SpeakerRecognition::runTrials(), FeatureExtraction::setNormalization(), and Vector().
Vector* Vector::sqrtElements | ( | bool | toSelf | ) | [inline] |
References theVector, Vector(), and vectorSize.
Referenced by FeatureExtraction::createFeaturesUntilFrame(), FeaturePool::createNewPool(), FeatureExtraction::doFeatureExtraction(), FeatureExtraction::finishClusterCMVN(), FeatureExtraction::finishExtraction(), Gaussian::Gaussian(), FeatureExtraction::getOnlineVector(), MixGaussian::getSumHist(), and Gaussian::shiftMean().

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().
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().

Member Data Documentation
double* Vector::theVector [protected] |
Referenced by adapt(), addElements(), addValue(), borrowVector(), calculateEPart(), checkNegativeElements(), copyVector(), distance(), divideElements(), getDeterminant(), getKey(), getMaxElement(), getValue(), getVectorArray(), isSmaller(), minimizeElements(), multiplyElements(), multiplyVector(), pow2Elements(), readData(), readFloatData(), setAllValues(), setValue(), sqrtElements(), storeData(), storeFloatData(), substractElements(), Vector(), and ~Vector().
int Vector::vectorSize [protected] |
Referenced by adapt(), addElements(), addValue(), borrowVector(), calculateEPart(), checkNegativeElements(), copyVector(), distance(), divideElements(), getDeterminant(), getMaxElement(), getValue(), isSmaller(), len(), minimizeElements(), multiplyElements(), multiplyVector(), pow2Elements(), printVector(), readData(), readFloatData(), setAllValues(), setValue(), sqrtElements(), storeData(), storeFloatData(), substractElements(), and Vector().