1 | // $Id: Kernel_SEV.cc 542 2006-03-05 15:46:47Z peter $ |
---|
2 | |
---|
3 | #include <c++_tools/classifier/Kernel_SEV.h> |
---|
4 | |
---|
5 | #include <c++_tools/classifier/DataLookup1D.h> |
---|
6 | #include <c++_tools/classifier/Kernel.h> |
---|
7 | #include <c++_tools/classifier/KernelFunction.h> |
---|
8 | #include <c++_tools/classifier/MatrixLookup.h> |
---|
9 | #include <c++_tools/gslapi/matrix.h> |
---|
10 | #include <c++_tools/gslapi/vector.h> |
---|
11 | |
---|
12 | namespace theplu { |
---|
13 | namespace classifier { |
---|
14 | |
---|
15 | |
---|
16 | Kernel_SEV::Kernel_SEV(const MatrixLookup& data, const KernelFunction& kf) |
---|
17 | : Kernel(data,kf) |
---|
18 | { |
---|
19 | kernel_matrix_ = gslapi::matrix(data.columns(),data.columns()); |
---|
20 | for (size_t i=0; i<kernel_matrix_.rows(); i++) |
---|
21 | for (size_t j=i; j<kernel_matrix_.columns(); j++) |
---|
22 | kernel_matrix_(i,j) = kernel_matrix_(j,i) = |
---|
23 | (*kf_)(DataLookup1D(data_,i,false),DataLookup1D(data_,j,false)); |
---|
24 | } |
---|
25 | |
---|
26 | |
---|
27 | double Kernel_SEV::element(const DataLookup1D& vec, const size_t i) const |
---|
28 | { |
---|
29 | return kf_->operator()(vec, DataLookup1D(data_,i)); |
---|
30 | } |
---|
31 | |
---|
32 | double Kernel_SEV::element(const DataLookup1D& vec, const DataLookup1D& w, |
---|
33 | const size_t i) const |
---|
34 | { |
---|
35 | return (*kf_)(vec, DataLookup1D(data_,i), w, DataLookup1D(w.size(),1.0)); |
---|
36 | } |
---|
37 | |
---|
38 | |
---|
39 | }} // of namespace classifier and namespace theplu |
---|