DenseDistance.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) 2006-2009 Christian Gehl
00008  * Copyright (C) 2006-2009 Fraunhofer Institute FIRST and Max-Planck-Society
00009  */
00010 
00011 #ifndef _DENSEDISTANCE_H___
00012 #define _DENSEDISTANCE_H___
00013 
00014 #include <shogun/distance/Distance.h>
00015 #include <shogun/features/FeatureTypes.h>
00016 #include <shogun/features/DenseFeatures.h>
00017 #include <shogun/io/SGIO.h>
00018 
00019 namespace shogun
00020 {
00022 template <class ST> class CDenseDistance : public CDistance
00023 {
00024     public:
00026         CDenseDistance() : CDistance() {}
00027 
00034         virtual bool init(CFeatures* l, CFeatures* r)
00035         {
00036             CDistance::init(l,r);
00037 
00038             ASSERT(l->get_feature_class()==C_DENSE);
00039             ASSERT(r->get_feature_class()==C_DENSE);
00040             ASSERT(l->get_feature_type()==this->get_feature_type());
00041             ASSERT(r->get_feature_type()==this->get_feature_type());
00042 
00043 
00044             if ( ((CDenseFeatures<ST>*) l)->get_num_features() != ((CDenseFeatures<ST>*) r)->get_num_features() )
00045             {
00046                 SG_ERROR( "train or test features #dimension mismatch (l:%d vs. r:%d)\n",
00047                         ((CDenseFeatures<ST>*) l)->get_num_features(),((CDenseFeatures<ST>*) r)->get_num_features());
00048             }
00049 
00050             return true;
00051         }
00052 
00057         virtual EFeatureClass get_feature_class() { return C_DENSE; }
00058 
00063         virtual EFeatureType get_feature_type();
00064 
00070         virtual const char* get_name() const {
00071             return "DenseDistance"; }
00072 
00079         virtual EDistanceType get_distance_type()=0;
00080 };
00081 } // namespace shogun
00082 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

SHOGUN Machine Learning Toolbox - Documentation