DistanceMachine.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  * 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/features/Labels.h>
00018 #include <shogun/machine/Machine.h>
00019 
00020 #include <stdio.h>
00021 
00022 namespace shogun
00023 {
00024     class CLabels;
00025     class CDistance;
00026     class CMachine;
00027 
00032 class CDistanceMachine : public CMachine
00033 {
00034     public:
00036         CDistanceMachine();
00037         virtual ~CDistanceMachine();
00038 
00043         inline void set_distance(CDistance* d)
00044         {
00045             SG_UNREF(distance);
00046             SG_REF(d);
00047             distance=d;
00048         }
00049 
00054         inline CDistance* get_distance() { SG_REF(distance); return distance; }
00055 
00065         void distances_lhs(float64_t* result,int32_t idx_a1,int32_t idx_a2,int32_t idx_b);
00066 
00076         void distances_rhs(float64_t* result,int32_t idx_b1,int32_t idx_b2,int32_t idx_a);  
00077 
00083         virtual const char* get_name() const { return "DistanceMachine"; }
00084 
00091         virtual CLabels* apply();
00092 
00100         virtual CLabels* apply(CFeatures* data);
00101 
00109         virtual float64_t apply(int32_t num);
00110 
00111     protected:
00121         virtual void store_model_features()
00122         {
00123             SG_ERROR("store_model_features not yet implemented for %s!\n",
00124                     get_name());
00125         }
00126 
00132         static void* run_distance_thread_lhs(void* p);
00133 
00139         static void* run_distance_thread_rhs(void* p);
00140 
00141     private:
00142         void init();
00143 
00144     protected:
00146         CDistance* distance;
00147 };
00148 }
00149 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

SHOGUN Machine Learning Toolbox - Documentation