source: trunk/lib/classifier/PolynomialKernelFunction.cc @ 524

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

fixed bug PolynimialKernelFunction? - can now handle NaNs? with weights

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 918 bytes
Line 
1// $Id: PolynomialKernelFunction.cc 524 2006-02-23 15:55:33Z peter $
2
3
4#include <c++_tools/classifier/PolynomialKernelFunction.h>
5
6#include <c++_tools/gslapi/matrix.h>
7#include <c++_tools/gslapi/vector.h>
8#include <c++_tools/statistics/AveragerPairWeighted.h>
9
10#include <cmath>
11
12
13namespace theplu {
14namespace classifier { 
15
16PolynomialKernelFunction::PolynomialKernelFunction(int order) 
17  : KernelFunction(), order_(order)
18{
19}
20
21double PolynomialKernelFunction::operator()(const gslapi::vector& a1,
22                                            const gslapi::vector& a2,
23                                            const gslapi::vector& w1,
24                                            const gslapi::vector& w2) const   
25{
26  statistics::AveragerPairWeighted averager;
27  averager.add(a1,a2,w1,w2);
28
29  // a1.size() term to make it coherent with no weight case
30  if(order_>1) 
31    return pow(1+averager.sum_xy()/averager.sum_w()*a1.size(),order_);
32  return averager.sum_xy()/averager.sum_w()*a1.size();
33}
34
35}} // of namespace cpptools and namespace theplu
Note: See TracBrowser for help on using the repository browser.