StochHMM  v0.34
Flexible Hidden Markov Model C++ Library and Application
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions | Private Attributes
StochHMM::Index Class Reference

#include <index.h>

List of all members.

Public Member Functions

 Index ()
 Create an index.
 Index (const Index &)
 Create an Index by copy.
 ~Index ()
 Destroy Index.
bool isAmbiguous ()
 Returns whether there is an ambiguous character.
void setAmbiguous (const std::vector< size_t > &)
Indexoperator= (const Index &)
 Set the Index as ambiguous.
Index operator+ (const Index &)
 Assign Index.
void operator+= (const Index &)
 Add Index.
void operator+= (const size_t)
 Add and assign Index.
void operator*= (const size_t)
 Add int to Index.
Index operator* (const size_t)
 Multiply int to Index.
size_t size ()
 Multiply int to Index.
size_t operator[] (const size_t)
 Get Number of indices.

Private Attributes

size_t index
std::vector< size_t > * amb
bool ambiguous

Detailed Description

Definition at line 42 of file index.h.


Constructor & Destructor Documentation

StochHMM::Index::Index ( )

Create an index.

Definition at line 33 of file index.cpp.

References amb, ambiguous, and index.

{
index=0;
amb=NULL;
ambiguous=false;
}
StochHMM::Index::Index ( const Index a)

Create an Index by copy.

Definition at line 40 of file index.cpp.

References amb, ambiguous, and index.

{
index=a.index;
ambiguous=a.ambiguous;
if (amb!=NULL){
amb=new(std::nothrow) std::vector<size_t>(a.amb->size());
if (amb==NULL){
std::cerr << "OUT OF MEMORY\nFile" << __FILE__ << "Line:\t"<< __LINE__ << std::endl;
exit(1);
}
copy( a.amb->begin(), a.amb->end(), amb->begin());
}
}
StochHMM::Index::~Index ( )

Destroy Index.

Definition at line 57 of file index.cpp.

References amb.

{
delete amb;
amb=NULL;
}

Member Function Documentation

bool StochHMM::Index::isAmbiguous ( )
inline

Returns whether there is an ambiguous character.

Definition at line 52 of file index.h.

References ambiguous.

{return ambiguous;};
Index StochHMM::Index::operator* ( const size_t  lhs)

Multiply int to Index.

Multiply Indices by integer.

Definition at line 196 of file index.cpp.

References amb, ambiguous, index, and StochHMM::multiplyValueToVector().

{
Index temp;
if (ambiguous){
}
else{
index*=lhs;
}
return temp;
}
void StochHMM::Index::operator*= ( const size_t  lhs)

Add int to Index.

Multiply Indices by integer

Parameters:
lhsInteger value

Definition at line 184 of file index.cpp.

References amb, ambiguous, index, and StochHMM::multiplyValueToVector().

{
if (ambiguous){
}
else{
index*=lhs;
}
return;
}
Index StochHMM::Index::operator+ ( const Index lhs)

Assign Index.

Add indexes together

Parameters:
lhs
Returns:
Index with values added

Definition at line 86 of file index.cpp.

References StochHMM::addValueToVector(), StochHMM::addVectorCombinatorial(), amb, ambiguous, and index.

{
Index temp;
temp.index=lhs.index + this->index;
if (ambiguous){
if (lhs.ambiguous){
temp.ambiguous=true;
temp.amb=new(std::nothrow) std::vector<size_t>;
if (temp.amb==NULL){
std::cerr << "OUT OF MEMORY\nFile" << __FILE__ << "Line:\t"<< __LINE__ << std::endl;
exit(1);
}
addVectorCombinatorial(*temp.amb, *this->amb, *lhs.amb);
}
else{
temp.ambiguous=true;
temp.amb=new(std::nothrow) std::vector<size_t>(*this->amb);
if (temp.amb==NULL){
std::cerr << "OUT OF MEMORY\nFile" << __FILE__ << "Line:\t"<< __LINE__ << std::endl;
exit(1);
}
addValueToVector(*temp.amb, lhs.index);
}
}
else{
if (lhs.ambiguous){
temp.ambiguous=true;
temp.amb=new(std::nothrow) std::vector<size_t>(*lhs.amb);
if (temp.amb==NULL){
std::cerr << "OUT OF MEMORY\nFile" << __FILE__ << "Line:\t"<< __LINE__ << std::endl;
exit(1);
}
addValueToVector(*temp.amb, this->index);
}
}
return temp;
}
void StochHMM::Index::operator+= ( const Index lhs)

Add Index.

Add and Assign.

Definition at line 132 of file index.cpp.

References StochHMM::addValueToVector(), StochHMM::addVectorCombinatorial(), amb, ambiguous, and index.

{
if (!ambiguous && !lhs.ambiguous){
index+=lhs.index;
return;
}
else if (ambiguous){
if (lhs.ambiguous){
std::vector<size_t>* temp = new(std::nothrow) std::vector<size_t>;
if (temp==NULL){
std::cerr << "OUT OF MEMORY\nFile" << __FILE__ << "Line:\t"<< __LINE__ << std::endl;
exit(1);
}
addVectorCombinatorial(*temp, *(this->amb), *(lhs.amb));
delete amb;
amb=temp;
}
else{
addValueToVector(*this->amb, lhs.index);
}
}
else{
if (lhs.ambiguous){
amb=new(std::nothrow) std::vector<size_t>(*lhs.amb);
ambiguous = true;
if (amb==NULL){
std::cerr << "OUT OF MEMORY\nFile" << __FILE__ << "Line:\t"<< __LINE__ << std::endl;
exit(1);
}
}
}
return;
}
void StochHMM::Index::operator+= ( const size_t  lhs)

Add and assign Index.

Add integer index to Index

Parameters:
lhsInteger index to add to Index

Definition at line 172 of file index.cpp.

References StochHMM::addValueToVector(), amb, ambiguous, and index.

{
if (ambiguous){
}
else{
index+=lhs;
}
return;
}
Index & StochHMM::Index::operator= ( const Index rhs)

Set the Index as ambiguous.

Assign Index by copy

Parameters:
rhs

Definition at line 66 of file index.cpp.

References amb, ambiguous, and index.

{
index=rhs.index;
ambiguous=rhs.ambiguous;
if (amb!=NULL){
amb=new(std::nothrow) std::vector<size_t>(rhs.amb->size());
if (amb==NULL){
std::cerr << "OUT OF MEMORY\nFile" << __FILE__ << "Line:\t"<< __LINE__ << std::endl;
exit(1);
}
copy( rhs.amb->begin(), rhs.amb->end(), amb->begin());
}
return *this;
}
size_t StochHMM::Index::operator[] ( const size_t  iter)

Get Number of indices.

Get the index at position in Index

Parameters:
iterInteger iterator of position
Returns:
int Integer value of index

Definition at line 221 of file index.cpp.

References amb, ambiguous, and index.

{
if (!ambiguous && iter==0){
return index;
}
else if (ambiguous){
return (*amb)[iter];
}
else{
std::cerr << "iterator: " << iter << " called on unambiguous value. Can only access with Iterator = 0" << std::endl;
exit(5);
}
}
void StochHMM::Index::setAmbiguous ( const std::vector< size_t > &  vec)

Definition at line 239 of file index.cpp.

References amb, and ambiguous.

Referenced by StochHMM::lexicalTable::getAmbiguousScore(), and StochHMM::lexicalTable::getReducedOrder().

{
amb=new(std::nothrow) std::vector<size_t>(vec);
if (amb==NULL){
std::cerr << "OUT OF MEMORY\nFile" << __FILE__ << "Line:\t"<< __LINE__ << std::endl;
exit(1);
}
ambiguous = true;
return;
}
size_t StochHMM::Index::size ( )

Multiply int to Index.

Get the number of indices in Index.

Definition at line 208 of file index.cpp.

References amb, and ambiguous.

Referenced by StochHMM::lexicalTable::getAmbiguousScore(), and StochHMM::lexicalTable::getReducedOrder().

{
if (ambiguous){
return amb->size();
}
else{
return 1;
}
}

Member Data Documentation

std::vector<size_t>* StochHMM::Index::amb
private
bool StochHMM::Index::ambiguous
private
size_t StochHMM::Index::index
private

Definition at line 69 of file index.h.

Referenced by Index(), operator*(), operator*=(), operator+(), operator+=(), operator=(), and operator[]().


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