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 * Written (W) 2006-2009 Soeren Sonnenburg 00009 * Copyright (C) 1999-2009 Fraunhofer Institute FIRST and Max-Planck-Society 00010 */ 00011 00012 #ifndef _DISTANCE_MACHINE_H__ 00013 #define _DISTANCE_MACHINE_H__ 00014 00015 #include <shogun/lib/common.h> 00016 #include <shogun/distance/Distance.h> 00017 #include <shogun/labels/Labels.h> 00018 #include <shogun/labels/RegressionLabels.h> 00019 #include <shogun/machine/Machine.h> 00020 00021 #include <stdio.h> 00022 00023 namespace shogun 00024 { 00025 class CLabels; 00026 class CRegressionLabels; 00027 class CDistance; 00028 class CMachine; 00029 00034 class CDistanceMachine : public CMachine 00035 { 00036 public: 00038 CDistanceMachine(); 00039 virtual ~CDistanceMachine(); 00040 00045 inline void set_distance(CDistance* d) 00046 { 00047 SG_UNREF(distance); 00048 SG_REF(d); 00049 distance=d; 00050 } 00051 00056 inline CDistance* get_distance() { SG_REF(distance); return distance; } 00057 00067 void distances_lhs(float64_t* result,int32_t idx_a1,int32_t idx_a2,int32_t idx_b); 00068 00078 void distances_rhs(float64_t* result,int32_t idx_b1,int32_t idx_b2,int32_t idx_a); 00079 00085 virtual const char* get_name() const { return "DistanceMachine"; } 00086 00094 virtual CMulticlassLabels* apply_multiclass(CFeatures* data=NULL); 00095 00103 virtual float64_t apply_one(int32_t num); 00104 00105 protected: 00115 virtual void store_model_features() 00116 { 00117 SG_ERROR("store_model_features not yet implemented for %s!\n", 00118 get_name()); 00119 } 00120 00126 static void* run_distance_thread_lhs(void* p); 00127 00133 static void* run_distance_thread_rhs(void* p); 00134 00135 private: 00136 void init(); 00137 00138 protected: 00140 CDistance* distance; 00141 }; 00142 } 00143 #endif