CSimpleFeatures< ST > Class Template Reference


Detailed Description

template<class ST>
class CSimpleFeatures< ST >

The class SimpleFeatures implements dense feature matrices.

The feature matrices are stored en-block in memory in fortran order, i.e. column-by-column, where a column denotes a feature vector.

There are get_num_vectors() many feature vectors, of dimension get_num_features(). To access a feature vector call get_feature_vector() and when you are done treating it call free_feature_vector(). While free_feature_vector() is a NOP in most cases feature vectors might have been generated on the fly (due to a number preprocessors being attached to them).

From this template class a number the following dense feature matrix types are used and supported:

Definition at line 59 of file SimpleFeatures.h.

Inheritance diagram for CSimpleFeatures< ST >:
Inheritance graph
[legend]

List of all members.

Public Member Functions

 CSimpleFeatures (int32_t size=0)
 CSimpleFeatures (const CSimpleFeatures &orig)
 CSimpleFeatures (ST *src, int32_t num_feat, int32_t num_vec)
 CSimpleFeatures (char *fname)
virtual CFeaturesduplicate () const
virtual ~CSimpleFeatures ()
void free_feature_matrix ()
void free_features ()
ST * get_feature_vector (int32_t num, int32_t &len, bool &dofree)
void set_feature_vector (ST *src, int32_t len, int32_t num)
void get_feature_vector (ST **dst, int32_t *len, int32_t num)
void free_feature_vector (ST *feat_vec, int32_t num, bool dofree)
void get_feature_matrix (ST **dst, int32_t *num_feat, int32_t *num_vec)
ST * get_feature_matrix (int32_t &num_feat, int32_t &num_vec)
virtual void set_feature_matrix (ST *fm, int32_t num_feat, int32_t num_vec)
virtual void copy_feature_matrix (ST *src, int32_t num_feat, int32_t num_vec)
virtual bool apply_preproc (bool force_preprocessing=false)
virtual int32_t get_size ()
virtual int32_t get_num_vectors ()
int32_t get_num_features ()
void set_num_features (int32_t num)
void set_num_vectors (int32_t num)
virtual EFeatureClass get_feature_class ()
virtual EFeatureType get_feature_type ()
virtual bool reshape (int32_t p_num_features, int32_t p_num_vectors)
virtual int32_t get_dim_feature_space ()
virtual float64_t dot (int32_t vec_idx1, int32_t vec_idx2)
virtual float64_t dense_dot (int32_t vec_idx1, const float64_t *vec2, int32_t vec2_len)
virtual void add_to_dense_vec (float64_t alpha, int32_t vec_idx1, float64_t *vec2, int32_t vec2_len, bool abs_val=false)
virtual int32_t get_nnz_features_for_vector (int32_t num)
virtual bool Align_char_features (CStringFeatures< char > *cf, CStringFeatures< char > *Ref, float64_t gapCost)
virtual bool load (char *fname)
virtual bool save (char *fname)
virtual const char * get_name () const

Protected Member Functions

virtual ST * compute_feature_vector (int32_t num, int32_t &len, ST *target=NULL)

Protected Attributes

int32_t num_vectors
 number of vectors in cache
int32_t num_features
 number of features in cache
ST * feature_matrix
CCache< ST > * feature_cache

Constructor & Destructor Documentation

template<class ST>
CSimpleFeatures< ST >::CSimpleFeatures ( int32_t  size = 0  ) 

constructor

Parameters:
size cache size

Definition at line 66 of file SimpleFeatures.h.

template<class ST>
CSimpleFeatures< ST >::CSimpleFeatures ( const CSimpleFeatures< ST > &  orig  ) 

copy constructor

Definition at line 71 of file SimpleFeatures.h.

template<class ST>
CSimpleFeatures< ST >::CSimpleFeatures ( ST *  src,
int32_t  num_feat,
int32_t  num_vec 
)

constructor

Parameters:
src feature matrix
num_feat number of features in matrix
num_vec number of vectors in matrix

Definition at line 91 of file SimpleFeatures.h.

template<class ST>
CSimpleFeatures< ST >::CSimpleFeatures ( char *  fname  ) 

constructor

NOT IMPLEMENTED!

Parameters:
fname filename to load features from

Definition at line 104 of file SimpleFeatures.h.

template<class ST>
virtual CSimpleFeatures< ST >::~CSimpleFeatures (  )  [virtual]

Definition at line 117 of file SimpleFeatures.h.


Member Function Documentation

template<class ST>
virtual void CSimpleFeatures< ST >::add_to_dense_vec ( float64_t  alpha,
int32_t  vec_idx1,
float64_t vec2,
int32_t  vec2_len,
bool  abs_val = false 
) [virtual]

add vector 1 multiplied with alpha to dense vector2

Parameters:
alpha scalar alpha
vec_idx1 index of first vector
vec2 pointer to real valued vector
vec2_len length of real valued vector
abs_val if true add the absolute value

Implements CDotFeatures.

Definition at line 518 of file SimpleFeatures.h.

template<class ST>
virtual bool CSimpleFeatures< ST >::Align_char_features ( CStringFeatures< char > *  cf,
CStringFeatures< char > *  Ref,
float64_t  gapCost 
) [virtual]

align char features

Parameters:
cf char features
Ref other char features
gapCost gap cost
Returns:
if aligning was successful

Definition at line 559 of file SimpleFeatures.h.

template<class ST>
virtual bool CSimpleFeatures< ST >::apply_preproc ( bool  force_preprocessing = false  )  [virtual]

apply preprocessor

Parameters:
force_preprocessing if preprocssing shall be forced
Returns:
if applying was successful

Definition at line 354 of file SimpleFeatures.h.

template<class ST>
virtual ST* CSimpleFeatures< ST >::compute_feature_vector ( int32_t  num,
int32_t &  len,
ST *  target = NULL 
) [protected, virtual]

compute feature vector for sample num if target is set the vector is written to target len is returned by reference

NOT IMPLEMENTED!

Parameters:
num num
len len
target 
Returns:
feature vector

Reimplemented in CFKFeatures, CRealFileFeatures, and CTOPFeatures.

Definition at line 635 of file SimpleFeatures.h.

template<class ST>
virtual void CSimpleFeatures< ST >::copy_feature_matrix ( ST *  src,
int32_t  num_feat,
int32_t  num_vec 
) [virtual]

copy feature matrix store copy of feature_matrix, where num_features is the column offset, and columns are linear in memory see below for definition of feature_matrix

Parameters:
src feature matrix to copy
num_feat number of features in matrix
num_vec number of vectors in matrix

Definition at line 339 of file SimpleFeatures.h.

template<class ST>
virtual float64_t CSimpleFeatures< ST >::dense_dot ( int32_t  vec_idx1,
const float64_t vec2,
int32_t  vec2_len 
) [virtual]

compute dot product between vector1 and a dense vector

Parameters:
vec_idx1 index of first vector
vec2 pointer to real valued vector
vec2_len length of real valued vector

Implements CDotFeatures.

template<class ST>
virtual float64_t CSimpleFeatures< ST >::dot ( int32_t  vec_idx1,
int32_t  vec_idx2 
) [virtual]

compute dot product between vector1 and vector2, appointed by their indices

Parameters:
vec_idx1 index of first vector
vec_idx2 index of second vector

Implements CDotFeatures.

Definition at line 486 of file SimpleFeatures.h.

template<class ST>
virtual CFeatures* CSimpleFeatures< ST >::duplicate (  )  const [virtual]

duplicate feature object

Returns:
feature object

Implements CFeatures.

Definition at line 112 of file SimpleFeatures.h.

template<class ST>
void CSimpleFeatures< ST >::free_feature_matrix (  ) 

free feature matrix

Definition at line 126 of file SimpleFeatures.h.

template<class ST>
void CSimpleFeatures< ST >::free_feature_vector ( ST *  feat_vec,
int32_t  num,
bool  dofree 
)

free feature vector

Parameters:
feat_vec feature vector to free
num index in feature cache
dofree if vector should be really deleted

Definition at line 271 of file SimpleFeatures.h.

template<class ST>
void CSimpleFeatures< ST >::free_features (  ) 

free feature matrix and cache

Definition at line 137 of file SimpleFeatures.h.

template<class ST>
virtual int32_t CSimpleFeatures< ST >::get_dim_feature_space (  )  [virtual]

obtain the dimensionality of the feature space

(not mix this up with the dimensionality of the input space, usually obtained via get_num_features())

Returns:
dimensionality

Implements CDotFeatures.

Definition at line 475 of file SimpleFeatures.h.

template<class ST>
virtual EFeatureClass CSimpleFeatures< ST >::get_feature_class (  )  [virtual]

get feature class

Returns:
feature class SIMPLE

Implements CFeatures.

Definition at line 442 of file SimpleFeatures.h.

template<class ST>
ST* CSimpleFeatures< ST >::get_feature_matrix ( int32_t &  num_feat,
int32_t &  num_vec 
)

get the pointer to the feature matrix num_feat,num_vectors are returned by reference

Parameters:
num_feat number of features in matrix
num_vec number of vectors in matrix
Returns:
feature matrix

Definition at line 305 of file SimpleFeatures.h.

template<class ST>
void CSimpleFeatures< ST >::get_feature_matrix ( ST **  dst,
int32_t *  num_feat,
int32_t *  num_vec 
)

get a copy of the feature matrix num_feat,num_vectors are returned by reference

Parameters:
dst destination to store matrix in
num_feat number of features (rows of matrix)
num_vec number of vectors (columns of matrix)

Definition at line 287 of file SimpleFeatures.h.

template<class ST>
virtual EFeatureType CSimpleFeatures< ST >::get_feature_type (  )  [virtual]

get feature type

Returns:
templated feature type

Implements CFeatures.

template<class ST>
void CSimpleFeatures< ST >::get_feature_vector ( ST **  dst,
int32_t *  len,
int32_t  num 
)

get feature vector num

Parameters:
dst destination to store vector in
len length of vector
num index of vector

Definition at line 245 of file SimpleFeatures.h.

template<class ST>
ST* CSimpleFeatures< ST >::get_feature_vector ( int32_t  num,
int32_t &  len,
bool &  dofree 
)

get feature vector for sample num from the matrix as it is if matrix is initialized, else return preprocessed compute_feature_vector

Parameters:
num index of feature vector
len length is returned by reference
dofree whether returned vector must be freed by caller via free_feature_vector
Returns:
feature vector

Definition at line 154 of file SimpleFeatures.h.

template<class ST>
virtual const char* CSimpleFeatures< ST >::get_name (  )  const [virtual]
Returns:
object name

Implements CSGObject.

Reimplemented in CFKFeatures, CRealFileFeatures, and CTOPFeatures.

Definition at line 621 of file SimpleFeatures.h.

template<class ST>
virtual int32_t CSimpleFeatures< ST >::get_nnz_features_for_vector ( int32_t  num  )  [virtual]

get number of non-zero features in vector

Parameters:
num which vector
Returns:
number of non-zero features in vector

Implements CDotFeatures.

Definition at line 547 of file SimpleFeatures.h.

template<class ST>
int32_t CSimpleFeatures< ST >::get_num_features (  ) 

get number of features

Returns:
number of features

Definition at line 407 of file SimpleFeatures.h.

template<class ST>
virtual int32_t CSimpleFeatures< ST >::get_num_vectors (  )  [virtual]

get number of feature vectors

Returns:
number of feature vectors

Implements CFeatures.

Definition at line 401 of file SimpleFeatures.h.

template<class ST>
virtual int32_t CSimpleFeatures< ST >::get_size (  )  [virtual]

get memory footprint of one feature

Returns:
memory footprint of one feature

Implements CFeatures.

Definition at line 394 of file SimpleFeatures.h.

template<class ST>
virtual bool CSimpleFeatures< ST >::load ( char *  fname  )  [virtual]

load features from file

Parameters:
fname filename to load from
Returns:
if loading was successful

Reimplemented from CFeatures.

Definition at line 570 of file SimpleFeatures.h.

template<class ST>
virtual bool CSimpleFeatures< ST >::reshape ( int32_t  p_num_features,
int32_t  p_num_vectors 
) [virtual]

reshape

Parameters:
p_num_features new number of features
p_num_vectors new number of vectors
Returns:
if reshaping was successful

Reimplemented from CFeatures.

Definition at line 456 of file SimpleFeatures.h.

template<class ST>
virtual bool CSimpleFeatures< ST >::save ( char *  fname  )  [virtual]

save features to file

Parameters:
fname filename to save to
Returns:
if saving was successful

Reimplemented from CFeatures.

Definition at line 594 of file SimpleFeatures.h.

template<class ST>
virtual void CSimpleFeatures< ST >::set_feature_matrix ( ST *  fm,
int32_t  num_feat,
int32_t  num_vec 
) [virtual]

set feature matrix necessary to set feature_matrix, num_features, num_vectors, where num_features is the column offset, and columns are linear in memory see below for definition of feature_matrix

Parameters:
fm feature matrix to se
num_feat number of features in matrix
num_vec number of vectors in matrix

Definition at line 322 of file SimpleFeatures.h.

template<class ST>
void CSimpleFeatures< ST >::set_feature_vector ( ST *  src,
int32_t  len,
int32_t  num 
)

set feature vector num

( only available in-memory feature matrices )

Parameters:
src vector
len length of vector
num index where to put vector to

Definition at line 222 of file SimpleFeatures.h.

template<class ST>
void CSimpleFeatures< ST >::set_num_features ( int32_t  num  ) 

set number of features

Parameters:
num number to set

Definition at line 413 of file SimpleFeatures.h.

template<class ST>
void CSimpleFeatures< ST >::set_num_vectors ( int32_t  num  ) 

set number of vectors

Parameters:
num number to set

Definition at line 428 of file SimpleFeatures.h.


Member Data Documentation

template<class ST>
CCache<ST>* CSimpleFeatures< ST >::feature_cache [protected]

feature cache

Definition at line 651 of file SimpleFeatures.h.

template<class ST>
ST* CSimpleFeatures< ST >::feature_matrix [protected]

feature matrix

Definition at line 648 of file SimpleFeatures.h.

template<class ST>
int32_t CSimpleFeatures< ST >::num_features [protected]

number of features in cache

Definition at line 645 of file SimpleFeatures.h.

template<class ST>
int32_t CSimpleFeatures< ST >::num_vectors [protected]

number of vectors in cache

Definition at line 642 of file SimpleFeatures.h.


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

SHOGUN Machine Learning Toolbox - Documentation