1 | // $Id$ |
---|
2 | |
---|
3 | /* |
---|
4 | Copyright (C) 2006, 2007 Jari Häkkinen, Peter Johansson |
---|
5 | Copyright (C) 2008 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 | |
---|
29 | namespace theplu { |
---|
30 | namespace yat { |
---|
31 | namespace 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 (weighted()) |
---|
71 | return (*kf_)(DataLookupWeighted1D(*mlw_,row,false), |
---|
72 | DataLookupWeighted1D(*mlw_,column,false)); |
---|
73 | else |
---|
74 | return (*kf_)(DataLookup1D(*ml_,row,false), |
---|
75 | DataLookup1D(*ml_,column,false)); |
---|
76 | } |
---|
77 | |
---|
78 | |
---|
79 | |
---|
80 | }}} // of namespace classifier, yat, and theplu |
---|