Skip to content

Commit

Permalink
Split template implementation of string preproc
Browse files Browse the repository at this point in the history
  • Loading branch information
vinx13 authored and vigsterkr committed Jun 4, 2018
1 parent 8a3e4d4 commit 11e72d6
Show file tree
Hide file tree
Showing 2 changed files with 116 additions and 76 deletions.
116 changes: 116 additions & 0 deletions src/shogun/preprocessor/StringPreprocessor.cpp
@@ -0,0 +1,116 @@
/*
* This software is distributed under BSD 3-clause license (see LICENSE file).
*
* Authors: Wuwei Lin
*/

#include <shogun/preprocessor/StringPreprocessor.h>

namespace shogun
{

template <>
inline EFeatureType CStringPreprocessor<uint64_t>::get_feature_type()
{
return F_ULONG;
}

template <>
inline EFeatureType CStringPreprocessor<int64_t>::get_feature_type()
{
return F_LONG;
}

template <>
inline EFeatureType CStringPreprocessor<uint32_t>::get_feature_type()
{
return F_UINT;
}

template <>
inline EFeatureType CStringPreprocessor<int32_t>::get_feature_type()
{
return F_INT;
}

template <>
inline EFeatureType CStringPreprocessor<uint16_t>::get_feature_type()
{
return F_WORD;
}

template <>
inline EFeatureType CStringPreprocessor<int16_t>::get_feature_type()
{
return F_WORD;
}

template <>
inline EFeatureType CStringPreprocessor<uint8_t>::get_feature_type()
{
return F_BYTE;
}

template <>
inline EFeatureType CStringPreprocessor<int8_t>::get_feature_type()
{
return F_BYTE;
}

template <>
inline EFeatureType CStringPreprocessor<char>::get_feature_type()
{
return F_CHAR;
}

template <>
inline EFeatureType CStringPreprocessor<bool>::get_feature_type()
{
return F_BOOL;
}

template <>
inline EFeatureType CStringPreprocessor<float32_t>::get_feature_type()
{
return F_SHORTREAL;
}

template <>
inline EFeatureType CStringPreprocessor<float64_t>::get_feature_type()
{
return F_DREAL;
}

template <>
inline EFeatureType CStringPreprocessor<floatmax_t>::get_feature_type()
{
return F_LONGREAL;
}

template <class ST>
CFeatures* CStringPreprocessor<ST>::apply(CFeatures* features, bool inplace)
{
REQUIRE(
features->get_feature_class() == C_STRING,
"Provided features (%d) "
"has to be of C_STRING (%d) class!\n",
features->get_feature_class(), C_STRING);

apply_to_string_features(features);
return features;
}

template class CStringPreprocessor<bool>;
template class CStringPreprocessor<char>;
template class CStringPreprocessor<int8_t>;
template class CStringPreprocessor<uint8_t>;
template class CStringPreprocessor<int16_t>;
template class CStringPreprocessor<uint16_t>;
template class CStringPreprocessor<int32_t>;
template class CStringPreprocessor<uint32_t>;
template class CStringPreprocessor<int64_t>;
template class CStringPreprocessor<uint64_t>;
template class CStringPreprocessor<float32_t>;
template class CStringPreprocessor<float64_t>;
template class CStringPreprocessor<floatmax_t>;
}
76 changes: 0 additions & 76 deletions src/shogun/preprocessor/StringPreprocessor.h
Expand Up @@ -61,81 +61,5 @@ template <class ST> class CStringPreprocessor : public CPreprocessor

};

template<> inline EFeatureType CStringPreprocessor<uint64_t>::get_feature_type()
{
return F_ULONG;
}

template<> inline EFeatureType CStringPreprocessor<int64_t>::get_feature_type()
{
return F_LONG;
}

template<> inline EFeatureType CStringPreprocessor<uint32_t>::get_feature_type()
{
return F_UINT;
}

template<> inline EFeatureType CStringPreprocessor<int32_t>::get_feature_type()
{
return F_INT;
}

template<> inline EFeatureType CStringPreprocessor<uint16_t>::get_feature_type()
{
return F_WORD;
}

template<> inline EFeatureType CStringPreprocessor<int16_t>::get_feature_type()
{
return F_WORD;
}

template<> inline EFeatureType CStringPreprocessor<uint8_t>::get_feature_type()
{
return F_BYTE;
}

template<> inline EFeatureType CStringPreprocessor<int8_t>::get_feature_type()
{
return F_BYTE;
}

template<> inline EFeatureType CStringPreprocessor<char>::get_feature_type()
{
return F_CHAR;
}

template<> inline EFeatureType CStringPreprocessor<bool>::get_feature_type()
{
return F_BOOL;
}

template<> inline EFeatureType CStringPreprocessor<float32_t>::get_feature_type()
{
return F_SHORTREAL;
}

template<> inline EFeatureType CStringPreprocessor<float64_t>::get_feature_type()
{
return F_DREAL;
}

template<> inline EFeatureType CStringPreprocessor<floatmax_t>::get_feature_type()
{
return F_LONGREAL;
}

template <class ST>
CFeatures* CStringPreprocessor<ST>::apply(CFeatures* features, bool inplace)
{
REQUIRE(features->get_feature_class()==C_STRING, "Provided features (%d) "
"has to be of C_STRING (%d) class!\n",
features->get_feature_class(), C_STRING);

apply_to_string_features(features);
return features;
}

}
#endif

0 comments on commit 11e72d6

Please sign in to comment.