# Changeset 345

Ignore:
Timestamp:
Jun 8, 2005, 11:02:12 AM (18 years ago)
Message:

Made some efficiency changes in KernelFunctions?. Added a small test in kernel_test.cc

Location:
trunk
Files:
4 edited

Unmodified
Removed
• ## trunk/lib/svm/GaussianKernelFunction.h

 r342 /// returning the scalar product of two vectors in feature space using the /// Gaussian kernel. @return \f$exp((x - y)^{2}/\sigma^2) \f$ \n /// inline double operator()(const gslapi::vector& a1, /// inline double operator()(const gslapi::vector& a1, const gslapi::vector& a2) const { return exp(-((a1-a2)*(a1-a2))/(sigma_*sigma_)); } { gslapi::vector a(a1); return exp(-((a-=a2)*a)/(sigma_*sigma_)); } ///
• ## trunk/lib/svm/PolynomialKernelFunction.cc

 r295 #include #include #include : KernelFunction(), order_(order) { } double PolynomialKernelFunction::operator()(const gslapi::vector& a1, const gslapi::vector& a2) const { if(order_>1) return pow(1+a1*a2,order_); return a1*a2; }
• ## trunk/lib/svm/PolynomialKernelFunction.h

 r295 #include #include #include namespace theplu { ///y)^{order} \f$\n If order is one (linear): \f$ x \cdot y \f\$ /// double operator()(const gslapi::vector&, const gslapi::vector&) const; inline double operator()(const gslapi::vector& a1, const gslapi::vector& a2) const { return ((order_>1) ? pow(1+a1*a2,order_) : a1*a2); } ///
• ## trunk/test/kernel_test.cc

 r307 #include #include #include #include #include ok = (ok && test_MEV(data,kf,kernel_matlab2,error_bound) & test_SEV(data,kf,kernel_matlab2,error_bound)); delete kf; // Checking that a GaussianKernelFunction object can be built at // compile time. kf = new svm::GaussianKernelFunction(); delete kf; if (ok=true) return 0;
Note: See TracChangeset for help on using the changeset viewer.