source: trunk/yat/classifier/Kernel_MEV.h @ 680

Last change on this file since 680 was 680, checked in by Jari Häkkinen, 15 years ago

Addresses #153. Introduced yat namespace. Removed alignment namespace. Clean up of code.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date ID
File size: 3.8 KB
Line 
1#ifndef _theplu_yat_classifier_kernel_mev_
2#define _theplu_yat_classifier_kernel_mev_
3
4// $Id$
5
6/*
7  Copyright (C) The authors contributing to this file.
8
9  This file is part of the yat library, http://lev.thep.lu.se/trac/yat
10
11  The yat library is free software; you can redistribute it and/or
12  modify it under the terms of the GNU General Public License as
13  published by the Free Software Foundation; either version 2 of the
14  License, or (at your option) any later version.
15
16  The yat library is distributed in the hope that it will be useful,
17  but WITHOUT ANY WARRANTY; without even the implied warranty of
18  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19  General Public License for more details.
20
21  You should have received a copy of the GNU General Public License
22  along with this program; if not, write to the Free Software
23  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
24  02111-1307, USA.
25*/
26
27#include "DataLookup1D.h"
28#include "Kernel.h"
29#include "KernelFunction.h"
30
31namespace theplu {
32namespace yat {
33namespace classifier {
34  class MatrixLookup;
35  class MatrixLookupWeighted;
36
37  ///
38  /// @brief Memory Efficient Kernel
39  ///
40  ///   Class taking care of the
41  ///   \f$ NxN \f$ kernel matrix, where \f$ N \f$ is number of
42  ///   samples. Type of Kernel is defined by a KernelFunction. This
43  ///   Memory Efficient Version (MEV) does not store the kernel
44  ///   matrix in memory, but calculates an element when it is
45  ///   needed. When memory allows do always use Kernel_SEV
46  ///   instead.
47  ///
48  class Kernel_MEV : public Kernel
49  {
50   
51  public:
52   
53    ///
54    /// Constructor taking the data matrix and KernelFunction as
55    /// input.Each column in the data matrix corresponds to one
56    /// sample. @note Can not handle NaNs.
57    ///
58    Kernel_MEV(const MatrixLookup& data, const KernelFunction& kf, 
59               const bool own=false);
60
61
62    ///
63    /// Constructor taking the data matrix and KernelFunction as
64    /// input.Each column in the data matrix corresponds to one
65    /// sample. @note Can not handle NaNs.
66    ///
67    Kernel_MEV(const MatrixLookupWeighted& data, const KernelFunction& kf,
68               const bool own=false);
69
70
71    ///
72    /// Constructing a new Kernel based on selected features @a
73    /// index. All other seeting are the same.
74    ///
75    Kernel_MEV(const Kernel_MEV& kernel, const std::vector<size_t>& index);
76
77
78    ///
79    /// @return Element at position (\a row, \a column) of the Kernel
80    /// matrix
81    ///
82    double operator()(const size_t row, const size_t column) const;
83   
84    ///
85    /// An interface for making new classifier objects. This function
86    /// allows for specification at run-time of which kernel to
87    /// instatiate (see 'Prototype' in Design Patterns).
88    ///
89    /// @Note Returns a dynamically allocated Kernel, which has
90    /// to be deleted by the caller to avoid memory leaks.
91    ///
92    const Kernel_MEV* make_kernel(const MatrixLookup&, 
93                                  const bool own=false) const;
94
95
96    ///
97    /// An interface for making new classifier objects. This function
98    /// allows for specification at run-time of which kernel to
99    /// instatiate (see 'Prototype' in Design Patterns).
100    ///
101    /// @Note Returns a dynamically allocated Kernel, which has
102    /// to be deleted by the caller to avoid memory leaks.
103    ///
104    const Kernel_MEV* make_kernel(const MatrixLookupWeighted&, 
105                                  const bool own=false) const;
106
107
108    ///
109    /// @see Kernel_MEV(const Kernel_MEV&, const std::vector<size_t>&);
110
111    ///
112    /// @note returns dynamically allocated pointer that must be
113    /// deleted by the caller to avoid memory leaks.
114    ///
115    const Kernel_MEV* selected(const std::vector<size_t>& index) const;
116
117  private:
118    ///
119    /// Copy constructor (not implemented)
120    ///
121    Kernel_MEV(const Kernel_MEV&);
122    const Kernel_MEV& operator=(const Kernel_MEV&);
123
124  }; // class Kernel_MEV
125
126}}} // of namespace classifier, yat, and theplu
127
128#endif
Note: See TracBrowser for help on using the repository browser.