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) 2006 Christian Gehl 00008 * Copyright (C) 2006-2008 Fraunhofer Institute FIRST and Max-Planck-Society 00009 */ 00010 00011 #ifndef _SIMPLEDISTANCE_H___ 00012 #define _SIMPLEDISTANCE_H___ 00013 00014 #include "distance/Distance.h" 00015 #include "features/SimpleFeatures.h" 00016 #include "lib/io.h" 00017 00019 template <class ST> class CSimpleDistance : public CDistance 00020 { 00021 public: 00023 CSimpleDistance() : CDistance() {} 00024 00031 virtual bool init(CFeatures* l, CFeatures* r) 00032 { 00033 CDistance::init(l,r); 00034 00035 ASSERT(l->get_feature_class()==C_SIMPLE); 00036 ASSERT(r->get_feature_class()==C_SIMPLE); 00037 ASSERT(l->get_feature_type()==this->get_feature_type()); 00038 ASSERT(r->get_feature_type()==this->get_feature_type()); 00039 00040 00041 if ( ((CSimpleFeatures<ST>*) l)->get_num_features() != ((CSimpleFeatures<ST>*) r)->get_num_features() ) 00042 { 00043 SG_ERROR( "train or test features #dimension mismatch (l:%d vs. r:%d)\n", 00044 ((CSimpleFeatures<ST>*) l)->get_num_features(),((CSimpleFeatures<ST>*) r)->get_num_features()); 00045 } 00046 00047 return true; 00048 } 00049 00054 inline virtual EFeatureClass get_feature_class() { return C_SIMPLE; } 00055 00060 inline virtual EFeatureType get_feature_type(); 00061 }; 00062 00067 template<> inline EFeatureType CSimpleDistance<DREAL>::get_feature_type() { return F_DREAL; } 00068 00073 template<> inline EFeatureType CSimpleDistance<ULONG>::get_feature_type() { return F_ULONG; } 00074 00079 template<> inline EFeatureType CSimpleDistance<INT>::get_feature_type() { return F_INT; } 00080 00085 template<> inline EFeatureType CSimpleDistance<WORD>::get_feature_type() { return F_WORD; } 00086 00091 template<> inline EFeatureType CSimpleDistance<SHORT>::get_feature_type() { return F_SHORT; } 00092 00097 template<> inline EFeatureType CSimpleDistance<BYTE>::get_feature_type() { return F_BYTE; } 00098 00103 template<> inline EFeatureType CSimpleDistance<CHAR>::get_feature_type() { return F_CHAR; } 00104 00105 #endif