SHOGUN  v2.0.0
 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 
15 
16 namespace shogun
17 {
29 {
30  public:
34  {
35  SG_ADD(&scale, "scale", "Scale quotient by which kernel is scaled.",
36  MS_AVAILABLE);
37  }
38 
41  {
42  }
43 
46  virtual bool init(CKernel* k)
47  {
48  CFeatures* old_lhs=k->lhs;
49  CFeatures* old_rhs=k->rhs;
50  k->lhs=old_lhs;
51  k->rhs=old_lhs;
52 
53  scale=k->compute(0, 0);
54 
55  k->lhs=old_lhs;
56  k->rhs=old_rhs;
57 
58  return true;
59  }
60 
66  inline virtual float64_t normalize(
67  float64_t value, int32_t idx_lhs, int32_t idx_rhs)
68  {
69  return value/scale;
70  }
71 
76  inline virtual float64_t normalize_lhs(float64_t value, int32_t idx_lhs)
77  {
78  return value/sqrt(scale);
79  }
80 
85  inline virtual float64_t normalize_rhs(float64_t value, int32_t idx_rhs)
86  {
87  return value/sqrt(scale);
88  }
89 
91  inline virtual const char* get_name() const { return "FirstElementKernelNormalizer"; }
92 
93  protected:
96 };
97 }
98 #endif

SHOGUN Machine Learning Toolbox - Documentation