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::simpleTable< T > Class Template Reference

#include <simpleTable.h>

List of all members.

Public Member Functions

 simpleTable (std::vector< size_t > &order, std::vector< size_t > &alpha, std::vector< size_t > tracks, T init)
 ~simpleTable ()
get (sequences &seqs, size_t position)
const T get (sequences &seqs, size_t position) const
void assign (T &value, size_t index)
void assign (T &value, std::vector< uint8_t > &seq)
size_t size () const
bool empty () const
size_t size (unsigned int Dim) const
void clear ()

Private Attributes

std::vector< T > * elements
size_t num_of_elements
size_t num_of_alphabets
size_t num_of_dimensions
std::vector< size_t > order
std::vector< size_t > alpha
std::vector< std::pair< size_t,
size_t > > 
upstream
std::vector< size_t > dimensions
std::vector< size_t > subarray_length

Detailed Description

template<typename T>
class StochHMM::simpleTable< T >

Definition at line 22 of file simpleTable.h.


Constructor & Destructor Documentation

template<typename T >
StochHMM::simpleTable< T >::simpleTable ( std::vector< size_t > &  order,
std::vector< size_t > &  alpha,
std::vector< size_t >  tracks,
init 
)
inline

Definition at line 39 of file simpleTable.h.

References StochHMM::simpleTable< T >::alpha, StochHMM::simpleTable< T >::dimensions, StochHMM::simpleTable< T >::elements, StochHMM::simpleTable< T >::num_of_alphabets, StochHMM::simpleTable< T >::num_of_dimensions, StochHMM::simpleTable< T >::num_of_elements, StochHMM::simpleTable< T >::order, StochHMM::simpleTable< T >::subarray_length, and StochHMM::simpleTable< T >::upstream.

if (num_of_alphabets != order.size()){
std::cerr << "Differing number of orders and alphabets handed to SimpleArray" << std::endl;
exit(2);
}
for(size_t i=0;i<num_of_alphabets;++i){
num_of_elements*= pow(alpha[i],order[i]+1);
for(size_t j=0;j<=order[i];++j){
dimensions.push_back(alpha[i]);
std::pair<size_t,size_t> temp(tracks[i],order[i]-j);
upstream.push_back(temp);
}
}
for (size_t i=0;i<num_of_dimensions;++i){
size_t temp = 1;
for (size_t j=i+1;j<num_of_dimensions;++j){
temp*=dimensions[j];
}
subarray_length.push_back(temp);
}
elements = new (std::nothrow) std::vector<T>(num_of_elements, init);
if (elements == NULL){
std::cerr << "Unable to allocate SimpleArray" <<std::endl;
}
return;
};
template<typename T >
StochHMM::simpleTable< T >::~simpleTable ( )
inline

Definition at line 78 of file simpleTable.h.

References StochHMM::simpleTable< T >::elements.

{ delete elements; }

Member Function Documentation

template<typename T >
void StochHMM::simpleTable< T >::assign ( T &  value,
size_t  index 
)
inline

Definition at line 99 of file simpleTable.h.

References StochHMM::simpleTable< T >::num_of_elements.

{
if (index > num_of_elements){
std::cerr << "Adding element beyond range of array" << std::endl;
}
(*elements)[index] = value;
};
template<typename T >
void StochHMM::simpleTable< T >::assign ( T &  value,
std::vector< uint8_t > &  seq 
)
inline

Definition at line 106 of file simpleTable.h.

References StochHMM::simpleTable< T >::dimensions, and StochHMM::simpleTable< T >::num_of_dimensions.

{
size_t index(0);
for(size_t i=0; i < num_of_dimensions; i++){
index += seq[i] * dimensions[i];
}
(*elements)[index]=value;
}
template<typename T >
void StochHMM::simpleTable< T >::clear ( )
template<typename T >
bool StochHMM::simpleTable< T >::empty ( ) const
inline

Definition at line 117 of file simpleTable.h.

References StochHMM::simpleTable< T >::num_of_elements.

{ return num_of_elements==0; }
template<typename T >
T StochHMM::simpleTable< T >::get ( sequences seqs,
size_t  position 
)
inline

Definition at line 81 of file simpleTable.h.

References StochHMM::simpleTable< T >::elements, StochHMM::simpleTable< T >::num_of_dimensions, StochHMM::simpleTable< T >::subarray_length, and StochHMM::simpleTable< T >::upstream.

{
size_t index(0);
for(size_t i=0; i < num_of_dimensions; i++){
index += seqs[upstream[i].first][position-upstream[i].second] * subarray_length[i];
}
return (*elements)[index];
}
template<typename T >
const T StochHMM::simpleTable< T >::get ( sequences seqs,
size_t  position 
) const
inline

Definition at line 90 of file simpleTable.h.

References StochHMM::simpleTable< T >::dimensions, StochHMM::simpleTable< T >::elements, StochHMM::simpleTable< T >::num_of_dimensions, and StochHMM::simpleTable< T >::upstream.

{
size_t index(0);
for(size_t i=0; i < num_of_dimensions; i++){
index += seqs[upstream[i].first][position-upstream[i].second] * dimensions[i];
}
return elements[index];
}
template<typename T >
size_t StochHMM::simpleTable< T >::size ( void  ) const
inline

Definition at line 116 of file simpleTable.h.

References StochHMM::simpleTable< T >::num_of_elements.

{ return num_of_elements; }
template<typename T >
size_t StochHMM::simpleTable< T >::size ( unsigned int  Dim) const
inline

Definition at line 120 of file simpleTable.h.

References StochHMM::simpleTable< T >::dimensions.

{ return dimensions[Dim-1];}

Member Data Documentation

template<typename T >
std::vector<size_t> StochHMM::simpleTable< T >::alpha
private

Definition at line 31 of file simpleTable.h.

Referenced by StochHMM::simpleTable< T >::simpleTable().

template<typename T >
std::vector<size_t> StochHMM::simpleTable< T >::dimensions
private
template<typename T >
std::vector<T>* StochHMM::simpleTable< T >::elements
private
template<typename T >
size_t StochHMM::simpleTable< T >::num_of_alphabets
private

Definition at line 27 of file simpleTable.h.

Referenced by StochHMM::simpleTable< T >::simpleTable().

template<typename T >
size_t StochHMM::simpleTable< T >::num_of_dimensions
private
template<typename T >
size_t StochHMM::simpleTable< T >::num_of_elements
private
template<typename T >
std::vector<size_t> StochHMM::simpleTable< T >::order
private

Definition at line 30 of file simpleTable.h.

Referenced by StochHMM::simpleTable< T >::simpleTable().

template<typename T >
std::vector<size_t> StochHMM::simpleTable< T >::subarray_length
private
template<typename T >
std::vector<std::pair<size_t,size_t> > StochHMM::simpleTable< T >::upstream
private

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