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 _SPARSEEUCLIDIANDISTANCE_H__ 00012 #define _SPARSEEUCLIDIANDISTANCE_H__ 00013 00014 #include <shogun/lib/common.h> 00015 #include <shogun/distance/SparseDistance.h> 00016 #include <shogun/features/SparseFeatures.h> 00017 00018 namespace shogun 00019 { 00020 template <class T> class CSparseFeatures; 00022 class CSparseEuclidianDistance: public CSparseDistance<float64_t> 00023 { 00024 public: 00026 CSparseEuclidianDistance(); 00027 00033 CSparseEuclidianDistance( 00034 CSparseFeatures<float64_t>* l, CSparseFeatures<float64_t>* r); 00035 virtual ~CSparseEuclidianDistance(); 00036 00043 virtual bool init(CFeatures* l, CFeatures* r); 00044 00046 virtual void cleanup(); 00047 00052 virtual EDistanceType get_distance_type() { return D_SPARSEEUCLIDIAN; } 00053 00058 inline virtual EFeatureType get_feature_type() { return F_DREAL; } 00059 00064 virtual const char* get_name() const { return "SparseEuclidianDistance"; } 00065 00066 protected: 00070 virtual float64_t compute(int32_t idx_a, int32_t idx_b); 00071 /* compute_kernel*/ 00072 00073 private: 00074 void init(); 00075 00076 protected: 00078 float64_t* sq_lhs; 00080 float64_t* sq_rhs; 00081 00082 }; 00083 00084 } // namespace shogun 00085 #endif /* _SPARSEEUCLIDIANDISTANCE_H__ */