1 | #ifndef _theplu_yat_utility_index_ |
---|
2 | #define _theplu_yat_utility_index_ |
---|
3 | |
---|
4 | // $Id: Index.h 1437 2008-08-25 17:55:00Z peter $ |
---|
5 | |
---|
6 | /* |
---|
7 | Copyright (C) 2008 Peter Johansson |
---|
8 | |
---|
9 | This file is part of the yat library, http://dev.thep.lu.se/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 "SmartPtr.h" |
---|
28 | |
---|
29 | #include <vector> |
---|
30 | |
---|
31 | namespace theplu { |
---|
32 | namespace yat { |
---|
33 | namespace utility { |
---|
34 | |
---|
35 | /// |
---|
36 | /// Internal Class keeping track of which samples are support vectors and |
---|
37 | /// not. The first nof_sv elements in the vector are indices of the |
---|
38 | /// support vectors |
---|
39 | /// |
---|
40 | class Index |
---|
41 | { |
---|
42 | public: |
---|
43 | /** |
---|
44 | Creates an empty Index |
---|
45 | */ |
---|
46 | Index(void); |
---|
47 | |
---|
48 | /** |
---|
49 | Created Index will satisfy a[i] = i. |
---|
50 | \param n size of created Index |
---|
51 | */ |
---|
52 | Index(size_t n); |
---|
53 | |
---|
54 | /** |
---|
55 | Constructed Index c will satisfy c[i]=a[b[i]] |
---|
56 | */ |
---|
57 | Index(const Index& a, const Index& b); |
---|
58 | |
---|
59 | /** |
---|
60 | \brief Constructor |
---|
61 | */ |
---|
62 | explicit Index(const SmartPtr<const std::vector<size_t> >& vec); |
---|
63 | |
---|
64 | /** |
---|
65 | \brief Constructor |
---|
66 | |
---|
67 | vec is copied |
---|
68 | */ |
---|
69 | explicit Index(const std::vector<size_t>& vec); |
---|
70 | |
---|
71 | /** |
---|
72 | \brief access operator |
---|
73 | */ |
---|
74 | const size_t& operator[](size_t) const; |
---|
75 | |
---|
76 | /** |
---|
77 | \brief number of elements |
---|
78 | */ |
---|
79 | size_t size(void) const; |
---|
80 | |
---|
81 | /** |
---|
82 | \return underlying vector |
---|
83 | */ |
---|
84 | const std::vector<size_t>& vector(void) const; |
---|
85 | |
---|
86 | private: |
---|
87 | // using compiler generated copy |
---|
88 | // Index(const Index&); |
---|
89 | // const Index& operator=(const Index&); |
---|
90 | |
---|
91 | SmartPtr<const std::vector<size_t> > index_; |
---|
92 | }; |
---|
93 | |
---|
94 | }}} // of namespace utility, yat, and theplu |
---|
95 | |
---|
96 | #endif |
---|