source: trunk/lib/classifier/KernelWeighted_MEV.h @ 513

Last change on this file since 513 was 513, checked in by Peter, 16 years ago

added kernels using weights

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 1.9 KB
Line 
1// $Id: KernelWeighted_MEV.h 513 2006-02-18 16:02:43Z peter $
2
3#ifndef _theplu_classifier_kernel_weighted_mev_
4#define _theplu_classifier_kernel_weighted_mev_
5
6#include <c++_tools/classifier/Kernel.h>
7#include <c++_tools/classifier/KernelFunction.h>
8#include <c++_tools/gslapi/vector.h>
9#include <c++_tools/gslapi/matrix.h>
10
11namespace theplu {
12namespace classifier {
13
14  ///
15  ///   @brief Memory Efficient Kernel
16  ///   Class taking care of the \f$NxN\f$ kernel matrix, where
17  ///   \f$N\f$ is number of samples. Type of Kernel is defined by a
18  ///   KernelFunction. This Memory Efficient Version (MEV) does not
19  ///   store the kernel matrix in memory, but calculates each element
20  ///   when it is needed. When memory allows do always use Kernel_SEV
21  ///   instead.
22  ///   
23  ///   @see also KernelWeighted_SEV
24  ///
25  class KernelWeighted_MEV : public Kernel
26  {
27   
28  public:
29   
30    ///
31    ///   Constructor taking the \a data matrix, the KernelFunction and a
32    ///   \a weight matrix as input. Each column in the data matrix
33    ///   corresponds to one sample.
34    ///
35    /// @note if @a data, @a kf, or @a weights is destroyed the
36    /// behaviour of the object is undefined
37    ///
38    inline KernelWeighted_MEV(const gslapi::matrix& data, 
39                              const KernelFunction& kf, 
40                              const gslapi::matrix& weights)
41    : Kernel(data,kf), weights_(weights) {}
42
43    ///
44    /// @return Element at position (\a row, \a column) of the Kernel
45    /// matrix
46    ///
47    inline double operator()(const size_t row, const size_t column) const
48      { return (*kf_)(gslapi::vector(data_,row,false),
49                      gslapi::vector(data_,column,false),
50                      gslapi::vector(weights_,row,false),
51                      gslapi::vector(weights_,column,false)); }
52
53  private:
54    ///
55    /// Copy constructor (not implemented)
56    ///
57    KernelWeighted_MEV(const KernelWeighted_MEV&);
58
59    const gslapi::matrix& weights_;
60
61  };
62
63}} // of namespace classifier and namespace theplu
64
65#endif
Note: See TracBrowser for help on using the repository browser.