casa  5.7.0-16
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
MaskedLatticeStatsDataProvider.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 LATTICES_MASKEDLATTICESTATSDATAPROVIDER_H
28 #define LATTICES_MASKEDLATTICESTATSDATAPROVIDER_H
29 
31 
34 
35 #include <casacore/casa/aips.h>
36 
37 namespace casacore {
38 
39 // Data provider which allows stats framework to iterate through a masked lattice.
40 
41 template <class T> class MaskedLatticeStatsDataProvider
42  : public LatticeStatsDataProviderBase<T> {
43 public:
44 
45  // default constructor. Must set lattice after construction but before
46  // using the object
47 
49 
50  // <src>iteratorLimitBytes</src> is related to the size of the lattice.
51  // If the lattice is greater than this size, then a lattice iterator will
52  // be used to step through the lattice. If less, then all the data in the
53  // values in the lattice are retrieved in a single chunk. The advantage of
54  // the iterator is that less memory is used. The disadvantage is there is
55  // a significant performace cost, so if the lattice is small, it is better to
56  // get all its values in a single chunk and forgo the iterator. This is particularly
57  // true when looping for a large number of iterations and creating a
58  // MaskedLatticeStatsDataProvider each loop (in that case, you probably will want
59  // to create a single object before the loop and use setLattice() to update
60  // its lattice).
62  MaskedLattice<T>& lattice, uInt iteratorLimitBytes=4096*4096
63  );
64 
66 
67  void operator++();
68 
69  uInt estimatedSteps() const;
70 
71  // Are there any data sets left to provide?
72  Bool atEnd() const;
73 
74  // Take any actions necessary to finalize the provider. This will be called when
75  // atEnd() returns True.
76  void finalize();
77 
78  // get the count of elements in the current data set. When implementing this method, be
79  // certain to take stride into account; ie for a data set with nominally 100 elements that
80  // is to have a stride of two, this method should return 50.
81  uInt64 getCount();
82 
83  // get the current data set
84  const T* getData();
85 
86  // Get the associated mask of the current dataset. Only called if hasMask() returns True;
87  const Bool* getMask();
88 
89  // returns something reasonable based on the lattice size.
90  uInt getNMaxThreads() const;
91 
92  // Does the current data set have an associated mask?
93  Bool hasMask() const;
94 
95  // reset the provider to point to the first data set it manages.
96  void reset();
97 
98  // set the lattice. Automatically resets the lattice iterator.
99  // <src>iteratorLimitBytes</src> is related to the size of the lattice.
100  // If the lattice is greater than this size, then a lattice iterator will
101  // be used to step through the lattice. If less, then all the data in the
102  // values in the lattice are retrieved in a single chunk. The advantage of
103  // the iterator is that less memory is used. The disadvantage is there is
104  // a significant performace cost, so if the lattice is small, it is better to
105  // get all its values in a single chunk and forgo the iterator. This is particularly
106  // true when looping for a large number of iterations and creating a
107  // MaskedLatticeStatsDataProvider each loop (in that case, you probably will want
108  // to create a single object before the loop and use setLattice() to update
109  // its lattice).
110  void setLattice(const MaskedLattice<T>& lattice, uInt iteratorLimitBytes=4096*4096);
111 
112  // <group>
113  // see base class documentation.
114  void updateMaxPos(const std::pair<Int64, Int64>& maxpos);
115 
116  void updateMinPos(const std::pair<Int64, Int64>& minpos);
117  // </group>
118 
119 private:
120 
124  const T* _currentPtr;
128 
129  void _freeStorage();
130 
131 };
132 
133 }
134 
135 #ifndef CASACORE_NO_AUTO_TEMPLATES
136 #include <casacore/lattices/LatticeMath/MaskedLatticeStatsDataProvider.tcc>
137 #endif //# CASACORE_NO_AUTO_TEMPLATES
138 
139 #endif
uInt64 getCount()
get the count of elements in the current data set.
void operator++()
increment the data provider to the next dataset, mask, range set, and weights.
unsigned long long uInt64
Definition: aipsxtype.h:39
MaskedLatticeStatsDataProvider()
default constructor.
void setLattice(const MaskedLattice< T > &lattice, uInt iteratorLimitBytes=4096 *4096)
set the lattice.
A templated, abstract base class for array-like objects with masks.
Bool atEnd() const
Are there any data sets left to provide?
uInt getNMaxThreads() const
returns something reasonable based on the lattice size.
Data provider which allows stats framework to iterate through a masked lattice.
Referenced counted pointer for constant data.
Definition: VisModelData.h:42
Abstract base class of data providers which allows stats framework to iterate through a lattice...
void finalize()
Take any actions necessary to finalize the provider.
CountedPtr< RO_MaskedLatticeIterator< T > > _iter
bool Bool
Define the standard types used by Casacore.
Definition: aipstype.h:42
const Bool * getMask()
Get the associated mask of the current dataset.
const T * getData()
get the current data set
template &lt;class T, class U&gt; class vector;
Definition: MSFlagger.h:37
void updateMinPos(const std::pair< Int64, Int64 > &minpos)
void updateMaxPos(const std::pair< Int64, Int64 > &maxpos)
see base class documentation.
uInt estimatedSteps() const
estimated number of steps to iterate through the the lattice
void reset()
reset the provider to point to the first data set it manages.
Bool hasMask() const
Does the current data set have an associated mask?
unsigned int uInt
Definition: aipstype.h:51
#define casacore
&lt;X11/Intrinsic.h&gt; #defines true, false, casacore::Bool, and String.
Definition: X11Intrinsic.h:42