Ignore:
Timestamp:
Sep 5, 2006, 9:22:30 AM (15 years ago)
Author:
Peter
Message:

fixes #116 and #90 removed classes KernelWeighted_SEV and KernelWeighted_MEV and they're now absorbed into Kernel_SEV and Kernel_MEV, respectively.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/c++_tools/classifier/Kernel.cc

    r608 r628  
    33#include <c++_tools/classifier/Kernel.h>
    44
     5#include <c++_tools/classifier/DataLookup1D.h>
     6#include <c++_tools/classifier/DataLookupWeighted1D.h>
    57#include <c++_tools/classifier/KernelFunction.h>
    68#include <c++_tools/classifier/MatrixLookup.h>
     
    1214
    1315  Kernel::Kernel(const MatrixLookup& data, const KernelFunction& kf)
    14     : data_(&data), kf_(&kf), data_owner_(false), weight_owner_(true)
     16    : data_(&data), data_w_(0), kf_(&kf), data_owner_(false),
     17      weight_owner_(false)
    1518  {
    16     weights_ = new MatrixLookup(data_->rows(),data_->columns(),1.0);
    1719  }
    1820
    1921
    20   Kernel::Kernel(const MatrixLookup& data, const KernelFunction& kf,
    21                  const MatrixLookup& weights)
    22     : data_(&data), weights_(&weights), kf_(&kf), data_owner_(false),
     22  Kernel::Kernel(const MatrixLookupWeighted& data, const KernelFunction& kf)
     23    : data_(&data), data_w_(&data), kf_(&kf), data_owner_(false),
    2324      weight_owner_(false)
    2425  {
     
    2728
    2829  Kernel::Kernel(const Kernel& other, const std::vector<size_t>& index)
    29     : kf_(other.kf_), data_owner_(true), weight_owner_(true)
     30    : kf_(other.kf_), data_owner_(true)
    3031  {
    31     data_ = new MatrixLookup(*other.data_, index, true);
    32     weights_ = new MatrixLookup(*other.weights_, index, true);
     32    // Peter go through this code; look fishy!
     33    data_ = other.data_->selected(index);
     34    if (data_w_){
     35      data_w_ = other.data_w_->selected(index);
     36      weight_owner_=true;
     37    }
     38    else{
     39      data_w_=NULL;
     40      weight_owner_=false;
     41    }
     42
    3343  }
    3444
     
    3747    if (data_owner_)
    3848      delete data_;
     49     
    3950    if (weight_owner_)
    40       delete weights_;
     51      if (data_w_)
     52        delete data_w_;
     53      else
     54        std::cerr << "Error in Kernel implementation: probably a constructor"
     55                  << std::endl;
     56   
     57  }
     58
     59 
     60  double Kernel::element(const DataLookup1D& vec, const size_t i) const
     61  {
     62    if (data_w_)
     63      return kf_->operator()(vec, DataLookupWeighted1D(*data_w_,i, false));
     64    else
     65      return kf_->operator()(vec, DataLookup1D(*data_,i, false));
     66  }
     67
     68
     69  double Kernel::element(const DataLookupWeighted1D& vec, const size_t i) const
     70  {
     71    if (data_w_)
     72      return kf_->operator()(vec, DataLookupWeighted1D(*data_w_,i, false));
     73    else
     74      return kf_->operator()(vec, DataLookup1D(*data_,i, false));
    4175  }
    4276
Note: See TracChangeset for help on using the changeset viewer.