source: trunk/yat/classifier/Kernel_MEV.cc @ 1146

Last change on this file since 1146 was 1146, checked in by Peter, 14 years ago

DataLookup1D is now a lookup into a MatrixLookup? closes #327

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date ID
File size: 2.2 KB
Line 
1// $Id$
2
3/*
4  Copyright (C) 2006 Jari Häkkinen, Peter Johansson
5  Copyright (C) 2007 Peter Johansson
6
7  This file is part of the yat library, http://trac.thep.lu.se/yat
8
9  The yat library is free software; you can redistribute it and/or
10  modify it under the terms of the GNU General Public License as
11  published by the Free Software Foundation; either version 2 of the
12  License, or (at your option) any later version.
13
14  The yat library is distributed in the hope that it will be useful,
15  but WITHOUT ANY WARRANTY; without even the implied warranty of
16  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17  General Public License for more details.
18
19  You should have received a copy of the GNU General Public License
20  along with this program; if not, write to the Free Software
21  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
22  02111-1307, USA.
23*/
24
25#include "Kernel_MEV.h"
26#include "DataLookup1D.h"
27#include "DataLookupWeighted1D.h"
28
29namespace theplu {
30namespace yat {
31namespace classifier { 
32
33  Kernel_MEV::Kernel_MEV(const MatrixLookup& data, const KernelFunction& kf,
34                         const bool own)
35    : Kernel(data,kf,own) 
36  {
37  }
38
39
40  Kernel_MEV::Kernel_MEV(const MatrixLookupWeighted& data, 
41                         const KernelFunction& kf, const bool own)
42    : Kernel(data,kf,own) 
43  {
44  }
45
46
47  Kernel_MEV::Kernel_MEV(const Kernel_MEV& kernel, 
48                         const std::vector<size_t>& index)
49    : Kernel(kernel,index)
50  {
51  }
52
53
54  const Kernel_MEV* Kernel_MEV::make_kernel(const MatrixLookup& data, 
55                                            const bool own) const
56  {
57    return new Kernel_MEV(data, *kf_, own);
58  }
59
60
61  const Kernel_MEV* Kernel_MEV::make_kernel(const MatrixLookupWeighted& data, 
62                                            const bool own) const
63  {
64    return new Kernel_MEV(data, *kf_, own);
65  }
66
67
68  double Kernel_MEV::operator()(const size_t row, const size_t column) const
69  { 
70    if (data_w_)
71      return (*kf_)(DataLookupWeighted1D(*data_w_,row,false),
72                    DataLookupWeighted1D(*data_w_,column,false)); 
73    else
74      return (*kf_)(DataLookup1D(dynamic_cast<const MatrixLookup&>
75                                 (*data_),row,false),
76                    DataLookup1D(dynamic_cast<const MatrixLookup&>
77                                 (*data_),column,false)); 
78  }
79
80
81
82}}} // of namespace classifier, yat, and theplu
Note: See TracBrowser for help on using the repository browser.