A.I.M.S algorithms


histogram.h
Go to the documentation of this file.
1 /* This software and supporting documentation are distributed by
2  * Institut Federatif de Recherche 49
3  * CEA/NeuroSpin, Batiment 145,
4  * 91191 Gif-sur-Yvette cedex
5  * France
6  *
7  * This software is governed by the CeCILL-B license under
8  * French law and abiding by the rules of distribution of free software.
9  * You can use, modify and/or redistribute the software under the
10  * terms of the CeCILL-B license as circulated by CEA, CNRS
11  * and INRIA at the following URL "http://www.cecill.info".
12  *
13  * As a counterpart to the access to the source code and rights to copy,
14  * modify and redistribute granted by the license, users are provided only
15  * with a limited warranty and the software's author, the holder of the
16  * economic rights, and the successive licensors have only limited
17  * liability.
18  *
19  * In this respect, the user's attention is drawn to the risks associated
20  * with loading, using, modifying and/or developing or reproducing the
21  * software by the user in light of its specific status of free software,
22  * that may mean that it is complicated to manipulate, and that also
23  * therefore means that it is reserved for developers and experienced
24  * professionals having in-depth computer knowledge. Users are therefore
25  * encouraged to load and test the software's suitability as regards their
26  * requirements in conditions enabling the security of their systems and/or
27  * data to be ensured and, more generally, to use and operate it in the
28  * same conditions as regards security.
29  *
30  * The fact that you are presently reading this means that you have had
31  * knowledge of the CeCILL-B license and that you accept its terms.
32  */
33 
34 
35 #ifndef AIMS_HISTOGRAM_HISTOGRAM_H
36 #define AIMS_HISTOGRAM_HISTOGRAM_H
37 
38 #include <aims/data/data.h>
39 #include <fstream>
40 
41 
42 template < class T > class Histogram;
43 
44 template < class T >
45 std::ostream& operator << ( std::ostream& os, const Histogram<T>& thing );
46 
48 template < class T>
49 class Histogram
50 {
51  public:
52 
55  Histogram();
58  Histogram( const Histogram<T>& other );
60  virtual ~Histogram() { }
62 
65  AimsData<int32_t>& data() { return _data; }
68  const AimsData<int32_t>& data() const { return _data; }
70 
75  { return _data.begin(); }
78  { return _data.begin() + _maxValid - _minValid + 1; }
79 
82  { return _data.begin(); }
85  { return _data.begin() + _maxValid - _minValid + 1; }
87 
89  int minValid() const { return _minValid; }
91  int maxValid() const { return _maxValid; }
92 
94  int totalPoints() const { return _nPoints; }
95 
98  virtual void doit( const AimsData<T>& ) { }
99 
102  friend std::ostream& operator << <> ( std::ostream& os,
104  const Histogram<T>& thing );
106 
107  protected:
108 
110  int _nPoints;
115 
118 };
119 
120 
121 template< class T > inline
123  : _nPoints( 0 ), _minValid( 0 ), _maxValid( 0 )
124 {
125 }
126 
127 
128 template< class T > inline
130  : _nPoints( other._nPoints ), _minValid( other._minValid ),
131  _maxValid( other._maxValid )
132 {
133  _data = other.data().clone();
134 }
135 
136 
137 template < class T > inline
138 std::ostream& operator << ( std::ostream& os, const Histogram<T>& thing )
139 {
140  os << "{nPoints=" << thing._nPoints << ",";
141  os << "minValid=" << thing._minValid << ",";
142  os << "maxValid=" << thing._maxValid << ",";
143  os << "data=" << thing._data << "}";
144 
145  return os;
146 }
147 
148 #endif
virtual ~Histogram()
destructor.
Definition: histogram.h:60
iterator begin()
int _nPoints
total number of points
Definition: histogram.h:110
AimsData< int32_t >::iterator endValid()
return the iterator to the last valid value of the histogram
Definition: histogram.h:77
AimsData< int32_t >::const_iterator beginValid() const
return the constant iterator to the first valid value of the histogram
Definition: histogram.h:81
AimsData< int32_t > & data()
return a reference to the data field of the histogram class.
Definition: histogram.h:66
int _minValid
minimum used value
Definition: histogram.h:112
int _maxValid
maximum used value
Definition: histogram.h:114
virtual void doit(const AimsData< T > &)
the histogram computation function.
Definition: histogram.h:98
int minValid() const
return the minimum valid (used) value of the histogram
Definition: histogram.h:89
AimsData< T > clone() const
Base class of histogram container class.
Definition: histogram.h:42
AimsData< int32_t > _data
histogram datas
Definition: histogram.h:117
AimsData< int32_t >::const_iterator endValid() const
return the constant iterator to the last valid value of the histogram
Definition: histogram.h:84
AimsData< int32_t >::iterator beginValid()
return the iterator to the first valid value of the histogram
Definition: histogram.h:74
int maxValid() const
returnn the maximum valid (used) value of the histogram
Definition: histogram.h:91
Histogram()
constructor.
Definition: histogram.h:122
const AimsData< int32_t > & data() const
return a constant reference to the data field of the histogram class.
Definition: histogram.h:68
int totalPoints() const
return the total number of points in the histogram
Definition: histogram.h:94