source: trunk/c++_tools/classifier/Kernel_SEV.cc @ 628

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

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

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date ID
File size: 1.6 KB
Line 
1// $Id$
2
3#include <c++_tools/classifier/Kernel_SEV.h>
4
5#include <c++_tools/classifier/DataLookup1D.h>
6#include <c++_tools/classifier/DataLookupWeighted1D.h>
7#include <c++_tools/classifier/Kernel.h>
8#include <c++_tools/classifier/KernelFunction.h>
9#include <c++_tools/classifier/MatrixLookup.h>
10#include <c++_tools/utility/matrix.h>
11
12namespace theplu {
13namespace classifier { 
14
15
16  Kernel_SEV::Kernel_SEV(const MatrixLookup& data, const KernelFunction& kf)
17    : Kernel(data,kf)
18  {
19    build_kernel();
20  }
21
22
23  Kernel_SEV::Kernel_SEV(const MatrixLookupWeighted& data, 
24                         const KernelFunction& kf)
25    : Kernel(data,kf)
26  {
27    kernel_matrix_ = utility::matrix(data_->columns(),data_->columns());
28    for (size_t i=0; i<kernel_matrix_.rows(); i++) 
29      for (size_t j=i; j<kernel_matrix_.columns(); j++)
30        kernel_matrix_(i,j) = kernel_matrix_(j,i) =
31          (*kf_)(DataLookupWeighted1D(data,i,false),
32                 DataLookupWeighted1D(data,j,false));
33  }
34
35
36  Kernel_SEV::Kernel_SEV(const Kernel_SEV& other, 
37                         const std::vector<size_t>& index)
38    : Kernel(other, index)
39  {
40    build_kernel();
41  }
42
43
44  void Kernel_SEV::build_kernel(void)
45  {
46    kernel_matrix_ = utility::matrix(data_->columns(),data_->columns());
47    for (size_t i=0; i<kernel_matrix_.rows(); i++) 
48      for (size_t j=i; j<kernel_matrix_.columns(); j++)
49        kernel_matrix_(i,j) = kernel_matrix_(j,i) =
50          (*kf_)(DataLookup1D(*data_,i,false),DataLookup1D(*data_,j,false));
51  }
52
53
54  const Kernel* Kernel_SEV::selected(const std::vector<size_t>& index) const
55  {
56    return new Kernel_SEV(*this, index);
57  }
58
59
60}} // of namespace classifier and namespace theplu
Note: See TracBrowser for help on using the repository browser.