SHOGUN  3.2.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
MultiquadricKernel.cpp
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) 2011 Joanna Stocka
8  * Copyright (C) 2007-2011 Fraunhofer Institute FIRST and Max-Planck-Society
9  */
10 
13 
14 using namespace shogun;
15 
16 CMultiquadricKernel::CMultiquadricKernel(): CKernel(0), m_distance(NULL), m_coef(0.0001)
17 {
18  init();
19 }
20 
22 : CKernel(cache), m_distance(dist), m_coef(coef)
23 {
26  init();
27 }
28 
30 : CKernel(10), m_distance(dist), m_coef(coef)
31 {
34  init(l, r);
35  init();
36 }
37 
39 {
40  cleanup();
42 }
43 
44 bool CMultiquadricKernel::init(CFeatures* l, CFeatures* r)
45 {
47  CKernel::init(l,r);
48  m_distance->init(l,r);
49  return init_normalizer();
50 }
51 
52 float64_t CMultiquadricKernel::compute(int32_t idx_a, int32_t idx_b)
53 {
54  float64_t dist = m_distance->distance(idx_a, idx_b);
55  return sqrt(CMath::sq(dist) + CMath::sq(m_coef));
56 }
57 
58 void CMultiquadricKernel::init()
59 {
60  SG_ADD(&m_coef, "coef", "Kernel coefficient.", MS_AVAILABLE);
61  SG_ADD((CSGObject**) &m_distance, "distance", "Distance to be used.",
62  MS_AVAILABLE);
63 }

SHOGUN Machine Learning Toolbox - Documentation