Ignore:
Timestamp:
Sep 5, 2006, 7:39:45 AM (15 years ago)
Author:
Peter
Message:

fixes #124 also extended interface of AveragerPairWeighted? supporting DataLookupWeighted1D

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/c++_tools/classifier/PolynomialKernelFunction.cc

    r616 r627  
    11// $Id$
    2 
    32
    43#include <c++_tools/classifier/PolynomialKernelFunction.h>
    54#include <c++_tools/classifier/DataLookup1D.h>
     5#include <c++_tools/classifier/DataLookupWeighted1D.h>
    66
    77#include <c++_tools/statistics/AveragerPairWeighted.h>
     
    1818}
    1919
     20
     21double PolynomialKernelFunction::operator()(const DataLookup1D& x,
     22                                            const DataLookup1D& y) const   
     23{
     24  assert(x.size()==y.size());
     25  return ((order_>1) ? pow(1+x*y,order_) : x*y);
     26}
     27
     28
     29double PolynomialKernelFunction::operator()(const DataLookup1D& x,
     30                                            const DataLookupWeighted1D& y) const
     31{
     32  assert(x.size()==y.size());
     33  statistics::AveragerPairWeighted averager;
     34  averager.add(x,y);
     35  if(order_>1)
     36    return pow(1+averager.sum_xy(),order_);
     37  return averager.sum_xy();
     38}
     39
     40
     41double PolynomialKernelFunction::operator()(const DataLookupWeighted1D& x,
     42                                            const DataLookupWeighted1D& y) const
     43{
     44  assert(x.size()==y.size());
     45  statistics::AveragerPairWeighted averager;
     46  averager.add(x,y);
     47  if(order_>1)
     48    return pow(1+averager.sum_xy(),order_);
     49  return averager.sum_xy();
     50}
     51
     52
    2053double PolynomialKernelFunction::operator()(const DataLookup1D& a1,
    2154                                            const DataLookup1D& a2,
     
    2760    averager.add(a1(i),a2(i),w1(i),w2(i));
    2861
    29   // a1.size() term to make it coherent with no weight case
    3062  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();
     63    return pow(1+averager.sum_xy(),order_);
     64  return averager.sum_xy();
    3365}
    3466
Note: See TracChangeset for help on using the changeset viewer.