1 | // $Id: Kernel_MEV.h 350 2005-06-08 19:19:51Z peter $ |
---|
2 | |
---|
3 | #ifndef _theplu_svm_kernel_mev_ |
---|
4 | #define _theplu_svm_kernel_mev_ |
---|
5 | |
---|
6 | #include <c++_tools/svm/Kernel.h> |
---|
7 | #include <c++_tools/svm/KernelFunction.h> |
---|
8 | #include <c++_tools/gslapi/matrix.h> |
---|
9 | |
---|
10 | namespace theplu { |
---|
11 | namespace svm { |
---|
12 | |
---|
13 | /// |
---|
14 | /// @brief Memory Efficient Kernel |
---|
15 | /// Class taking care of the \f$NxN\f$ kernel matrix, where |
---|
16 | /// \f$N\f$ is number of samples. Type of Kernel is defined by a |
---|
17 | /// KernelFunction. This Memory Efficient Version (MEV) does not |
---|
18 | /// store the kernel matrix in memory, but calculates each element |
---|
19 | /// when it is needed. When memory allows do always use Kernel_SEV |
---|
20 | /// instead. |
---|
21 | /// |
---|
22 | /// @see also Kernel_SEV |
---|
23 | /// |
---|
24 | class Kernel_MEV : public Kernel |
---|
25 | { |
---|
26 | |
---|
27 | public: |
---|
28 | |
---|
29 | /// |
---|
30 | /// Default constructor (not implemented) |
---|
31 | /// |
---|
32 | Kernel_MEV(); |
---|
33 | |
---|
34 | /// |
---|
35 | /// Constructor taking the data matrix and KernelFunction as |
---|
36 | /// input.Each column in the data matrix corresponds to one |
---|
37 | /// sample. @note Can not handle NaNs. |
---|
38 | /// |
---|
39 | Kernel_MEV(const gslapi::matrix&, const KernelFunction&); |
---|
40 | |
---|
41 | /// |
---|
42 | /// @todo Constructor taking the \a data matrix, the KernelFunction and a |
---|
43 | /// \a weight matrix as input. Each column in the data matrix |
---|
44 | /// corresponds to one sample. |
---|
45 | Kernel_MEV(const gslapi::matrix& data, const KernelFunction&, |
---|
46 | const gslapi::matrix& weight); |
---|
47 | |
---|
48 | /// |
---|
49 | /// Copy constructor (not implemented) |
---|
50 | /// |
---|
51 | Kernel_MEV(const Kernel_MEV&); |
---|
52 | |
---|
53 | /// |
---|
54 | /// Destructor |
---|
55 | /// |
---|
56 | virtual ~Kernel_MEV(void); |
---|
57 | |
---|
58 | /// |
---|
59 | /// @return element at position (\a row, \a column) of the Kernel |
---|
60 | /// matrix |
---|
61 | /// |
---|
62 | double operator()(const size_t row,const size_t column) const |
---|
63 | { return (*kf_)(data_.TEMP_col_return(row),data_.TEMP_col_return(column)); } |
---|
64 | |
---|
65 | /// |
---|
66 | /// @brief number of samples |
---|
67 | /// |
---|
68 | inline size_t size(void) const { return data_.columns(); } |
---|
69 | |
---|
70 | private: |
---|
71 | const gslapi::matrix& data_; |
---|
72 | const KernelFunction* kf_; |
---|
73 | |
---|
74 | }; // class Kernel_MEV |
---|
75 | |
---|
76 | }} // of namespace svm and namespace theplu |
---|
77 | |
---|
78 | #endif |
---|