casacore
Loading...
Searching...
No Matches
StatisticsAlgorithmQuantileComputer.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: casa-feedback@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_STATSALGORITHMQUANTILECOMPUTER_H
27#define SCIMATH_STATSALGORITHMQUANTILECOMPUTER_H
28
29#include <casacore/scimath/StatsFramework/StatisticsTypes.h>
30
31#include <casacore/casa/aips.h>
32
33namespace casacore {
34
35// This is the virtual base class from which concrete QuantileComputer classes
36// are derived. The API developer should never explicitly instantiate a
37// QuantileComputer class; they are used internally by other StatsFramework
38// classes. See the documentation of StatisticsAlgorithm for more details.
39
40template <class AccumType, class DataIterator, class MaskIterator = const Bool*,
41 class WeightsIterator = DataIterator>
43 public:
45
47
48 // clone this object by returning a pointer to a copy
50
51 // delete any (partially) sorted array
53
54 // reset this object by clearing data.
55 virtual void reset();
56
57 // This must be called upon the copy or assignment of the
58 // associated statistics algorithm object. Otherwise, there is generally
59 // no reason to call it.
61
62 // FIXME make protected once refactor is complete
63 std::vector<AccumType>& _getSortedArray() { return _sortedArray; }
64
65 // FIXME make protected once refactor is complete
66 void _setSortedArray(const std::vector<AccumType>& v) { _sortedArray = v; }
67
68 void setMedian(std::shared_ptr<AccumType> median) { _median = std::move(median); }
69
70 protected:
71 // ds should be the dataset object held in the StatisticsAlgorithm object.
72 // The QuantileComputer calculator object should never hold its own version
73 // of a dataset object. The algorithm object (caller of this method) is
74 // always responsible for deleting the passed object, usually upon its
75 // destruction.
77
78 // use copy semantics. statistics algorithm object's responsibility to set
79 // the _dataset object in the new QuantileComputer calculator object upon a
80 // copy. The underlying _dataset object in the new stats calculator object
81 // should be a reference to the new _dataset object in the copied statistics
82 // algorithm object.
84
85 // use copy semantics. The _dataset object is not copied. It is the
86 // associated statistics algorithm object's responsibility to set the
87 // _dataset object in the new QuantileComputer calculator object upon an
88 // assignment. The underlying _dataset object in the new stats calculator
89 // object should be a reference to that in the newly assigned statistics
90 // algorithm object.
92
94
95 std::shared_ptr<AccumType> _getMedian() const { return _median; }
96
97 std::shared_ptr<AccumType> _getMedianAbsDevMedian() const { return _medAbsDevMed; }
98
99 void _setMedianAbsDevMedian(std::shared_ptr<AccumType> medAbsDevMed) {
100 _medAbsDevMed = std::move(medAbsDevMed);
101 }
102
103 private:
104 std::vector<AccumType> _sortedArray{};
105 // This pointer references the (non-pointer) object
106 // in the associated non-QuantileComputer computer object,
107 // so this should not be wrapped in a smart pointer.
109 std::shared_ptr<AccumType> _median{}, _medAbsDevMed{};
110};
111
112} // namespace casacore
113
114#ifndef CASACORE_NO_AUTO_TEMPLATES
115#include <casacore/scimath/StatsFramework/StatisticsAlgorithmQuantileComputer.tcc>
116#endif
117
118#endif
void _setSortedArray(const std::vector< AccumType > &v)
FIXME make protected once refactor is complete.
virtual StatisticsAlgorithmQuantileComputer< CASA_STATP > * clone() const =0
clone this object by returning a pointer to a copy
StatisticsAlgorithmQuantileComputer(StatisticsDataset< CASA_STATP > *ds)
ds should be the dataset object held in the StatisticsAlgorithm object.
StatisticsAlgorithmQuantileComputer & operator=(const StatisticsAlgorithmQuantileComputer &other)
use copy semantics.
void setDataset(StatisticsDataset< CASA_STATP > *ds)
This must be called upon the copy or assignment of the associated statistics algorithm object.
virtual void reset()
reset this object by clearing data.
StatisticsDataset< CASA_STATP > * _dataset
This pointer references the (non-pointer) object in the associated non-QuantileComputer computer obje...
std::vector< AccumType > & _getSortedArray()
FIXME make protected once refactor is complete.
void deleteSortedArray()
delete any (partially) sorted array
void _setMedianAbsDevMedian(std::shared_ptr< AccumType > medAbsDevMed)
StatisticsAlgorithmQuantileComputer(const StatisticsAlgorithmQuantileComputer &other)
use copy semantics.
Representation of a statistics dataset used in statistics framework calculatations.
For temporary backward namespace compatibility, use casa as alias for casacore.
Definition mainpage.dox:28
bool Bool
Define the standard types used by Casacore.
Definition aipstype.h:40
LatticeExprNode median(const LatticeExprNode &expr)