1 | // $Id: Kernel_SEV.h 542 2006-03-05 15:46:47Z peter $ |
---|
2 | |
---|
3 | #ifndef _theplu_classifier_kernel_sev_ |
---|
4 | #define _theplu_classifier_kernel_sev_ |
---|
5 | |
---|
6 | #include <c++_tools/classifier/Kernel.h> |
---|
7 | #include <c++_tools/gslapi/matrix.h> |
---|
8 | |
---|
9 | |
---|
10 | namespace theplu { |
---|
11 | namespace classifier { |
---|
12 | |
---|
13 | class DataLookup1D; |
---|
14 | class KernelFunction; |
---|
15 | |
---|
16 | /// |
---|
17 | /// @brief Speed Efficient Kernel |
---|
18 | /// Class taking care of the \f$NxN\f$ kernel matrix, where |
---|
19 | /// \f$N\f$ is number of samples. Type of Kernel is defined by a |
---|
20 | /// KernelFunction. This Speed Efficient Version (SEV) calculated |
---|
21 | /// the kernel matrix once and the kernel is stored in |
---|
22 | /// memory. When \f$N\f$ is large and the kernel matrix cannot be |
---|
23 | /// stored in memory, use Kernel_MEV instead. |
---|
24 | /// |
---|
25 | /// @see also Kernel_MEV |
---|
26 | /// |
---|
27 | class Kernel_SEV : public Kernel |
---|
28 | { |
---|
29 | |
---|
30 | public: |
---|
31 | |
---|
32 | /// |
---|
33 | /// Default constructor (not implemented) |
---|
34 | /// |
---|
35 | Kernel_SEV(void); |
---|
36 | |
---|
37 | /// |
---|
38 | /// Constructor taking the data matrix and KernelFunction as |
---|
39 | /// input. @note Can not handle NaNs. When dealing with missing values, |
---|
40 | /// use constructor taking a weight matrix. |
---|
41 | Kernel_SEV(const MatrixLookup&, const KernelFunction&); |
---|
42 | |
---|
43 | /// |
---|
44 | /// Copy constructor (not implemented) |
---|
45 | /// |
---|
46 | Kernel_SEV(const Kernel_SEV&); |
---|
47 | |
---|
48 | /// |
---|
49 | /// Destructor |
---|
50 | /// |
---|
51 | inline virtual ~Kernel_SEV(void) {}; |
---|
52 | |
---|
53 | /// |
---|
54 | /// @return element at position (\a row, \a column) in the Kernel |
---|
55 | /// matrix |
---|
56 | /// |
---|
57 | inline double operator()(const size_t row,const size_t column) const |
---|
58 | { return kernel_matrix_(row,column); } |
---|
59 | |
---|
60 | /// |
---|
61 | /// @return kernel element between data @a ve and training sample @a i |
---|
62 | /// |
---|
63 | double element(const DataLookup1D& vec, const size_t i) const; |
---|
64 | double element(const DataLookup1D& vec, const DataLookup1D& w, |
---|
65 | const size_t i) const; |
---|
66 | |
---|
67 | |
---|
68 | private: |
---|
69 | gslapi::matrix kernel_matrix_; |
---|
70 | |
---|
71 | }; // class Kernel_SEV |
---|
72 | |
---|
73 | }} // of namespace classifier and namespace theplu |
---|
74 | |
---|
75 | #endif |
---|