StringKernel.h

Go to the documentation of this file.
00001 /*
00002  * This program is free software; you can redistribute it and/or modify
00003  * it under the terms of the GNU General Public License as published by
00004  * the Free Software Foundation; either version 3 of the License, or
00005  * (at your option) any later version.
00006  *
00007  * Written (W) 1999-2009 Soeren Sonnenburg
00008  * Copyright (C) 1999-2009 Fraunhofer Institute FIRST and Max-Planck-Society
00009  */
00010 
00011 #ifndef _STRINGKERNEL_H___
00012 #define _STRINGKERNEL_H___
00013 
00014 #include <shogun/kernel/Kernel.h>
00015 #include <shogun/features/StringFeatures.h>
00016 
00017 namespace shogun
00018 {
00024 template <class ST> class CStringKernel : public CKernel
00025 {
00026     public:
00031         CStringKernel(int32_t cachesize=0) : CKernel(cachesize) {}
00032 
00038         CStringKernel(CFeatures *l, CFeatures *r) : CKernel(10)
00039         {
00040             init(l, r);
00041         }
00042 
00053         virtual bool init(CFeatures* l, CFeatures* r)
00054         {
00055             CKernel::init(l,r);
00056 
00057             ASSERT(l->get_feature_class()==C_STRING);
00058             ASSERT(r->get_feature_class()==C_STRING);
00059             ASSERT(l->get_feature_type()==this->get_feature_type());
00060             ASSERT(r->get_feature_type()==this->get_feature_type());
00061 
00062             return true;
00063         }
00064 
00069         inline virtual EFeatureClass get_feature_class() { return C_STRING; }
00070 
00075         virtual EFeatureType get_feature_type();
00076 
00082         virtual const char* get_name(void) const {
00083             return "StringKernel"; }
00084 
00092         virtual EKernelType get_kernel_type()=0;
00093 };
00094 
00095 template<> inline EFeatureType CStringKernel<float64_t>::get_feature_type() { return F_DREAL; }
00096 
00097 template<> inline EFeatureType CStringKernel<uint64_t>::get_feature_type() { return F_ULONG; }
00098 
00099 template<> inline EFeatureType CStringKernel<int32_t>::get_feature_type() { return F_INT; }
00100 
00101 template<> inline EFeatureType CStringKernel<uint16_t>::get_feature_type() { return F_WORD; }
00102 
00103 template<> inline EFeatureType CStringKernel<int16_t>::get_feature_type() { return F_SHORT; }
00104 
00105 template<> inline EFeatureType CStringKernel<uint8_t>::get_feature_type() { return F_BYTE; }
00106 
00107 template<> inline EFeatureType CStringKernel<char>::get_feature_type() { return F_CHAR; }
00108 }
00109 #endif /* _STRINGKERNEL_H__ */
00110 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

SHOGUN Machine Learning Toolbox - Documentation