source: trunk/c++_tools/classifier/PolynomialKernelFunction.cc @ 616

Last change on this file since 616 was 616, checked in by Jari Häkkinen, 15 years ago

Removed gslapi namespace and put the code into utility namespace.
Move #ifndef _header_ idiom to top of touched header files.
Removed unneccesary #includes, and added needed #includes.

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