SHOGUN  4.2.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
ECOCEDDecoder.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) 2012 Chiyuan Zhang
8  * Copyright (C) 2012 Chiyuan Zhang
9  */
10 
11 #ifndef ECOCEDDECODER_H__
12 #define ECOCEDDECODER_H__
13 
14 #include <shogun/lib/config.h>
15 
18 
19 namespace shogun
20 {
21 
29 {
30 public:
33 
35  virtual ~CECOCEDDecoder() {}
36 
38  virtual const char* get_name() const { return "ECOCEDDecoder"; }
39 
40 
41 protected:
43  virtual bool binary_decoding()
44  {
45  return false;
46  }
47 
49  virtual float64_t compute_distance(SGVector<float64_t> outputs, const int32_t *code)
50  {
51  float64_t dist = 0;
52  for (int32_t i=0; i < outputs.vlen; ++i)
53  dist += (outputs[i]-code[i])*(outputs[i]-code[i]);
54  return CMath::sqrt(dist);
55  }
56 };
57 
58 } /* shogun */
59 
60 #endif /* end of include guard: ECOCEDDECODER_H__ */
61 
index_t vlen
Definition: SGVector.h:494
double float64_t
Definition: common.h:50
all of classes and functions are contained in the shogun namespace
Definition: class_list.h:18
virtual const char * get_name() const
Definition: ECOCEDDecoder.h:38
virtual float64_t compute_distance(SGVector< float64_t > outputs, const int32_t *code)
Definition: ECOCEDDecoder.h:49
static float32_t sqrt(float32_t x)
Definition: Math.h:459
virtual bool binary_decoding()
Definition: ECOCEDDecoder.h:43

SHOGUN Machine Learning Toolbox - Documentation