source: trunk/lib/classifier/Kernel.cc @ 549

Last change on this file since 549 was 549, checked in by Peter, 16 years ago

forgot to add file

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 1.0 KB
RevLine 
[549]1// $Id: Kernel.cc 549 2006-03-07 09:43:57Z peter $
2
3#include <c++_tools/classifier/Kernel.h>
4
5#include <c++_tools/classifier/KernelFunction.h>
6#include <c++_tools/classifier/MatrixLookup.h>
7
8#include <vector>
9
10namespace theplu {
11namespace classifier {
12
13  Kernel::Kernel(const MatrixLookup& data, const KernelFunction& kf) 
14    : data_(&data), kf_(&kf), data_owner_(false), weight_owner_(true)
15  {
16    weights_ = new MatrixLookup(data_->rows(),data_->columns(),1.0);
17  }
18
19
20  Kernel::Kernel(const MatrixLookup& data, const KernelFunction& kf,
21                 const MatrixLookup& weights) 
22    : data_(&data), weights_(&weights), kf_(&kf), data_owner_(false), 
23      weight_owner_(false)
24  {
25  }
26
27
28  Kernel::Kernel(const Kernel& other, const std::vector<size_t>& index)
29    : kf_(other.kf_), data_owner_(true), weight_owner_(true)
30  {
31    data_ = new MatrixLookup(*other.data_, index, true);
32    weights_ = new MatrixLookup(*other.weights_, index, true);
33  }
34
35  Kernel::~Kernel()
36  {
37    if (data_owner_)
38      delete data_;
39    if (weight_owner_)
40      delete weights_;
41  }
42
43}} // of namespace classifier and namespace theplu
Note: See TracBrowser for help on using the repository browser.