casacore
LineCollapser.h
Go to the documentation of this file.
1 //# LineCollapser.h: Abstract base class to collapse lines for LatticeApply
2 //# Copyright (C) 1996,1997,1998
3 //# Associated Universities, Inc. Washington DC, USA.
4 //#
5 //# This library is free software; you can redistribute it and/or modify it
6 //# under the terms of the GNU Library General Public License as published by
7 //# the Free Software Foundation; either version 2 of the License, or (at your
8 //# option) any later version.
9 //#
10 //# This library is distributed in the hope that it will be useful, but WITHOUT
11 //# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 //# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
13 //# License for more details.
14 //#
15 //# You should have received a copy of the GNU Library General Public License
16 //# along with this library; if not, write to the Free Software Foundation,
17 //# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA.
18 //#
19 //# Correspondence concerning AIPS++ should be addressed as follows:
20 //# Internet email: aips2-request@nrao.edu.
21 //# Postal address: AIPS++ Project Office
22 //# National Radio Astronomy Observatory
23 //# 520 Edgemont Road
24 //# Charlottesville, VA 22903-2475 USA
25 //#
26 //# $Id$
27 
28 #ifndef LATTICES_LINECOLLAPSER_H
29 #define LATTICES_LINECOLLAPSER_H
30 
31 
32 //# Includes
33 #include <casacore/casa/aips.h>
34 #include <casacore/casa/Arrays/ArrayFwd.h>
35 #include <casacore/scimath/Mathematics/NumericTraits.h>
36 
37 namespace casacore { //# NAMESPACE CASACORE - BEGIN
38 
39 //# Forward Declarations
40 class IPosition;
41 
42 // <summary>
43 // Abstract base class for LatticeApply function signatures
44 // </summary>
45 
46 // <use visibility=export>
47 
48 // <reviewed reviewer="" date="yyyy/mm/dd" tests="" demos="">
49 // </reviewed>
50 
51 // <prerequisite>
52 // <li> <linkto class=LatticeApply>LatticeApply</linkto>
53 // </prerequisite>
54 
55 // <etymology>
56 // </etymology>
57 
58 // <synopsis>
59 // This is an abstract base class for the collapsing of lines to
60 // be used in function <src>lineApply</src> or <src>lineMultiApply</src>
61 // in class <linkto class=LatticeApply>LatticeApply</linkto>.
62 // It is meant for cases where the entire line is needed (e.g. moment
63 // calculation). If that is not needed (e.g. to calculate maximum),
64 // it is better to use function <src>LatticeApply::tiledApply</src>
65 // with class <linkto class=TiledCollapser>TiledCollapser</linkto>.
66 // <p>
67 // The user has to derive a concrete class from this base class
68 // and implement the (pure) virtual functions.
69 // <br> The main function is <src>process</src>, which needs to do the
70 // calculation.
71 // <br> Other functions make it possible to perform an initial check.
72 // <p>
73 // The class is Doubly templated. Ths first template type
74 // is for the data type you are processing. The second type is
75 // for what type you want the results of the processing assigned to.
76 // For example, if you are computing sums of squares for statistical
77 // purposes, you might use higher precision (FLoat->Double) for this.
78 // No check is made that the template types are self-consistent.
79 // </synopsis>
80 
81 // <example>
82 // <srcblock>
83 // </srcblock>
84 // </example>
85 
86 // <motivation>
87 // </motivation>
88 
89 // <todo asof="1997/08/01">
90 // <li>
91 // </todo>
92 
93 template <class T, class U=T> class LineCollapser
94 {
95 public:
96 // Destructor
97  virtual ~LineCollapser();
98 
99 // The init function for a derived class.
100 // It can be used to check if <src>nOutPixelsPerCollapse</src>
101 // corresponds with the number of pixels produced per collapsed line.
102  virtual void init (uInt nOutPixelsPerCollapse) = 0;
103 
104 // Can the process function in the derived class handle a null mask?
105 // If not, LatticeApply ensures that it'll always pass a filled mask vector,
106 // even if the lattice does not have a mask (in that case that mask
107 // contains all True values).
108 // <br>The default implementation returns False.
109 // <br>The function is there to make optimization possible when no masks
110 // are involved. On the other side, it allows the casual user to ignore
111 // optimization.
112  virtual Bool canHandleNullMask() const;
113 
114 // Collapse the given line and return one value from that operation.
115 // The position in the Lattice at the start of the line is input
116 // as well.
117 // <br>When function <src>canHandleNullMask</src> returned True,
118 // it is possible that <src>mask</src> is an empty vector indicating
119 // that the input has no mask, thus all values are valid.
120 // If not empty, the mask has the same length as the line.
121  virtual void process (U& result, Bool& resultMask,
122  const Vector<T>& line,
123  const Vector<Bool>& mask,
124  const IPosition& pos) = 0;
125 
126 // Collapse the given line and return a line of values from that operation.
127 // The position in the Lattice at the start of the line is input
128 // as well.
129 // <br>When function <src>canHandleNullMask</src> returned True,
130 // it is possible that <src>mask</src> is an empty vector indicating
131 // that the input has no mask, thus all values are valid.
132 // If not empty, the mask has the same length as the line.
133  virtual void multiProcess (Vector<U>& result, Vector<Bool>& resultMask,
134  const Vector<T>& line,
135  const Vector<Bool>& mask,
136  const IPosition& pos) = 0;
137 };
138 
139 
140 
141 } //# NAMESPACE CASACORE - END
142 
143 #ifndef CASACORE_NO_AUTO_TEMPLATES
144 #include <casacore/lattices/LatticeMath/LineCollapser.tcc>
145 #endif //# CASACORE_NO_AUTO_TEMPLATES
146 #endif
virtual Bool canHandleNullMask() const
Can the process function in the derived class handle a null mask? If not, LatticeApply ensures that i...
virtual ~LineCollapser()
Destructor.
virtual void process(U &result, Bool &resultMask, const Vector< T > &line, const Vector< Bool > &mask, const IPosition &pos)=0
Collapse the given line and return one value from that operation.
virtual void init(uInt nOutPixelsPerCollapse)=0
The init function for a derived class.
virtual void multiProcess(Vector< U > &result, Vector< Bool > &resultMask, const Vector< T > &line, const Vector< Bool > &mask, const IPosition &pos)=0
Collapse the given line and return a line of values from that operation.
this file contains all the compiler specific defines
Definition: mainpage.dox:28
unsigned int uInt
Definition: aipstype.h:51
LatticeExprNode mask(const LatticeExprNode &expr)
This function returns the mask of the given expression.
bool Bool
Define the standard types used by Casacore.
Definition: aipstype.h:42