source: trunk/lib/classifier/Kernel_SEV.cc @ 523

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

add prediction functions to SVM

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 857 bytes
Line 
1// $Id: Kernel_SEV.cc 523 2006-02-23 08:52:04Z peter $
2
3#include <c++_tools/classifier/Kernel_SEV.h>
4
5#include <c++_tools/classifier/Kernel.h>
6#include <c++_tools/classifier/KernelFunction.h>
7#include <c++_tools/gslapi/matrix.h>
8#include <c++_tools/gslapi/vector.h>
9
10namespace theplu {
11namespace classifier { 
12
13
14  Kernel_SEV::Kernel_SEV(const gslapi::matrix& data, const KernelFunction& kf)
15    : Kernel(data,kf)
16  {
17    kernel_matrix_ = gslapi::matrix(data.columns(),data.columns());
18    for (size_t i=0; i<kernel_matrix_.rows(); i++) 
19      for (size_t j=i; j<kernel_matrix_.columns(); j++) 
20        kernel_matrix_(i,j) = kernel_matrix_(j,i) =
21          (*kf_)(gslapi::vector(data_,i,false),gslapi::vector(data_,j,false));
22  }
23
24  double Kernel_SEV::element(const gslapi::vector& vec, const size_t i) const
25  { 
26    return kf_->operator()(vec, gslapi::vector(data_,i)); 
27  }
28
29
30}} // of namespace classifier and namespace theplu
Note: See TracBrowser for help on using the repository browser.