# Changeset 163

Ignore:
Timestamp:
Sep 22, 2004, 7:14:06 PM (19 years ago)
Message:

Design of Kernel class modified

Location:
trunk/src
Files:
6 edited

Unmodified
Removed
• ## trunk/src/GaussianKernelFunction.cc

 r67 // Thep C++ Tools #include "GaussianKernelFunction.h" #include "matrix.h" #include "vector.h" } const theplu::gslapi::matrix& GaussianKernelFunction::operator()(theplu::gslapi::matrix& k, const theplu::gslapi::matrix& data) const { theplu::gslapi::matrix data_transposed(data); data_transposed.transpose(); k = data_transposed*data; // Working with the linear linear kernel in order to avoid copying // row vectors from data matrix (many times) and calculate the // kernel element in a more transparent way. for (size_t i=0; i
• ## trunk/src/GaussianKernelFunction.h

 r67 namespace cpptools { /** Class calculating one element in the kernel matrix using the Gaussian kernel. */ /// /// Class for Gaussian kernel calculations. /// public: ///Constructor taking the sigma_ , i.e. the width of the Gaussian,as /// ///Constructor taking the sigma_ , i.e. the width of the Gaussian,as ///input. Default is sigma_ = 1. /// GaussianKernelFunction(double = 1); ///Destructor /// ///Destructor /// virtual ~GaussianKernelFunction(void) {}; ///returning the scalar product of two vectors in feature space using the ///Gaussian kernel. @return \f$exp((x - y)^{2}/\sigma^2) \f$ \n /// /// 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, const gslapi::vector& w2) const; private: /// /// @kernel matrix /// const gslapi::matrix& operator()(theplu::gslapi::matrix& kernel, const theplu::gslapi::matrix& data) const; private: double sigma_;
• ## trunk/src/Kernel.cc

 r67 Kernel::Kernel(const gslapi::matrix& data, const KernelFunction& kf) : k_(data.rows(),data.rows()) : k_(data.columns(),data.columns()) { for(u_int i=0;i
• ## trunk/src/KernelFunction.h

 r99 namespace gslapi { class vector; class matrix; } /// ///   Virtual Class calculating one element in the kernel matrix ///   (i.e. the scalar product in feature space) from the two ///   corresponding vector in the data matrix. ///   Virtual Class calculating kernel matrix. /// class KernelFunction const gslapi::vector&) const = 0; }; // class KernelFunction virtual const theplu::gslapi::matrix& operator() (theplu::gslapi::matrix& k, const gslapi::matrix& data) const = 0; }; // class KernelFunction }} // of namespace cpptools and namespace theplu
• ## trunk/src/PolynomialKernelFunction.cc

 r67 // Thep C++ Tools #include "PolynomialKernelFunction.h" #include "matrix.h" #include "vector.h" { if(order_>1) return pow(a1*a2,order_); return pow(1+a1*a2,order_); return a1*a2; } } const theplu::gslapi::matrix& PolynomialKernelFunction::operator()(theplu::gslapi::matrix& kernel, const theplu::gslapi::matrix& data) const { theplu::gslapi::matrix data_transposed(data.transpose()); kernel = data_transposed*data; if (order_>1) for (size_t i=0; i
• ## trunk/src/PolynomialKernelFunction.h

 r100 namespace cpptools { ///Class calculating one element in the kernel matrix using the polynomial ///kernel. /// /// Class for polynomial kernel calculations /// public: ///Constructor taking the order of the polynomial as input. Default is /// ///Constructor taking the order of the polynomial as input. Default is ///order=1 yielding the linear kernel function. /// virtual ~PolynomialKernelFunction(void) {}; /// ///returning the scalar product of two vectors in feature space using the ///polynomial kernel. @return If order is larger than one: \f\$ (1+x \cdot double operator()(const gslapi::vector&, const gslapi::vector&) const; /// ///returning the scalar product of two vectors in feature space using the ///polynomial kernel with weights. const gslapi::vector&, const gslapi::vector&) const; /// /// @kernel matrix /// const gslapi::matrix& operator()(theplu::gslapi::matrix& kernel, const theplu::gslapi::matrix& data) const; private: int order_;
Note: See TracChangeset for help on using the changeset viewer.