casacore
StatsDataProvider.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 //# $Id: Array.h 21545 2015-01-22 19:36:35Z gervandiepen $
26 
27 #ifndef SCIMATH_STATSDATAPROVIDER_H
28 #define SCIMATH_STATSDATAPROVIDER_H
29 
30 #include <casacore/scimath/Mathematics/StatisticsTypes.h>
31 
32 #include <casacore/casa/aips.h>
33 
34 namespace casacore {
35 
36 // Abstract base class which defines interface for providing "datasets" to the statistics framework
37 // when nontrivial means of doing so are not sufficient.
38 
39 template <class AccumType, class DataIterator, class MaskIterator=const Bool *, class WeightsIterator=DataIterator>
41 public:
42 
43  virtual ~StatsDataProvider();
44 
45  // increment the data provider to the next dataset, mask, range set, and weights.
46  virtual void operator++() = 0;
47 
48  // Are there any data sets left to provide?
49  virtual Bool atEnd() const = 0;
50 
51  // Take any actions necessary to finalize the provider. This will be called when
52  // atEnd() returns True.
53  virtual void finalize() = 0;
54 
55  // get the count of elements in the current data set. When implementing this method, be
56  // certain to take stride into account; ie for a data set with nominally 100 elements that
57  // is to have a stride of two, this method should return 50.
58  virtual uInt64 getCount() = 0;
59 
60  // get the current dataset
61  virtual DataIterator getData() = 0;
62 
63  // Get the associated mask of the current dataset. Only called if hasMask() returns True;
64  virtual MaskIterator getMask() = 0;
65 
66  // Get the stride for the current mask (only called if hasMask() returns True).
67  virtual uInt getMaskStride() = 0;
68 
69  // If OpenMP is enabled and statistics methods are not being called in a multi-threaded
70  // context, get maximum number of threads that should be used. If zero is returned,
71  // the statistics classes will use the maximum number of threads available to openmp.
72  // Returning less than that helps to decrease overhead used by statistics methods when the
73  // maximum number of threads available to openmp are unnecessary. The base class
74  // implmentation returns 0.
75  virtual uInt getNMaxThreads() const;
76 
77  // Get the associated range(s) of the current dataset. Only called if hasRanges() returns True;
78  virtual DataRanges getRanges() = 0;
79 
80  // Get the stride for the current data set.
81  virtual uInt getStride() = 0;
82 
83  // Get the associated weights of the current dataset. Only called if hasWeights() returns True;
84  virtual WeightsIterator getWeights() = 0;
85 
86  // Does the current data set have an associated mask?
87  virtual Bool hasMask() const = 0;
88 
89  // Does the current data set have associated range(s)?
90  virtual Bool hasRanges() const = 0;
91 
92  // Does the current data set have associated weights?
93  virtual Bool hasWeights() const = 0;
94 
95  // If the associated data set has ranges, are these include (return True) or
96  // exclude (return False) ranges?
97  virtual Bool isInclude() const = 0;
98 
99  // reset the provider to point to the first data set it manages.
100  virtual void reset() = 0;
101 
102  // <group>
103  // In general, unless you are writing statistics algorithm code, you shouldn't need
104  // to call these methods.
105  // The statistics framework calls these methods when the min and max posiitons are
106  // updated. It passes in the relevant index of the current sub dataset it is processing.
107  // Data providers can use this information to transform into something more useful, eg
108  // an IPosition for lattice data providers, so that they may be retreived easily after
109  // statistics have been calculated. The default implementations do nothing.
110  virtual void updateMaxPos(const std::pair<Int64, Int64>&) {}
111 
112  virtual void updateMinPos(const std::pair<Int64, Int64>&) {}
113  // </group>
114 
115 protected:
116 
118 
119 };
120 
121 }
122 
123 #ifndef CASACORE_NO_AUTO_TEMPLATES
124 #include <casacore/scimath/Mathematics/StatsDataProvider.tcc>
125 #endif //# CASACORE_NO_AUTO_TEMPLATES
126 
127 #endif
virtual uInt getNMaxThreads() const
If OpenMP is enabled and statistics methods are not being called in a multi-threaded context...
virtual void reset()=0
reset the provider to point to the first data set it manages.
unsigned long long uInt64
Definition: aipsxtype.h:39
virtual DataRanges getRanges()=0
Get the associated range(s) of the current dataset.
virtual uInt64 getCount()=0
get the count of elements in the current data set.
virtual WeightsIterator getWeights()=0
Get the associated weights of the current dataset.
virtual void operator++()=0
increment the data provider to the next dataset, mask, range set, and weights.
Abstract base class which defines interface for providing "datasets" to the statistics framework when...
virtual Bool hasWeights() const =0
Does the current data set have associated weights?
virtual Bool hasMask() const =0
Does the current data set have an associated mask?
virtual Bool hasRanges() const =0
Does the current data set have associated range(s)?
virtual Bool isInclude() const =0
If the associated data set has ranges, are these include (return True) or exclude (return False) rang...
virtual void finalize()=0
Take any actions necessary to finalize the provider.
virtual uInt getStride()=0
Get the stride for the current data set.
virtual MaskIterator getMask()=0
Get the associated mask of the current dataset.
virtual uInt getMaskStride()=0
Get the stride for the current mask (only called if hasMask() returns True).
#define DataRanges
Commonly used types in statistics framework.
bool Bool
Define the standard types used by Casacore.
Definition: aipstype.h:42
virtual Bool atEnd() const =0
Are there any data sets left to provide?
virtual DataIterator getData()=0
get the current dataset
virtual void updateMaxPos(const std::pair< Int64, Int64 > &)
In general, unless you are writing statistics algorithm code, you shouldn&#39;t need to call these method...
virtual void updateMinPos(const std::pair< Int64, Int64 > &)
this file contains all the compiler specific defines
Definition: mainpage.dox:28
unsigned int uInt
Definition: aipstype.h:51