SHOGUN  3.2.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
FirstElementKernelNormalizer.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) 2008-2009 Soeren Sonnenburg
8  * Copyright (C) 2008-2009 Fraunhofer Institute FIRST and Max-Planck-Society
9  */
10 
11 #ifndef _FIRSTELEMENTKERNELNORMALIZER_H___
12 #define _FIRSTELEMENTKERNELNORMALIZER_H___
13 
14 #include <shogun/lib/config.h>
15 
17 
18 namespace shogun
19 {
31 {
32  public:
36  {
37  SG_ADD(&scale, "scale", "Scale quotient by which kernel is scaled.",
38  MS_AVAILABLE);
39  }
40 
43  {
44  }
45 
48  virtual bool init(CKernel* k)
49  {
50  CFeatures* old_lhs=k->lhs;
51  CFeatures* old_rhs=k->rhs;
52  k->lhs=old_lhs;
53  k->rhs=old_lhs;
54 
55  scale=k->compute(0, 0);
56 
57  k->lhs=old_lhs;
58  k->rhs=old_rhs;
59 
60  return true;
61  }
62 
69  float64_t value, int32_t idx_lhs, int32_t idx_rhs)
70  {
71  return value/scale;
72  }
73 
78  virtual float64_t normalize_lhs(float64_t value, int32_t idx_lhs)
79  {
80  return value/sqrt(scale);
81  }
82 
87  virtual float64_t normalize_rhs(float64_t value, int32_t idx_rhs)
88  {
89  return value/sqrt(scale);
90  }
91 
93  virtual const char* get_name() const { return "FirstElementKernelNormalizer"; }
94 
95  protected:
98 };
99 }
100 #endif

SHOGUN Machine Learning Toolbox - Documentation