casa  5.7.0-16
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
ConstrainedRangeQuantileComputer.h
Go to the documentation of this file.
1 //# Copyright (C) 2000,2001
2 //# Associated Universities, Inc. Washington DC, USA.
3 //#
4 //# This library is free software; you can redistribute it and/or modify it
5 //# under the terms of the GNU Library General Public License as published by
6 //# the Free Software Foundation; either version 2 of the License, or (at your
7 //# option) any later version.
8 //#
9 //# This library is distributed in the hope that it will be useful, but WITHOUT
10 //# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 //# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
12 //# License for more details.
13 //#
14 //# You should have received a copy of the GNU Library General Public License
15 //# along with this library; if not, write to the Free Software Foundation,
16 //# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA.
17 //#
18 //# Correspondence concerning AIPS++ should be addressed as follows:
19 //# Internet email: aips2-request@nrao.edu.
20 //# Postal address: AIPS++ Project Office
21 //# National Radio Astronomy Observatory
22 //# 520 Edgemont Road
23 //# Charlottesville, VA 22903-2475 USA
24 //#
25 
26 #ifndef SCIMATH_CONSTRAINEDRANGEQUANTILECOMPUTER_H
27 #define SCIMATH_CONSTRAINEDRANGEQUANTILECOMPUTER_H
28 
30 
31 #include <casacore/casa/aips.h>
32 
33 namespace casacore {
34 
35 // Basic concrete QuantileComputer class for data constrained to be
36 // in a specified range. Some derived classes of ConstrainedRangeStatistics
37 // use it. It should never be explicitly instantiated by an API developer.
38 // See the class documentation of StatisticsAlgorithm for details on
39 // QuantileComputer classes.
40 
41 template <
42  class AccumType, class DataIterator, class MaskIterator=const Bool*,
43  class WeightsIterator=DataIterator
44 >
46  : public ClassicalQuantileComputer<CASA_STATP> {
47 public:
48 
50 
52 
53  // copy semantics
56  );
57 
59 
60  // copy semantics
63  );
64 
65  // clone this object by returning a pointer to a copy
67 
68  // Caller is responsible for passing correct values of mynpts, mymin, and
69  // mymax; no checking is done for correctness in this method.
70  virtual AccumType getMedian(
71  uInt64 mynpts, AccumType mymin, AccumType mymax,
72  uInt binningThreshholdSizeBytes, Bool persistSortedArray, uInt nBins
73  );
74 
75  // get the median of the absolute deviation about the median of the data.
76  virtual AccumType getMedianAbsDevMed(
77  uInt64 mynpts, AccumType mymin, AccumType mymax,
78  uInt binningThreshholdSizeBytes, Bool persistSortedArray, uInt nBins
79  );
80 
81  void setRange(const std::pair<AccumType, AccumType>& r) {
82  _range = r;
83  }
84 
85 protected:
86 
87  // <group>
88  virtual void _findBins(
89  std::vector<BinCountArray>& binCounts,
90  std::vector<CountedPtr<AccumType>>& sameVal, std::vector<Bool>& allSame,
91  const DataIterator& dataBegin, uInt64 nr, uInt dataStride,
92  const std::vector<StatsHistogram<AccumType> >& binDesc,
93  const std::vector<AccumType>& maxLimit
94  ) const;
95 
96  virtual void _findBins(
97  std::vector<BinCountArray>& binCounts,
98  std::vector<CountedPtr<AccumType>>& sameVal, std::vector<Bool>& allSame,
99  const DataIterator& dataBegin, uInt64 nr, uInt dataStride,
100  const DataRanges& ranges, Bool isInclude,
101  const std::vector<StatsHistogram<AccumType>>& binDesc,
102  const std::vector<AccumType>& maxLimit
103  ) const;
104 
105  virtual void _findBins(
106  std::vector<BinCountArray>& binCounts,
107  std::vector<CountedPtr<AccumType>>& sameVal, std::vector<Bool>& allSame,
108  const DataIterator& dataBegin, uInt64 nr, uInt dataStride,
109  const MaskIterator& maskBegin, uInt maskStride,
110  const std::vector<StatsHistogram<AccumType>>& binDesc,
111  const std::vector<AccumType>& maxLimit
112  ) const;
113 
114  virtual void _findBins(
115  std::vector<BinCountArray>& binCounts,
116  std::vector<CountedPtr<AccumType>>& sameVal, std::vector<Bool>& allSame,
117  const DataIterator& dataBegin, uInt64 nr, uInt dataStride,
118  const MaskIterator& maskBegin, uInt maskStride,
119  const DataRanges& ranges, Bool isInclude,
120  const std::vector<StatsHistogram<AccumType>>& binDesc,
121  const std::vector<AccumType>& maxLimit
122  ) const;
123 
124  virtual void _findBins(
125  std::vector<BinCountArray>& binCounts,
126  std::vector<CountedPtr<AccumType>>& sameVal, std::vector<Bool>& allSame,
127  const DataIterator& dataBegin, const WeightsIterator& weightsBegin,
128  uInt64 nr, uInt dataStride,
129  const std::vector<StatsHistogram<AccumType>>& binDesc,
130  const std::vector<AccumType>& maxLimit
131  ) const ;
132 
133  virtual void _findBins(
134  std::vector<BinCountArray>& binCounts,
135  std::vector<CountedPtr<AccumType>>& sameVal, std::vector<Bool>& allSame,
136  const DataIterator& dataBegin,
137  const WeightsIterator& weightsBegin, uInt64 nr, uInt dataStride,
138  const DataRanges& ranges, Bool isInclude,
139  const std::vector<StatsHistogram<AccumType>>& binDesc,
140  const std::vector<AccumType>& maxLimit
141  ) const;
142 
143  virtual void _findBins(
144  std::vector<BinCountArray>& binCounts,
145  std::vector<CountedPtr<AccumType>>& sameVal, std::vector<Bool>& allSame,
146  const DataIterator& dataBegin, const WeightsIterator& weightsBegin,
147  uInt64 nr, uInt dataStride, const MaskIterator& maskBegin,
148  uInt maskStride, const DataRanges& ranges, Bool isInclude,
149  const std::vector<StatsHistogram<AccumType> >& binDesc,
150  const std::vector<AccumType>& maxLimit
151  ) const;
152 
153  virtual void _findBins(
154  std::vector<BinCountArray>& binCounts,
155  std::vector<CountedPtr<AccumType>>& sameVal, std::vector<Bool>& allSame,
156  const DataIterator& dataBegin, const WeightsIterator& weightBegin,
157  uInt64 nr, uInt dataStride, const MaskIterator& maskBegin,
158  uInt maskStride, const std::vector<StatsHistogram<AccumType> >& binDesc,
159  const std::vector<AccumType>& maxLimit
160  ) const;
161  // </group>
162 
163  //<group>
164  // populate an unsorted array with valid data. If <src>includeLimits</src>
165  // is defined, then restrict values that are entered in the array to those
166  // limits (inclusive of the minimum, exclusive of the maximum).
167  // <src>maxCount</src> and <src>currentCount</src> are used only if
168  // <src>includeLimits</src> is defined. In this case, the method will return
169  // when currentCount == maxCount, thus avoiding scanning remaining data
170  // unnecessarily.
171 
172  // no weights, no mask, no ranges
173  virtual void _populateArray(
174  DataArray& ary, const DataIterator& dataBegin, uInt64 nr,
175  uInt dataStride
176  ) const;
177 
178  // ranges
179  virtual void _populateArray(
180  DataArray& ary, const DataIterator& dataBegin, uInt64 nr,
181  uInt dataStride, const DataRanges& ranges, Bool isInclude
182  ) const;
183 
184  virtual void _populateArray(
185  DataArray& ary, const DataIterator& dataBegin, uInt64 nr,
186  uInt dataStride, const MaskIterator& maskBegin, uInt maskStride
187  ) const;
188 
189  // mask and ranges
190  virtual void _populateArray(
191  DataArray& ary, const DataIterator& dataBegin, uInt64 nr,
192  uInt dataStride, const MaskIterator& maskBegin, uInt maskStride,
193  const DataRanges& ranges, Bool isInclude
194  ) const;
195 
196  // weights
197  virtual void _populateArray(
198  DataArray& ary, const DataIterator& dataBegin,
199  const WeightsIterator& weightsBegin, uInt64 nr, uInt dataStride
200  ) const;
201 
202  // weights and ranges
203  virtual void _populateArray(
204  DataArray& ary, const DataIterator& dataBegin,
205  const WeightsIterator& weightsBegin, uInt64 nr, uInt dataStride,
206  const DataRanges& ranges, Bool isInclude
207  ) const;
208 
209  // weights and mask
210  virtual void _populateArray(
211  DataArray& ary, const DataIterator& dataBegin,
212  const WeightsIterator& weightBegin, uInt64 nr, uInt dataStride,
213  const MaskIterator& maskBegin, uInt maskStride
214  ) const;
215 
216  // weights, mask, ranges
217  virtual void _populateArray(
218  DataArray& ary, const DataIterator& dataBegin,
219  const WeightsIterator& weightBegin, uInt64 nr, uInt dataStride,
220  const MaskIterator& maskBegin, uInt maskStride,
221  const DataRanges& ranges, Bool isInclude
222  ) const;
223 
224  // no weights, no mask, no ranges
225  virtual void _populateArrays(
226  std::vector<DataArray>& arys, uInt64& currentCount,
227  const DataIterator& dataBegin, uInt64 nr, uInt dataStride,
228  const IncludeLimits& includeLimits, uInt64 maxCount
229  ) const;
230 
231  // ranges
232  virtual void _populateArrays(
233  std::vector<DataArray>& arys, uInt64& currentCount,
234  const DataIterator& dataBegin, uInt64 nr, uInt dataStride,
235  const DataRanges& ranges, Bool isInclude,
236  const IncludeLimits& includeLimits, uInt64 maxCount
237  ) const;
238 
239  virtual void _populateArrays(
240  std::vector<DataArray>& arys, uInt64& currentCount,
241  const DataIterator& dataBegin, uInt64 nr, uInt dataStride,
242  const MaskIterator& maskBegin, uInt maskStride,
243  const IncludeLimits& includeLimits, uInt64 maxCount
244  ) const;
245 
246  // mask and ranges
247  virtual void _populateArrays(
248  std::vector<DataArray>& arys, uInt64& currentCount,
249  const DataIterator& dataBegin, uInt64 nr, uInt dataStride,
250  const MaskIterator& maskBegin, uInt maskStride,
251  const DataRanges& ranges, Bool isInclude,
252  const IncludeLimits& includeLimits, uInt64 maxCount
253  ) const;
254 
255  // weights
256  virtual void _populateArrays(
257  std::vector<DataArray>& arys, uInt64& currentCount,
258  const DataIterator& dataBegin, const WeightsIterator& weightsBegin,
259  uInt64 nr, uInt dataStride, const IncludeLimits& includeLimits,
260  uInt64 maxCount
261  ) const;
262 
263  // weights and ranges
264  virtual void _populateArrays(
265  std::vector<DataArray>& arys, uInt64& currentCount,
266  const DataIterator& dataBegin, const WeightsIterator& weightsBegin,
267  uInt64 nr, uInt dataStride, const DataRanges& ranges, Bool isInclude,
268  const IncludeLimits& includeLimits, uInt64 maxCount
269  ) const;
270 
271  // weights and mask
272  virtual void _populateArrays(
273  std::vector<DataArray>& arys, uInt64& currentCount,
274  const DataIterator& dataBegin, const WeightsIterator& weightBegin,
275  uInt64 nr, uInt dataStride, const MaskIterator& maskBegin,
276  uInt maskStride, const IncludeLimits& includeLimits, uInt64 maxCount
277  ) const;
278 
279  // weights, mask, ranges
280  virtual void _populateArrays(
281  std::vector<DataArray>& arys, uInt64& currentCount,
282  const DataIterator& dataBegin, const WeightsIterator& weightBegin,
283  uInt64 nr, uInt dataStride, const MaskIterator& maskBegin,
284  uInt maskStride, const DataRanges& ranges, Bool isInclude,
285  const IncludeLimits& includeLimits, uInt64 maxCount
286  ) const;
287  // </group>
288 
289  // <group>
290  // no weights, no mask, no ranges
291  virtual Bool _populateTestArray(
292  DataArray& ary, const DataIterator& dataBegin, uInt64 nr,
293  uInt dataStride, uInt maxElements
294  ) const;
295 
296  // ranges
297  virtual Bool _populateTestArray(
298  DataArray& ary, const DataIterator& dataBegin, uInt64 nr,
299  uInt dataStride, const DataRanges& ranges, Bool isInclude,
300  uInt maxElements
301  ) const;
302 
303  // mask
304  virtual Bool _populateTestArray(
305  DataArray& ary, const DataIterator& dataBegin, uInt64 nr,
306  uInt dataStride, const MaskIterator& maskBegin, uInt maskStride,
307  uInt maxElements
308  ) const;
309 
310  // mask and ranges
311  virtual Bool _populateTestArray(
312  DataArray& ary, const DataIterator& dataBegin, uInt64 nr,
313  uInt dataStride, const MaskIterator& maskBegin, uInt maskStride,
314  const DataRanges& ranges, Bool isInclude, uInt maxElements
315  ) const;
316 
317  // weights
318  virtual Bool _populateTestArray(
319  DataArray& ary, const DataIterator& dataBegin,
320  const WeightsIterator& weightBegin, uInt64 nr, uInt dataStride,
321  uInt maxElements
322  ) const;
323 
324  // weights and ranges
325  virtual Bool _populateTestArray(
326  DataArray& ary, const DataIterator& dataBegin,
327  const WeightsIterator& weightsBegin, uInt64 nr, uInt dataStride,
328  const DataRanges& ranges, Bool isInclude, uInt maxElements
329  ) const;
330 
331  // weights and mask
332  virtual Bool _populateTestArray(
333  DataArray& ary, const DataIterator& dataBegin,
334  const WeightsIterator& weightBegin, uInt64 nr, uInt dataStride,
335  const MaskIterator& maskBegin, uInt maskStride, uInt maxElements
336  ) const;
337 
338  // weights, mask, ranges
339  virtual Bool _populateTestArray(
340  DataArray& ary, const DataIterator& dataBegin,
341  const WeightsIterator& weightBegin, uInt64 nr, uInt dataStride,
342  const MaskIterator& maskBegin, uInt maskStride,
343  const DataRanges& ranges, Bool isInclude, uInt maxElements
344  ) const;
345  // </group>
346 
347 private:
348 
350  // for use in macros of often repeatedly run methods
351  AccumType _myMedian{0};
352  std::pair<AccumType, AccumType> _range{};
353 
354 };
355 
356 }
357 
358 #ifndef CASACORE_NO_AUTO_TEMPLATES
359 #include <casacore/scimath/StatsFramework/ConstrainedRangeQuantileComputer.tcc>
360 #endif
361 
362 #endif
Basic concrete QuantileComputer class for data constrained to be in a specified range.
Represents an unfilled histogram with equal width bins for binning used for quantile computations...
This class is used internally by ClassicalStatistics objects.
virtual Bool _populateTestArray(DataArray &ary, const DataIterator &dataBegin, uInt64 nr, uInt dataStride, uInt maxElements) const
no weights, no mask, no ranges
unsigned long long uInt64
Definition: aipsxtype.h:39
AccumType _myMedian
for use in macros of often repeatedly run methods
#define DataArray
Commonly used types in statistics framework.
virtual void _populateArray(DataArray &ary, const DataIterator &dataBegin, uInt64 nr, uInt dataStride) const
populate an unsorted array with valid data.
virtual void _findBins(std::vector< BinCountArray > &binCounts, std::vector< CountedPtr< AccumType >> &sameVal, std::vector< Bool > &allSame, const DataIterator &dataBegin, uInt64 nr, uInt dataStride, const std::vector< StatsHistogram< AccumType > > &binDesc, const std::vector< AccumType > &maxLimit) const
virtual AccumType getMedian(uInt64 mynpts, AccumType mymin, AccumType mymax, uInt binningThreshholdSizeBytes, Bool persistSortedArray, uInt nBins)
Caller is responsible for passing correct values of mynpts, mymin, and mymax; no checking is done for...
#define DataRanges
bool Bool
Define the standard types used by Casacore.
Definition: aipstype.h:42
void setRange(const std::pair< AccumType, AccumType > &r)
virtual void _populateArrays(std::vector< DataArray > &arys, uInt64 &currentCount, const DataIterator &dataBegin, uInt64 nr, uInt dataStride, const IncludeLimits &includeLimits, uInt64 maxCount) const
no weights, no mask, no ranges
#define IncludeLimits
virtual StatisticsAlgorithmQuantileComputer< CASA_STATP > * clone() const
clone this object by returning a pointer to a copy
virtual AccumType getMedianAbsDevMed(uInt64 mynpts, AccumType mymin, AccumType mymax, uInt binningThreshholdSizeBytes, Bool persistSortedArray, uInt nBins)
get the median of the absolute deviation about the median of the data.
unsigned int uInt
Definition: aipstype.h:51
ConstrainedRangeQuantileComputer & operator=(const ConstrainedRangeQuantileComputer &other)
copy semantics
#define casacore
&lt;X11/Intrinsic.h&gt; #defines true, false, casacore::Bool, and String.
Definition: X11Intrinsic.h:42