Skip to content

Commit

Permalink
const methods in Features
Browse files Browse the repository at this point in the history
  • Loading branch information
gsomix committed May 22, 2012
1 parent df320e8 commit 61ff1e2
Show file tree
Hide file tree
Showing 39 changed files with 143 additions and 143 deletions.
6 changes: 3 additions & 3 deletions src/shogun/features/BinnedDotFeatures.cpp
Expand Up @@ -314,13 +314,13 @@ CFeatures* CBinnedDotFeatures::duplicate() const
return new CBinnedDotFeatures(*this);
}

EFeatureType CBinnedDotFeatures::get_feature_type()
EFeatureType CBinnedDotFeatures::get_feature_type() const
{
return F_DREAL;
}


EFeatureClass CBinnedDotFeatures::get_feature_class()
EFeatureClass CBinnedDotFeatures::get_feature_class() const
{
return C_BINNED_DOT;
}
Expand All @@ -331,7 +331,7 @@ int32_t CBinnedDotFeatures::get_num_vectors() const
return m_features->get_num_vectors();
}

int32_t CBinnedDotFeatures::get_size()
int32_t CBinnedDotFeatures::get_size() const
{
return sizeof(float64_t);
}
Expand Down
6 changes: 3 additions & 3 deletions src/shogun/features/BinnedDotFeatures.h
Expand Up @@ -204,13 +204,13 @@ class CBinnedDotFeatures : public CDotFeatures
*
* @return feature type
*/
virtual EFeatureType get_feature_type();
virtual EFeatureType get_feature_type() const;

/** get feature class
*
* @return feature class
*/
virtual EFeatureClass get_feature_class();
virtual EFeatureClass get_feature_class() const;

/** get number of examples/vectors
*
Expand All @@ -222,7 +222,7 @@ class CBinnedDotFeatures : public CDotFeatures
*
* @return size in bytes
*/
virtual int32_t get_size();
virtual int32_t get_size() const;

private:
void init();
Expand Down
6 changes: 3 additions & 3 deletions src/shogun/features/CombinedDotFeatures.h
Expand Up @@ -140,7 +140,7 @@ class CCombinedDotFeatures : public CDotFeatures
*
* @return templated feature type
*/
inline virtual EFeatureType get_feature_type()
inline virtual EFeatureType get_feature_type() const
{
return F_DREAL;
}
Expand All @@ -149,7 +149,7 @@ class CCombinedDotFeatures : public CDotFeatures
*
* @return feature class
*/
inline virtual EFeatureClass get_feature_class()
inline virtual EFeatureClass get_feature_class() const
{
return C_COMBINED_DOT;
}
Expand All @@ -158,7 +158,7 @@ class CCombinedDotFeatures : public CDotFeatures
*
* @return size of a element
*/
inline virtual int32_t get_size()
inline virtual int32_t get_size() const
{
return sizeof(float64_t);
}
Expand Down
2 changes: 1 addition & 1 deletion src/shogun/features/CombinedFeatures.cpp
Expand Up @@ -43,7 +43,7 @@ CCombinedFeatures::~CCombinedFeatures()
SG_UNREF(feature_list);
}

int32_t CCombinedFeatures::get_size()
int32_t CCombinedFeatures::get_size() const
{
CFeatures* f=(CFeatures*) feature_list
->get_current_element();
Expand Down
6 changes: 3 additions & 3 deletions src/shogun/features/CombinedFeatures.h
Expand Up @@ -49,7 +49,7 @@ class CCombinedFeatures : public CFeatures
*
* @return feature type UNKNOWN
*/
inline virtual EFeatureType get_feature_type()
inline virtual EFeatureType get_feature_type() const
{
return F_UNKNOWN;
}
Expand All @@ -58,7 +58,7 @@ class CCombinedFeatures : public CFeatures
*
* @return feature class SIMPLE
*/
inline virtual EFeatureClass get_feature_class()
inline virtual EFeatureClass get_feature_class() const
{
return C_COMBINED;
}
Expand All @@ -76,7 +76,7 @@ class CCombinedFeatures : public CFeatures
*
* @return memory footprint of one feature
*/
virtual int32_t get_size();
virtual int32_t get_size() const;

/** list feature objects */
void list_feature_objs();
Expand Down
6 changes: 3 additions & 3 deletions src/shogun/features/DenseFeatures.cpp
Expand Up @@ -397,7 +397,7 @@ template<class ST> bool CDenseFeatures<ST>::apply_preprocessor(bool force_prepro
}
}

template<class ST> int32_t CDenseFeatures<ST>::get_size() { return sizeof(ST); }
template<class ST> int32_t CDenseFeatures<ST>::get_size() const { return sizeof(ST); }

template<class ST> int32_t CDenseFeatures<ST>::get_num_vectors() const
{
Expand Down Expand Up @@ -435,7 +435,7 @@ template<class ST> void CDenseFeatures<ST>::initialize_cache()
}
}

template<class ST> EFeatureClass CDenseFeatures<ST>::get_feature_class() { return C_DENSE; }
template<class ST> EFeatureClass CDenseFeatures<ST>::get_feature_class() const { return C_DENSE; }

template<class ST> bool CDenseFeatures<ST>::reshape(int32_t p_num_features, int32_t p_num_vectors)
{
Expand Down Expand Up @@ -586,7 +586,7 @@ template<class ST> void CDenseFeatures<ST>::init()
}

#define GET_FEATURE_TYPE(f_type, sg_type) \
template<> EFeatureType CDenseFeatures<sg_type>::get_feature_type() \
template<> EFeatureType CDenseFeatures<sg_type>::get_feature_type() const \
{ \
return f_type; \
}
Expand Down
6 changes: 3 additions & 3 deletions src/shogun/features/DenseFeatures.h
Expand Up @@ -291,7 +291,7 @@ template<class ST> class CDenseFeatures: public CDotFeatures
*
* @return memory footprint of one feature
*/
virtual int32_t get_size();
virtual int32_t get_size() const;

/** get number of feature vectors
*
Expand Down Expand Up @@ -329,13 +329,13 @@ template<class ST> class CDenseFeatures: public CDotFeatures
*
* @return feature class DENSE
*/
virtual EFeatureClass get_feature_class();
virtual EFeatureClass get_feature_class() const;

/** get feature type
*
* @return templated feature type
*/
virtual EFeatureType get_feature_type();
virtual EFeatureType get_feature_type() const;

/** reshape
*
Expand Down
6 changes: 3 additions & 3 deletions src/shogun/features/DummyFeatures.cpp
Expand Up @@ -29,7 +29,7 @@ int32_t CDummyFeatures::get_num_vectors() const
return num_vectors;
}

int32_t CDummyFeatures::get_size()
int32_t CDummyFeatures::get_size() const
{
return 1;
}
Expand All @@ -39,12 +39,12 @@ CFeatures* CDummyFeatures::duplicate() const
return new CDummyFeatures(*this);
}

inline EFeatureType CDummyFeatures::get_feature_type()
inline EFeatureType CDummyFeatures::get_feature_type() const
{
return F_ANY;
}

EFeatureClass CDummyFeatures::get_feature_class()
EFeatureClass CDummyFeatures::get_feature_class() const
{
return C_ANY;
}
Expand Down
6 changes: 3 additions & 3 deletions src/shogun/features/DummyFeatures.h
Expand Up @@ -42,16 +42,16 @@ class CDummyFeatures : public CFeatures
virtual int32_t get_num_vectors() const;

/** get size of features (always 1) */
virtual int32_t get_size();
virtual int32_t get_size() const;

/** duplicate features */
virtual CFeatures* duplicate() const;

/** get feature type (ANY) */
inline EFeatureType get_feature_type();
inline EFeatureType get_feature_type() const;

/** get feature class (ANY) */
inline virtual EFeatureClass get_feature_class();
inline virtual EFeatureClass get_feature_class() const;

/** @return object name */
inline virtual const char* get_name() const { return "DummyFeatures"; }
Expand Down
6 changes: 3 additions & 3 deletions src/shogun/features/ExplicitSpecFeatures.cpp
Expand Up @@ -175,12 +175,12 @@ int32_t CExplicitSpecFeatures::get_nnz_features_for_vector(int32_t num)
return 0;
}

EFeatureType CExplicitSpecFeatures::get_feature_type()
EFeatureType CExplicitSpecFeatures::get_feature_type() const
{
return F_UNKNOWN;
}

EFeatureClass CExplicitSpecFeatures::get_feature_class()
EFeatureClass CExplicitSpecFeatures::get_feature_class() const
{
return C_SPEC;
}
Expand All @@ -190,7 +190,7 @@ int32_t CExplicitSpecFeatures::get_num_vectors() const
return num_strings;
}

int32_t CExplicitSpecFeatures::get_size()
int32_t CExplicitSpecFeatures::get_size() const
{
return sizeof(float64_t);
}
6 changes: 3 additions & 3 deletions src/shogun/features/ExplicitSpecFeatures.h
Expand Up @@ -145,13 +145,13 @@ class CExplicitSpecFeatures : public CDotFeatures
*
* @return templated feature type
*/
virtual EFeatureType get_feature_type();
virtual EFeatureType get_feature_type() const;

/** get feature class
*
* @return feature class
*/
virtual EFeatureClass get_feature_class();
virtual EFeatureClass get_feature_class() const;

/** get number of strings
*
Expand All @@ -163,7 +163,7 @@ class CExplicitSpecFeatures : public CDotFeatures
*
* @return size of one element
*/
virtual int32_t get_size();
virtual int32_t get_size() const;

/** @return object name */
inline virtual const char* get_name() const { return "ExplicitSpecFeatures"; }
Expand Down
14 changes: 7 additions & 7 deletions src/shogun/features/Features.cpp
Expand Up @@ -108,7 +108,7 @@ int32_t CFeatures::add_preprocessor(CPreprocessor* p)
}

/// get current preprocessor
CPreprocessor* CFeatures::get_preprocessor(int32_t num)
CPreprocessor* CFeatures::get_preprocessor(int32_t num) const
{
if (num<num_preproc)
{
Expand All @@ -120,7 +120,7 @@ CPreprocessor* CFeatures::get_preprocessor(int32_t num)
}

/// get whether specified preprocessor (or all if num=1) was/were already applied
int32_t CFeatures::get_num_preprocessed()
int32_t CFeatures::get_num_preprocessed() const
{
int32_t num=0;

Expand Down Expand Up @@ -190,7 +190,7 @@ void CFeatures::set_preprocessed(int32_t num)
preprocessed[num]=true;
}

bool CFeatures::is_preprocessed(int32_t num)
bool CFeatures::is_preprocessed(int32_t num) const
{
return preprocessed[num];
}
Expand All @@ -200,7 +200,7 @@ int32_t CFeatures::get_num_preprocessors() const
return num_preproc;
}

int32_t CFeatures::get_cache_size()
int32_t CFeatures::get_cache_size() const
{
return cache_size;
}
Expand All @@ -211,7 +211,7 @@ bool CFeatures::reshape(int32_t num_features, int32_t num_vectors)
return false;
}

void CFeatures::list_feature_obj()
void CFeatures::list_feature_obj() const
{
SG_INFO( "%p - ", this);
switch (get_feature_class())
Expand Down Expand Up @@ -323,7 +323,7 @@ void CFeatures::save(CFile* writer)
SG_RESET_LOCALE;
}

bool CFeatures::check_feature_compatibility(CFeatures* f)
bool CFeatures::check_feature_compatibility(CFeatures* f) const
{
bool result=false;

Expand All @@ -333,7 +333,7 @@ bool CFeatures::check_feature_compatibility(CFeatures* f)
return result;
}

bool CFeatures::has_property(EFeatureProperty p)
bool CFeatures::has_property(EFeatureProperty p) const
{
return (properties & p) != 0;
}
Expand Down

0 comments on commit 61ff1e2

Please sign in to comment.