SHOGUN  v1.1.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
InverseMultiQuadricKernel.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 Abhinav Maurya
8  * Copyright (C) 2007-2011 Fraunhofer Institute FIRST and Max-Planck-Society
9  * Copyright (C) 2011 Indian Institute of Technology Bombay
10  */
11 
14 
15 using namespace shogun;
16 
18 {
19  init();
20 }
21 
23 : CKernel(cache), distance(dist), coef(coefficient)
24 {
26  init();
27 }
28 
30 : CKernel(10), distance(dist), coef(coefficient)
31 {
33  init();
34  init(l, r);
35 }
36 
38 {
39  cleanup();
41 }
42 
43 bool CInverseMultiQuadricKernel::init(CFeatures* l, CFeatures* r)
44 {
45  CKernel::init(l,r);
46  distance->init(l,r);
47  return init_normalizer();
48 }
49 
51 {
53 }
54 
55 void CInverseMultiQuadricKernel::init()
56 {
57  m_parameters->add(&coef, "coef", "Kernel Coefficient.");
58  m_parameters->add((CSGObject**) &distance, "distance", "Distance to be used.");
59 }
60 
61 float64_t CInverseMultiQuadricKernel::compute(int32_t idx_a, int32_t idx_b)
62 {
63  float64_t dist = distance->distance(idx_a, idx_b);
64  return 1/sqrt(dist*dist + coef*coef);
65 }

SHOGUN Machine Learning Toolbox - Documentation