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) 2007-2009 Soeren Sonnenburg 00008 * Copyright (C) 2007-2009 Fraunhofer Institute FIRST and Max-Planck-Society 00009 */ 00010 00011 #ifndef _EUCLIDEANDISTANCE_H__ 00012 #define _EUCLIDEANDISTANCE_H__ 00013 00014 #include <shogun/lib/common.h> 00015 #include <shogun/distance/RealDistance.h> 00016 #include <shogun/features/DenseFeatures.h> 00017 00018 namespace shogun 00019 { 00043 class CEuclideanDistance: public CRealDistance 00044 { 00045 public: 00047 CEuclideanDistance(); 00048 00054 CEuclideanDistance(CDenseFeatures<float64_t>* l, CDenseFeatures<float64_t>* r); 00055 virtual ~CEuclideanDistance(); 00056 00063 virtual bool init(CFeatures* l, CFeatures* r); 00064 00066 virtual void cleanup(); 00067 00072 virtual EDistanceType get_distance_type() { return D_EUCLIDEAN; } 00073 00078 virtual EFeatureType get_feature_type() { return F_DREAL; } 00079 00084 virtual const char* get_name() const { return "EuclideanDistance"; } 00085 00091 virtual bool get_disable_sqrt() { return disable_sqrt; }; 00092 00098 virtual void set_disable_sqrt(bool state) { disable_sqrt=state; }; 00099 00112 virtual float64_t distance_upper_bounded(int32_t idx_a, int32_t idx_b, float64_t upper_bound); 00113 00114 protected: 00118 virtual float64_t compute(int32_t idx_a, int32_t idx_b); 00119 00120 private: 00121 void init(); 00122 00123 protected: 00125 bool disable_sqrt; 00126 }; 00127 00128 } // namespace shogun 00129 #endif /* _EUCLIDEANDISTANCE_H__ */