Changeset 345
- Timestamp:
- Jun 8, 2005, 11:02:12 AM (18 years ago)
- Location:
- trunk
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/lib/svm/GaussianKernelFunction.h
r342 r345 36 36 /// returning the scalar product of two vectors in feature space using the 37 37 /// Gaussian kernel. @return \f$ exp((x - y)^{2}/\sigma^2) \f$ \n 38 39 38 /// 39 inline double operator()(const gslapi::vector& a1, 40 40 const gslapi::vector& a2) const 41 { return exp(-((a1-a2)*(a1-a2))/(sigma_*sigma_)); }41 { gslapi::vector a(a1); return exp(-((a-=a2)*a)/(sigma_*sigma_)); } 42 42 43 43 /// -
trunk/lib/svm/PolynomialKernelFunction.cc
r295 r345 7 7 #include <c++_tools/gslapi/vector.h> 8 8 9 #include < math.h>9 #include <cmath> 10 10 11 11 … … 16 16 : KernelFunction(), order_(order) 17 17 { 18 }19 20 double PolynomialKernelFunction::operator()(const gslapi::vector& a1,21 const gslapi::vector& a2) const22 {23 if(order_>1)24 return pow(1+a1*a2,order_);25 return a1*a2;26 18 } 27 19 -
trunk/lib/svm/PolynomialKernelFunction.h
r295 r345 5 5 6 6 #include <c++_tools/svm/KernelFunction.h> 7 #include <c++_tools/gslapi/vector.h> 8 9 #include <cmath> 10 7 11 8 12 namespace theplu { … … 39 43 ///y)^{order} \f$ \n If order is one (linear): \f$ x \cdot y \f$ 40 44 /// 41 double operator()(const gslapi::vector&, const gslapi::vector&) const; 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 42 49 43 50 /// -
trunk/test/kernel_test.cc
r307 r345 7 7 #include <c++_tools/gslapi/vector.h> 8 8 #include <c++_tools/svm/PolynomialKernelFunction.h> 9 #include <c++_tools/svm/GaussianKernelFunction.h> 9 10 #include <c++_tools/svm/Kernel_MEV.h> 10 11 #include <c++_tools/svm/Kernel_SEV.h> … … 69 70 ok = (ok && test_MEV(data,kf,kernel_matlab2,error_bound) 70 71 & test_SEV(data,kf,kernel_matlab2,error_bound)); 71 72 delete kf; 73 74 // Checking that a GaussianKernelFunction object can be built at 75 // compile time. 76 kf = new svm::GaussianKernelFunction(); 77 delete kf; 78 72 79 if (ok=true) 73 80 return 0;
Note: See TracChangeset
for help on using the changeset viewer.