Changeset 336


Ignore:
Timestamp:
Jun 3, 2005, 4:16:19 PM (17 years ago)
Author:
Peter
Message:

moved members data_ and kf_ from base class Kernel to Kernel_SEV and Kernel_MEV. These two classes should perhaps in future be inherited from a intervening class since they are overlapping, but different from KernelView?.

Location:
trunk/lib/svm
Files:
1 deleted
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/lib/svm/Kernel.h

    r333 r336  
    11// $Id$
    22
    3 #ifndef _theplu_svm_kernel
    4 #define _theplu_svm_kernel
     3#ifndef _theplu_svm_kernel_
     4#define _theplu_svm_kernel_
    55
    6 #include <c++_tools/gslapi/matrix.h>
     6#include <cctype>
    77
    88namespace theplu {
     9
     10namespace gslapi {
     11  class matrix;
     12}
     13
    914namespace svm {
    1015
     
    3035    /// Default constructor
    3136    ///
    32     Kernel(void);
     37    Kernel(void) {};
    3338
    3439    ///
    35     /// Copy constructor
     40    /// Copy constructor (not implemented)
    3641    ///
    37     /// @note SHALLOW copy performed.
    38     ///
    39     Kernel(const Kernel&);
     42    Kernel(const Kernel&);
    4043
    4144    ///
     
    4447    ///   sample. @note Can not handle NaNs.
    4548    ///
    46     Kernel(const gslapi::matrix&, const KernelFunction&);
     49    Kernel(const gslapi::matrix&, const KernelFunction&) {};
    4750   
    4851    ///
     
    5154    ///   \a weight matrix as input. Each column in the data matrix
    5255    ///   corresponds to one sample.
    53     Kernel(const gslapi::matrix& data, const KernelFunction&,
    54                const gslapi::matrix& weight);
     56    Kernel(const gslapi::matrix& data, const KernelFunction&,
     57           const gslapi::matrix& weight);
    5558
    5659    ///
    5760    ///   Destructor
    5861    ///
    59     virtual ~Kernel(void);
     62    virtual ~Kernel(void) {};
    6063
    6164    ///
     
    6871    /// @brief number of samples
    6972    ///
    70     virtual size_t size(void) const;
     73    virtual size_t size(void) const=0;
    7174   
    7275  protected:
    73     const gslapi::matrix& data_;
    74     const KernelFunction* kf_;
    75 
    76     virtual bool is_view(void) const;
    7776
    7877  }; // class Kernel
  • trunk/lib/svm/KernelView.cc

    r333 r336  
    1010
    1111KernelView::KernelView(const Kernel& kernel, const std::vector<size_t>& index)
    12   : Kernel(kernel), kernel_(&kernel), index_(index)
     12  : Kernel(), kernel_(&kernel), index_(index)
    1313{
    1414  // to view into the original kernel rather than a view
  • trunk/lib/svm/KernelView.h

    r333 r336  
    5858    /// @brief number of samples
    5959    ///
    60     size_t size(void) const { return index_.size(); }
     60    inline size_t size(void) const { return index_.size(); }
    6161   
    6262
  • trunk/lib/svm/Kernel_MEV.cc

    r330 r336  
    1111
    1212  Kernel_MEV::Kernel_MEV(const gslapi::matrix& data, const KernelFunction& kf)
    13     : Kernel(data, kf)
     13    : Kernel(data, kf), data_(data), kf_(&kf)
    1414  {
    1515  }
     
    2323
    2424
    25   double Kernel_MEV::operator()(size_t row, size_t column) const
    26   {
    27     return (*kf_)(data_.TEMP_col_return(row),data_.TEMP_col_return(column));
    28   }
    29 
    3025
    3126}} // of namespace svm and namespace theplu
  • trunk/lib/svm/Kernel_MEV.h

    r330 r336  
    11// $Id$
    22
    3 #ifndef _theplu_svm_kernel_mev
    4 #define _theplu_svm_kernel_mev
     3#ifndef _theplu_svm_kernel_mev_
     4#define _theplu_svm_kernel_mev_
    55
    66#include <c++_tools/svm/Kernel.h>
     7#include <c++_tools/svm/KernelFunction.h>
    78#include <c++_tools/gslapi/matrix.h>
    89
    910namespace theplu {
    1011namespace svm {
    11 
    12   class KernelFunction;
    1312
    1413  ///
     
    4847               const gslapi::matrix& weight);
    4948
     49    ///
     50    /// Copy constructor (not implemented)
     51    ///
     52    Kernel_MEV(const Kernel_MEV&);
     53
    5054    ///
    5155    ///   Destructor
     
    5761    /// matrix
    5862    ///
    59     double operator()(const size_t row,const size_t column) const;
     63    double operator()(const size_t row,const size_t column) const
     64    { return (*kf_)(data_.TEMP_col_return(row),data_.TEMP_col_return(column)); }
    6065
     66    ///
     67    /// @brief number of samples
     68    ///
     69    inline size_t size(void) const { return data_.columns(); }
     70
     71  private:
     72    const gslapi::matrix& data_;
     73    const KernelFunction* kf_;
    6174
    6275  }; // class Kernel_MEV
  • trunk/lib/svm/Kernel_SEV.cc

    r330 r336  
    1212
    1313Kernel_SEV::Kernel_SEV(const gslapi::matrix& data, const KernelFunction& kf)
    14   : Kernel(data,kf)
     14  : Kernel(data,kf), data_(data), kf_(&kf)
    1515{
    1616  kernel_matrix_ = gslapi::matrix(data.columns(),data.columns());
  • trunk/lib/svm/Kernel_SEV.h

    r333 r336  
    44#define _theplu_svm_kernel_sev_
    55
     6#include <c++_tools/svm/Kernel.h>
    67#include <c++_tools/gslapi/matrix.h>
    7 #include <c++_tools/svm/Kernel.h>
    88
    99
     
    4141   
    4242    ///
    43     /// @todo
    44     /// Copy constructor
     43    /// Copy constructor (not implemented)
    4544    ///
    4645    Kernel_SEV(const Kernel_SEV&);
     
    5756    inline double operator()(const size_t row,const size_t column) const
    5857    { return kernel_matrix_(row,column); }
    59    
     58
     59    ///
     60    /// @brief number of samples
     61    ///
     62    inline size_t size(void) const { return kernel_matrix_.columns(); }
     63
    6064  private:
     65    const gslapi::matrix& data_;
     66    const KernelFunction* kf_;
    6167    gslapi::matrix kernel_matrix_;
    6268
  • trunk/lib/svm/Makefile.am

    r331 r336  
    1010libsvm_la_SOURCES = \
    1111  ConsensusInputRanker.cc CrossValidation.cc GaussianKernelFunction.cc \
    12   InputRanker.cc Kernel.cc Kernel_MEV.cc Kernel_SEV.cc KernelView.cc\
    13   PolynomialKernelFunction.cc  SVM.cc
     12  InputRanker.cc Kernel_MEV.cc Kernel_SEV.cc KernelView.cc \
     13  PolynomialKernelFunction.cc SVM.cc
    1414
    1515include_svmdir = $(includedir)/c++_tools/svm
Note: See TracChangeset for help on using the changeset viewer.