4200 |
19 Aug 22 |
peter |
1 |
#ifndef _theplu_yat_classifier_dataLookup1D_ |
4200 |
19 Aug 22 |
peter |
2 |
#define _theplu_yat_classifier_dataLookup1D_ |
467 |
17 Dec 05 |
peter |
3 |
|
675 |
10 Oct 06 |
jari |
// $Id$ |
467 |
17 Dec 05 |
peter |
5 |
|
675 |
10 Oct 06 |
jari |
6 |
/* |
831 |
27 Mar 07 |
peter |
Copyright (C) 2005 Peter Johansson |
2119 |
12 Dec 09 |
peter |
Copyright (C) 2006 Jari Häkkinen, Peter Johansson, Markus Ringnér |
4359 |
23 Aug 23 |
peter |
Copyright (C) 2007 Peter Johansson |
4359 |
23 Aug 23 |
peter |
Copyright (C) 2008 Jari Häkkinen, Peter Johansson |
4359 |
23 Aug 23 |
peter |
Copyright (C) 2009 Peter Johansson |
675 |
10 Oct 06 |
jari |
12 |
|
1437 |
25 Aug 08 |
peter |
This file is part of the yat library, http://dev.thep.lu.se/yat |
675 |
10 Oct 06 |
jari |
14 |
|
675 |
10 Oct 06 |
jari |
The yat library is free software; you can redistribute it and/or |
675 |
10 Oct 06 |
jari |
modify it under the terms of the GNU General Public License as |
1486 |
09 Sep 08 |
jari |
published by the Free Software Foundation; either version 3 of the |
675 |
10 Oct 06 |
jari |
License, or (at your option) any later version. |
675 |
10 Oct 06 |
jari |
19 |
|
675 |
10 Oct 06 |
jari |
The yat library is distributed in the hope that it will be useful, |
675 |
10 Oct 06 |
jari |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
675 |
10 Oct 06 |
jari |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
675 |
10 Oct 06 |
jari |
General Public License for more details. |
675 |
10 Oct 06 |
jari |
24 |
|
675 |
10 Oct 06 |
jari |
You should have received a copy of the GNU General Public License |
1487 |
10 Sep 08 |
jari |
along with yat. If not, see <http://www.gnu.org/licenses/>. |
675 |
10 Oct 06 |
jari |
27 |
*/ |
675 |
10 Oct 06 |
jari |
28 |
|
1146 |
25 Feb 08 |
peter |
29 |
#include "MatrixLookup.h" |
882 |
22 Sep 07 |
peter |
30 |
|
2076 |
06 Oct 09 |
peter |
31 |
#include <iosfwd> |
767 |
22 Feb 07 |
peter |
32 |
#include <vector> |
467 |
17 Dec 05 |
peter |
33 |
|
467 |
17 Dec 05 |
peter |
34 |
namespace theplu { |
680 |
11 Oct 06 |
jari |
35 |
namespace yat { |
767 |
22 Feb 07 |
peter |
36 |
namespace utility { |
1018 |
01 Feb 08 |
peter |
37 |
class VectorBase; |
767 |
22 Feb 07 |
peter |
38 |
} |
4200 |
19 Aug 22 |
peter |
39 |
namespace classifier { |
467 |
17 Dec 05 |
peter |
40 |
|
467 |
17 Dec 05 |
peter |
41 |
/// |
4200 |
19 Aug 22 |
peter |
/// @brief Class for general vector view. |
467 |
17 Dec 05 |
peter |
43 |
/// |
1268 |
09 Apr 08 |
peter |
44 |
class DataLookup1D |
1268 |
09 Apr 08 |
peter |
45 |
{ |
1268 |
09 Apr 08 |
peter |
46 |
public: |
1552 |
06 Oct 08 |
peter |
47 |
/** |
1552 |
06 Oct 08 |
peter |
value_type is double |
1552 |
06 Oct 08 |
peter |
49 |
|
1552 |
06 Oct 08 |
peter |
\since New in yat 0.5 |
1552 |
06 Oct 08 |
peter |
51 |
*/ |
1552 |
06 Oct 08 |
peter |
52 |
typedef MatrixLookup::value_type value_type; |
1552 |
06 Oct 08 |
peter |
53 |
|
1552 |
06 Oct 08 |
peter |
54 |
/** |
1552 |
06 Oct 08 |
peter |
const_reference type is const double& |
1552 |
06 Oct 08 |
peter |
56 |
|
1552 |
06 Oct 08 |
peter |
\since New in yat 0.5 |
1552 |
06 Oct 08 |
peter |
58 |
*/ |
1552 |
06 Oct 08 |
peter |
59 |
typedef MatrixLookup::const_reference const_reference; |
1552 |
06 Oct 08 |
peter |
60 |
|
966 |
11 Oct 07 |
peter |
/// 'Read Only' iterator |
1525 |
24 Sep 08 |
peter |
62 |
typedef MatrixLookup::const_row_iterator const_iterator; |
880 |
21 Sep 07 |
peter |
63 |
|
467 |
17 Dec 05 |
peter |
64 |
/// |
4200 |
19 Aug 22 |
peter |
/// Constructor. |
467 |
17 Dec 05 |
peter |
66 |
/// |
1268 |
09 Apr 08 |
peter |
/// \param m MatrixLookup to look into |
648 |
14 Sep 06 |
peter |
/// @param row_vector if true DataLookup1D is looking into a |
1170 |
27 Feb 08 |
peter |
/// row of MatrixLookup, otherwise looking into a |
648 |
14 Sep 06 |
peter |
/// column. @param index which row/column to look into. |
533 |
03 Mar 06 |
peter |
71 |
/// |
4200 |
19 Aug 22 |
peter |
72 |
DataLookup1D(const MatrixLookup& m, const size_t index, |
565 |
16 Mar 06 |
peter |
73 |
const bool row_vector); |
467 |
17 Dec 05 |
peter |
74 |
|
469 |
19 Dec 05 |
peter |
75 |
/// |
537 |
05 Mar 06 |
peter |
/// Copy constructor |
469 |
19 Dec 05 |
peter |
77 |
/// |
537 |
05 Mar 06 |
peter |
78 |
DataLookup1D(const DataLookup1D&); |
537 |
05 Mar 06 |
peter |
79 |
|
469 |
19 Dec 05 |
peter |
80 |
/// |
537 |
05 Mar 06 |
peter |
/// Construct DataLookup1D that owns its underlying matrix. Object |
537 |
05 Mar 06 |
peter |
/// has size @ size and all its element is equal to @a value. |
537 |
05 Mar 06 |
peter |
83 |
/// |
4200 |
19 Aug 22 |
peter |
84 |
DataLookup1D(const size_t size, const double value=0); |
473 |
22 Dec 05 |
peter |
85 |
|
767 |
22 Feb 07 |
peter |
86 |
/** |
1018 |
01 Feb 08 |
peter |
@brief Create general view from utility::VectorBase |
4200 |
19 Aug 22 |
peter |
88 |
|
767 |
22 Feb 07 |
peter |
Constructor creates a proper MatrixLookup that object can view |
4200 |
19 Aug 22 |
peter |
into. Object is owner of this underlying MatrixLookup. Object fulfills |
767 |
22 Feb 07 |
peter |
\f$ x(i) = vec(index(i)) \f$ |
767 |
22 Feb 07 |
peter |
92 |
*/ |
4200 |
19 Aug 22 |
peter |
93 |
DataLookup1D(const utility::VectorBase& vec, |
4200 |
19 Aug 22 |
peter |
94 |
const std::vector<size_t>& index); |
767 |
22 Feb 07 |
peter |
95 |
|
815 |
17 Mar 07 |
peter |
96 |
/** |
1018 |
01 Feb 08 |
peter |
@brief Create general view from utility::VectorBase |
4200 |
19 Aug 22 |
peter |
98 |
|
815 |
17 Mar 07 |
peter |
Constructor creates a proper MatrixLookup that object can view |
4200 |
19 Aug 22 |
peter |
into. Object is owner of this underlying MatrixLookup. Object fulfills |
815 |
17 Mar 07 |
peter |
\f$ x(i) = vec(i) \f$ |
815 |
17 Mar 07 |
peter |
102 |
*/ |
4200 |
19 Aug 22 |
peter |
103 |
DataLookup1D(const utility::VectorBase& vec); |
815 |
17 Mar 07 |
peter |
104 |
|
473 |
22 Dec 05 |
peter |
105 |
/// |
4200 |
19 Aug 22 |
peter |
/// @brief Destructor deletes underlying MatrixLookup if object is owner |
473 |
22 Dec 05 |
peter |
107 |
/// |
537 |
05 Mar 06 |
peter |
108 |
virtual ~DataLookup1D(); |
537 |
05 Mar 06 |
peter |
109 |
|
880 |
21 Sep 07 |
peter |
110 |
/** |
966 |
11 Oct 07 |
peter |
\return 'Read Only' iterator to first element. |
880 |
21 Sep 07 |
peter |
112 |
*/ |
880 |
21 Sep 07 |
peter |
113 |
const_iterator begin() const; |
880 |
21 Sep 07 |
peter |
114 |
|
880 |
21 Sep 07 |
peter |
115 |
/** |
966 |
11 Oct 07 |
peter |
\return 'Read Only' iterator to end of DataLookup1D. |
880 |
21 Sep 07 |
peter |
117 |
*/ |
880 |
21 Sep 07 |
peter |
118 |
const_iterator end() const; |
880 |
21 Sep 07 |
peter |
119 |
|
537 |
05 Mar 06 |
peter |
120 |
/// |
648 |
14 Sep 06 |
peter |
/// @return number of elements |
537 |
05 Mar 06 |
peter |
122 |
/// |
720 |
26 Dec 06 |
jari |
123 |
size_t size(void) const; |
467 |
17 Dec 05 |
peter |
124 |
|
467 |
17 Dec 05 |
peter |
125 |
/// |
648 |
14 Sep 06 |
peter |
/// @brief access operator |
467 |
17 Dec 05 |
peter |
127 |
/// |
720 |
26 Dec 06 |
jari |
128 |
double operator()(const size_t i) const; |
467 |
17 Dec 05 |
peter |
129 |
|
527 |
01 Mar 06 |
peter |
130 |
/// |
527 |
01 Mar 06 |
peter |
/// scalar product |
527 |
01 Mar 06 |
peter |
132 |
/// |
527 |
01 Mar 06 |
peter |
133 |
double operator*(const DataLookup1D&) const; |
527 |
01 Mar 06 |
peter |
134 |
|
469 |
19 Dec 05 |
peter |
135 |
private: |
1525 |
24 Sep 08 |
peter |
// assignment no allowed |
555 |
08 Mar 06 |
peter |
137 |
const DataLookup1D& operator=(const DataLookup1D&); |
467 |
17 Dec 05 |
peter |
138 |
|
469 |
19 Dec 05 |
peter |
139 |
const bool column_vector_; |
469 |
19 Dec 05 |
peter |
140 |
const size_t index_; |
1146 |
25 Feb 08 |
peter |
141 |
const MatrixLookup* matrix_; |
537 |
05 Mar 06 |
peter |
142 |
const bool owner_; |
4200 |
19 Aug 22 |
peter |
143 |
|
1268 |
09 Apr 08 |
peter |
144 |
}; |
593 |
25 Aug 06 |
markus |
145 |
|
527 |
01 Mar 06 |
peter |
146 |
/// |
593 |
25 Aug 06 |
markus |
/// @brief The output operator for DataLookup1D. |
527 |
01 Mar 06 |
peter |
148 |
/// |
593 |
25 Aug 06 |
markus |
149 |
/** |
593 |
25 Aug 06 |
markus |
* Elements are separated by the character from the omanip fill. |
593 |
25 Aug 06 |
markus |
* The following example will write the elements separated by tab. |
4200 |
19 Aug 22 |
peter |
152 |
* |
4200 |
19 Aug 22 |
peter |
@verbatim |
4200 |
19 Aug 22 |
peter |
char prev=s.fill('\t'); |
593 |
25 Aug 06 |
markus |
s << v; |
4200 |
19 Aug 22 |
peter |
s.fill(prev); |
593 |
25 Aug 06 |
markus |
@endverbatim |
1883 |
31 Mar 09 |
peter |
158 |
|
1883 |
31 Mar 09 |
peter |
\relates DataLookup1D |
593 |
25 Aug 06 |
markus |
160 |
*/ |
593 |
25 Aug 06 |
markus |
161 |
std::ostream& operator<<(std::ostream& s, const DataLookup1D& v); |
4200 |
19 Aug 22 |
peter |
162 |
|
680 |
11 Oct 06 |
jari |
163 |
}}} // of namespace classifier, yat, and theplu |
467 |
17 Dec 05 |
peter |
164 |
|
467 |
17 Dec 05 |
peter |
165 |
#endif |