SHOGUN  v1.1.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
DistanceMachine.h
Go to the documentation of this file.
1 /*
2  * This program is free software; you can redistribute it and/or modify
3  * it under the terms of the GNU General Public License as published by
4  * the Free Software Foundation; either version 3 of the License, or
5  * (at your option) any later version.
6  *
7  * Written (W) 2006-2009 Christian Gehl
8  * Written (W) 2006-2009 Soeren Sonnenburg
9  * Copyright (C) 1999-2009 Fraunhofer Institute FIRST and Max-Planck-Society
10  */
11 
12 #ifndef _DISTANCE_MACHINE_H__
13 #define _DISTANCE_MACHINE_H__
14 
15 #include <shogun/lib/common.h>
17 #include <shogun/features/Labels.h>
18 #include <shogun/machine/Machine.h>
19 
20 #include <stdio.h>
21 
22 namespace shogun
23 {
24  class CLabels;
25  class CDistance;
26  class CMachine;
27 
32 class CDistanceMachine : public CMachine
33 {
34  public:
37  virtual ~CDistanceMachine();
38 
43  inline void set_distance(CDistance* d)
44  {
46  SG_REF(d);
47  distance=d;
48  }
49 
54  inline CDistance* get_distance() { SG_REF(distance); return distance; }
55 
65  void distances_lhs(float64_t* result,int32_t idx_a1,int32_t idx_a2,int32_t idx_b);
66 
76  void distances_rhs(float64_t* result,int32_t idx_b1,int32_t idx_b2,int32_t idx_a);
77 
83  virtual const char* get_name() const { return "DistanceMachine"; }
84 
91  virtual CLabels* apply();
92 
100  virtual CLabels* apply(CFeatures* data);
101 
109  virtual float64_t apply(int32_t num);
110 
111  protected:
121  virtual void store_model_features()
122  {
123  SG_ERROR("store_model_features not yet implemented for %s!\n",
124  get_name());
125  }
126 
132  static void* run_distance_thread_lhs(void* p);
133 
139  static void* run_distance_thread_rhs(void* p);
140 
141  private:
142  void init();
143 
144  protected:
147 };
148 }
149 #endif
Class Distance, a base class for all the distances used in the Shogun toolbox.
Definition: Distance.h:77
virtual void store_model_features()
The class Labels models labels, i.e. class assignments of objects.
Definition: Labels.h:35
void distances_lhs(float64_t *result, int32_t idx_a1, int32_t idx_a2, int32_t idx_b)
#define SG_ERROR(...)
Definition: SGIO.h:75
static void * run_distance_thread_lhs(void *p)
virtual const char * get_name() const
#define SG_REF(x)
Definition: SGObject.h:44
A generic DistanceMachine interface.
A generic learning machine interface.
Definition: Machine.h:96
double float64_t
Definition: common.h:56
void distances_rhs(float64_t *result, int32_t idx_b1, int32_t idx_b2, int32_t idx_a)
#define SG_UNREF(x)
Definition: SGObject.h:45
The class Features is the base class of all feature objects.
Definition: Features.h:56
void set_distance(CDistance *d)
static void * run_distance_thread_rhs(void *p)
virtual CLabels * apply()

SHOGUN Machine Learning Toolbox - Documentation