SHOGUN  3.2.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
BesselKernel.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 Zi Yuan
8  * Copyright (C) 2011 Berlin Institute of Technology and Max-Planck-Society
9  */
10 
13 #include <math.h>
14 
15 using namespace shogun;
16 
18 {
19  init();
20 }
21 
23  int32_t n, CDistance* dist) :
24  CDistanceKernel(size,w,dist), order(v), degree(n)
25 {
28  init();
29 }
30 
32  float64_t w, int32_t n, CDistance* dist, int32_t size) :
33  CDistanceKernel(size,w,dist), order(v), degree(n)
34 {
35  init();
38  init(l,r);
39 }
40 
42 {
43  cleanup();
45 }
46 
48 {
49 }
50 
51 bool CBesselKernel::init(CFeatures* l, CFeatures* r)
52 {
54  CDistanceKernel::init(l,r);
55  distance->init(l,r);
56  return init_normalizer();
57 }
58 
59 void CBesselKernel::init()
60 {
61  SG_ADD(&order, "order", "Kernel order.", MS_AVAILABLE);
62  SG_ADD(&degree, "degree", "Kernel degree.", MS_AVAILABLE);
63 }
64 
65 float64_t CBesselKernel::compute(int32_t idx_a, int32_t idx_b)
66 {
67  float64_t dist = distance->distance(idx_a, idx_b);
68  return jn(order,dist/width)/CMath::pow(dist,-degree*order);
69 }

SHOGUN Machine Learning Toolbox - Documentation