Changeset 548


Ignore:
Timestamp:
Mar 6, 2006, 7:00:05 PM (16 years ago)
Author:
Peter
Message:

fixed bug in Kernels

Location:
trunk/lib/classifier
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/lib/classifier/KernelWeighted_SEV.cc

    r545 r548  
    1919    : Kernel(data,kf,weights)
    2020  {
    21     kernel_matrix_ = gslapi::matrix(data.columns(),data.columns());
     21    build_kernel();
     22  }
     23 
     24
     25  KernelWeighted_SEV::KernelWeighted_SEV(const KernelWeighted_SEV& other,
     26                                         const std::vector<size_t>& index)
     27    : Kernel(other, index)
     28  {
     29    build_kernel();
     30  }
     31 
     32
     33  void KernelWeighted_SEV::build_kernel(void)
     34  {
     35    kernel_matrix_ = gslapi::matrix(data_->columns(),data_->columns());
    2236    for (size_t i=0; i<kernel_matrix_.rows(); i++)
    2337      for (size_t j=i; j<kernel_matrix_.columns(); j++)
     
    2842                 DataLookup1D(*weights_,j,false));
    2943  }
    30  
    3144
    32   KernelWeighted_SEV::KernelWeighted_SEV(const KernelWeighted_SEV& other,
    33                                          const std::vector<size_t>& index)
    34     : Kernel(other, index)
    35   {
    36   }
    37  
    3845
    3946  const KernelWeighted_SEV*
  • trunk/lib/classifier/KernelWeighted_SEV.h

    r545 r548  
    3333
    3434    ///
    35     ///   Constructor taking the data matrix and KernelFunction as
    36     ///   input. @note Can not handle NaNs. When dealing with missing values,
    37     ///   use constructor taking a weight matrix.
     35    ///  Constructor taking the data matrix and KernelFunction as
     36    ///  input. @note Can not handle NaNs. When dealing with missing values,
     37    ///  use constructor taking a weight matrix.
    3838    ///
    3939    /// @note if @a data, @a kf, or @a weights is destroyed the
     
    4949                       const std::vector<size_t>& index);
    5050   
     51
    5152    ///
    5253    /// @return element at position (\a row, \a column) in the Kernel
     
    6667    }
    6768
     69    ///
     70    /// @todo doc
     71    ///
    6872    inline double element(const DataLookup1D& vec, const DataLookup1D& w,
    6973                          const size_t i) const
     
    8690    KernelWeighted_SEV(const KernelWeighted_SEV&);
    8791
     92    ///
     93    /// Building Kernel matrix
     94    ///
     95    void build_kernel(void);
     96
    8897    gslapi::matrix kernel_matrix_;
    8998
  • trunk/lib/classifier/Kernel_SEV.cc

    r545 r548  
    1717    : Kernel(data,kf)
    1818  {
    19     kernel_matrix_ = gslapi::matrix(data.columns(),data.columns());
     19    build_kernel();
     20  }
     21
     22  Kernel_SEV::Kernel_SEV(const Kernel_SEV& other,
     23                         const std::vector<size_t>& index)
     24    : Kernel(other, index)
     25  {
     26    build_kernel();
     27  }
     28
     29
     30  void Kernel_SEV::build_kernel(void)
     31  {
     32    kernel_matrix_ = gslapi::matrix(data_->columns(),data_->columns());
    2033    for (size_t i=0; i<kernel_matrix_.rows(); i++)
    2134      for (size_t j=i; j<kernel_matrix_.columns(); j++)
     
    2437  }
    2538
    26   Kernel_SEV::Kernel_SEV(const Kernel_SEV& other,
    27                          const std::vector<size_t>& index)
    28     : Kernel(other, index)
    29   {
    30   }
    3139
    3240  double Kernel_SEV::element(const DataLookup1D& vec, const size_t i) const
  • trunk/lib/classifier/Kernel_SEV.h

    r545 r548  
    3131
    3232    ///
    33     ///  Default constructor (not implemented)
    34     ///
    35     Kernel_SEV(void);
    36 
    37     ///
    3833    ///   Constructor taking the data matrix and KernelFunction as
    3934    ///   input. @note Can not handle NaNs. When dealing with missing values,
     
    4136    Kernel_SEV(const MatrixLookup&, const KernelFunction&);
    4237   
    43     ///
    44     /// Copy constructor (not implemented)
    45     ///
    46     Kernel_SEV(const Kernel_SEV&);
    47 
    4838    ///
    4939    /// @todo doc
     
    5949
    6050    ///
    61     /// @return kernel element between data @a ve and training sample @a i
     51    /// @return kernel element between data @a vec and training sample @a i
    6252    ///
    6353    double element(const DataLookup1D& vec, const size_t i) const;
     54
     55    ///
     56    /// @todo doc
     57    ///
    6458    double element(const DataLookup1D& vec, const DataLookup1D& w,
    6559                   const size_t i) const;
    6660
     61    ///
     62    /// @todo doc
     63    ///
    6764    const Kernel* selected(const std::vector<size_t>& index) const;
    6865
     66    ///
     67    /// @return false
     68    ///
    6969    inline bool weighted(void) const { return false; }
     70
    7071  private:
     72    ///
     73    /// Copy constructor (not implemented)
     74    ///
     75    Kernel_SEV(const Kernel_SEV&);
     76
     77    void build_kernel(void);
     78
    7179    gslapi::matrix kernel_matrix_;
    7280
Note: See TracChangeset for help on using the changeset viewer.