Last change
on this file since 353 was
353,
checked in by Peter, 17 years ago
|
removed function returning the whole matrix. It is not needed anymore and should not be there for simplistic reasons.
|
-
Property svn:eol-style set to
native
-
Property svn:keywords set to
Author Date Id Revision
|
File size:
1.4 KB
|
Line | |
---|
1 | // $Id: PolynomialKernelFunction.h 353 2005-06-08 23:28:35Z peter $ |
---|
2 | |
---|
3 | #ifndef _theplu_svm_polynomial_kernel_function_ |
---|
4 | #define _theplu_svm_polynomial_kernel_function_ |
---|
5 | |
---|
6 | #include <c++_tools/svm/KernelFunction.h> |
---|
7 | #include <c++_tools/gslapi/vector.h> |
---|
8 | |
---|
9 | #include <cmath> |
---|
10 | |
---|
11 | |
---|
12 | namespace theplu { |
---|
13 | |
---|
14 | namespace gslapi { |
---|
15 | class vector; |
---|
16 | } |
---|
17 | |
---|
18 | namespace svm { |
---|
19 | |
---|
20 | /// |
---|
21 | /// Class for polynomial kernel calculations |
---|
22 | /// |
---|
23 | |
---|
24 | |
---|
25 | class PolynomialKernelFunction : public KernelFunction |
---|
26 | { |
---|
27 | |
---|
28 | public: |
---|
29 | /// |
---|
30 | ///Constructor taking the order of the polynomial as input. Default is |
---|
31 | ///order=1 yielding the linear kernel function. |
---|
32 | /// |
---|
33 | PolynomialKernelFunction(int = 1); |
---|
34 | |
---|
35 | /// |
---|
36 | ///Destructor |
---|
37 | /// |
---|
38 | virtual ~PolynomialKernelFunction(void) {}; |
---|
39 | |
---|
40 | /// |
---|
41 | ///returning the scalar product of two vectors in feature space using the |
---|
42 | ///polynomial kernel. @return If order is larger than one: \f$ (1+x \cdot |
---|
43 | ///y)^{order} \f$ \n If order is one (linear): \f$ x \cdot y \f$ |
---|
44 | /// |
---|
45 | inline double operator()(const gslapi::vector& a1, |
---|
46 | const gslapi::vector& a2) const |
---|
47 | { return ((order_>1) ? pow(1+a1*a2,order_) : a1*a2); } |
---|
48 | |
---|
49 | |
---|
50 | /// |
---|
51 | ///returning the scalar product of two vectors in feature space using the |
---|
52 | ///polynomial kernel with weights. |
---|
53 | /// |
---|
54 | double operator()(const gslapi::vector&, const gslapi::vector&, |
---|
55 | const gslapi::vector&, const gslapi::vector&) const; |
---|
56 | |
---|
57 | private: |
---|
58 | int order_; |
---|
59 | |
---|
60 | }; // class PolynomialKernelFunction |
---|
61 | |
---|
62 | }} // of namespace svm and namespace theplu |
---|
63 | |
---|
64 | #endif |
---|
Note: See
TracBrowser
for help on using the repository browser.