Changeset 353


Ignore:
Timestamp:
Jun 9, 2005, 1:28:35 AM (17 years ago)
Author:
Peter
Message:

removed function returning the whole matrix. It is not needed anymore and should not be there for simplistic reasons.

Location:
trunk/lib/svm
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/lib/svm/GaussianKernelFunction.cc

    r295 r353  
    3434
    3535
    36 const theplu::gslapi::matrix&
    37 GaussianKernelFunction::operator()(theplu::gslapi::matrix& k,
    38                                    const theplu::gslapi::matrix& data) const
    39 {
    40   theplu::gslapi::matrix data_transposed(data);
    41   data_transposed.transpose();
    42   k = data_transposed*data;
    43   // Working with the linear linear kernel in order to avoid copying
    44   // row vectors from data matrix (many times) and calculate the
    45   // kernel element in a more transparent way.
    46   for (size_t i=0; i<k.rows()-1; i++)
    47     for (size_t j=i+1; j<k.columns(); j++)
    48       k(i,j)=k(j,i)=exp(-(k(i,i)+k(j,j)-2*k(i,j))/(2*sigma_));
    49   for (size_t i=0; i<k.rows(); i++)
    50     k(i,i)=1;
    51   return k;
    52 }
    5336
    5437}} // of namespace svn and namespace theplu
  • trunk/lib/svm/GaussianKernelFunction.h

    r345 r353  
    5050                      const gslapi::vector& w2) const;
    5151         
    52     ///
    53     /// @return kernel matrix
    54     ///
    55     const gslapi::matrix& operator()(theplu::gslapi::matrix& kernel,
    56                                      const theplu::gslapi::matrix& data) const;
    57  
    5852  private:
    5953    double sigma_;
  • trunk/lib/svm/KernelFunction.h

    r295 r353  
    4444                              const gslapi::vector&) const = 0;
    4545   
    46     ///
    47     /// @return kernel matrix
    48     ///
    49     virtual const theplu::gslapi::matrix& operator()
    50       (theplu::gslapi::matrix& k, const gslapi::matrix& data) const = 0;
    51  
    5246  }; // class KernelFunction
    5347
  • trunk/lib/svm/PolynomialKernelFunction.cc

    r345 r353  
    3636}
    3737
    38 const theplu::gslapi::matrix&
    39 PolynomialKernelFunction::operator()(theplu::gslapi::matrix& kernel,
    40                                      const theplu::gslapi::matrix& data) const
    41 {
    42   gslapi::matrix data_transposed(data.transpose());
    43   kernel = data_transposed*data;
    44   if (order_>1)
    45     for (size_t i=0; i<kernel.rows(); i++)
    46       for (size_t j=i; j<kernel.rows(); j++)
    47         kernel(i,j)=kernel(j,i)=pow(1+kernel(i,j),order_);
    48   return kernel;
    49 }
    5038}} // of namespace cpptools and namespace theplu
  • trunk/lib/svm/PolynomialKernelFunction.h

    r345 r353  
    5555                      const gslapi::vector&, const gslapi::vector&) const;
    5656   
    57     ///
    58     /// @return kernel matrix
    59     ///
    60     const gslapi::matrix& operator()(theplu::gslapi::matrix& kernel,
    61                                      const theplu::gslapi::matrix& data) const;
    62 
    6357  private:
    6458    int order_;
Note: See TracChangeset for help on using the changeset viewer.