SHOGUN  v1.1.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
TStudentKernel.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 Andrew Tereskin
8  * Copyright (C) 2011 Berlin Institute of Technology and Max-Planck-Society
9  */
10 
11 #include <math.h>
14 
15 using namespace shogun;
16 
17 void CTStudentKernel::init()
18 {
19  m_parameters->add(&degree, "degree", "Kernel degree.");
20  m_parameters->add((CSGObject**) &distance, "distance", "Distance to be used.");
21 }
22 
23 CTStudentKernel::CTStudentKernel(): CKernel(0), distance(NULL), degree(1.0)
24 {
25  init();
26 }
27 
29 : CKernel(cache), distance(dist), degree(d)
30 {
31  init();
34 }
35 
37 : CKernel(10), distance(dist), degree(d)
38 {
39  init();
42  init(l, r);
43 }
44 
46 {
47  cleanup();
49 }
50 
51 bool CTStudentKernel::init(CFeatures* l, CFeatures* r)
52 {
54  CKernel::init(l,r);
55  distance->init(l,r);
56  return init_normalizer();
57 }
58 
59 float64_t CTStudentKernel::compute(int32_t idx_a, int32_t idx_b)
60 {
61  float64_t dist = distance->distance(idx_a, idx_b);
62  return 1.0/(1.0+CMath::pow(dist, this->degree));
63 }

SHOGUN Machine Learning Toolbox - Documentation