casa  5.7.0-16
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
LELBinary.h
Go to the documentation of this file.
1 //# LELBinary.h: LELBinary.h
2 //# Copyright (C) 1997,1998,1999,2000
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_LELBINARY_H
29 #define LATTICES_LELBINARY_H
30 
31 
32 //# Includes
33 #include <casacore/casa/aips.h>
36 
37 namespace casacore { //# NAMESPACE CASACORE - BEGIN
38 
39 //# Forward Declarations
40 
41 
42 // <summary> This LEL class handles numerical binary operators </summary>
43 //
44 // <use visibility=local>
45 //
46 // <reviewed reviewer="" date="yyyy/mm/dd" tests="" demos="">
47 // </reviewed>
48 //
49 // <prerequisite>
50 // <li> <linkto class="Lattice"> Lattice</linkto>
51 // <li> <linkto class="LatticeExpr"> LatticeExpr</linkto>
52 // <li> <linkto class="LatticeExprNode"> LatticeExprNode</linkto>
53 // <li> <linkto class="LELInterface"> LELInterface</linkto>
54 // <li> <linkto class="LELBinaryEnums"> LELBinaryEnums</linkto>
55 // </prerequisite>
56 //
57 // <etymology>
58 // This derived LEL letter class handles numerical binary
59 // operators
60 // </etymology>
61 //
62 // <synopsis>
63 // This LEL letter class is derived from LELInterface. It
64 // is used to construct LEL objects that apply numerical binary
65 // operators to Lattice expressions. They operate on numerical
66 // Lattice (Float,Double,Complex,DComplex) expressions and return the
67 // same numerical type. The available C++ operators
68 // are <src>+,-,*,/</src> with equivalents in the enum
69 // of ADD, SUBTRACT, MULTIPLY, and DIVIDE.
70 //
71 // A description of the implementation details of the LEL classes can
72 // be found in
73 // <a href="../notes/216.html">Note 216</a>
74 //
75 // </synopsis>
76 //
77 // <example>
78 // Examples are not very useful as the user would never use
79 // these classes directly. Look in LatticeExprNode.cc to see
80 // how it invokes these classes. Examples of how the user
81 // would indirectly use this class (through the envelope) are:
82 // <srcblock>
83 // IPosition shape(2,5,10);
84 // ArrayLattice<Float> x(shape); x.set(1.0);
85 // ArrayLattice<Float> y(shape); y.set(2.0);
86 // ArrayLattice<Float> z(shape);
87 // z.copyData(x+y); // z = x + y;
88 // z.copyData(x-y); // z = x - y;
89 // z.copyData(x*y); // z = x * y;
90 // z.copyData(x/y); // z = x / y;
91 // </srcblock>
92 // </example>
93 //
94 // <motivation>
95 // Numerical binary operations are a basic mathematical expression.
96 // </motivation>
97 //
98 // <todo asof="1998/01/20">
99 // </todo>
100 
101 
102 template <class T> class LELBinary : public LELInterface<T>
103 {
104  //# Make members of parent class known.
105 protected:
107 
108 public:
109 // Constructor takes operation and left and right expressions
110 // to be operated upon
112  const CountedPtr<LELInterface<T> >& pLeftExpr,
113  const CountedPtr<LELInterface<T> >& pRightExpr);
114 
115 // Destructor
116  ~LELBinary();
117 
118 // Recursively evaluate the expression
119  virtual void eval (LELArray<T>& result,
120  const Slicer& section) const;
121 
122 // Recursively efvaluate the scalar expression
123  virtual LELScalar<T> getScalar() const;
124 
125 // Do further preparations (e.g. optimization) on the expression.
126  virtual Bool prepareScalarExpr();
127 
128 // Get class name
129  virtual String className() const;
130 
131  // Handle locking/syncing of a lattice in a lattice expression.
132  // <group>
133  virtual Bool lock (FileLocker::LockType, uInt nattempts);
134  virtual void unlock();
135  virtual Bool hasLock (FileLocker::LockType) const;
136  virtual void resync();
137  // </group>
138 
139 private:
143 };
144 
145 
146 
147 
148 // <summary> This LEL class handles relational binary numerical operators </summary>
149 //
150 // <use visibility=local>
151 //
152 // <reviewed reviewer="" date="yyyy/mm/dd" tests="" demos="">
153 // </reviewed>
154 //
155 // <prerequisite>
156 // <li> <linkto class="Lattice"> Lattice</linkto>
157 // <li> <linkto class="LatticeExpr"> LatticeExpr</linkto>
158 // <li> <linkto class="LatticeExprNode"> LatticeExprNode</linkto>
159 // <li> <linkto class="LELInterface"> LELInterface</linkto>
160 // <li> <linkto class="LELBinaryEnums"> LELBinaryEnums</linkto>
161 // </prerequisite>
162 //
163 // <etymology>
164 // This derived LEL letter class handles relational numerical binary
165 // operators
166 // </etymology>
167 //
168 // <synopsis>
169 // This LEL letter class is derived from LELInterface. It
170 // is used to construct LEL objects that apply relational numerical
171 // binary operators to Lattice expressions. They operate on numerical
172 // (Float,Double,Complex,DComplex) Lattice expressions and result
173 // in a Bool. The available C++ operators are
174 // <src>==,!=>,>=,<,<=,</src> with equivalents in the enum of
175 // EQ, NE, GT, GE, LT, and LE
176 //
177 // A description of the implementation details of the LEL classes can
178 // be found in
179 // <a href="../notes/216.html">Note 216</a>
180 //
181 // </synopsis>
182 //
183 // <example>
184 // Examples are not very useful as the user would never use
185 // these classes directly. Look in LatticeExprNode.cc to see
186 // how it invokes these classes. Examples of how the user
187 // would indirectly use this class (through the envelope) are:
188 // <srcblock>
189 // IPosition shape(2,5,10);
190 // ArrayLattice<Float> x(shape); x.set(1.0);
191 // ArrayLattice<Float> y(shape); y.set(2.0);
192 // ArrayLattice<Bool> z(shape);
193 // z.copyData(x==y); // z = x == y;
194 // z.copyData(x!=y); // z = x != y;
195 // z.copyData(x>y); // z = x > y;
196 // z.copyData(x>=y); // z = x >= y;
197 // z.copyData(x<y); // z = x < y;
198 // z.copyData(x<=y); // z = x <= y;
199 // </srcblock>
200 // </example>
201 //
202 // <motivation>
203 // Numerical relational binary operations are a basic mathematical expression.
204 // </motivation>
205 //
206 // <todo asof="1998/01/20">
207 // </todo>
208 
209 
210 template<class T> class LELBinaryCmp : public LELInterface<Bool>
211 {
212 public:
213 
214 // Constructor takes operation and left and right expressions
215 // to be operated upon. It can only handle the comparison operators.
217  const CountedPtr<LELInterface<T> >& pLeftExpr,
218  const CountedPtr<LELInterface<T> >& pRightExpr);
219 
220 // Destructor
221  ~LELBinaryCmp();
222 
223 // Recursively evaluate the expression
224  virtual void eval (LELArray<Bool>& result,
225  const Slicer& section) const;
226 
227 // Recursively evaluate the scalar expression
228  virtual LELScalar<Bool> getScalar() const;
229 
230 // Do further preparations (e.g. optimization) on the expression.
231  virtual Bool prepareScalarExpr();
232 
233 // Get class name
234  virtual String className() const;
235 
236  // Handle locking/syncing of a lattice in a lattice expression.
237  // <group>
238  virtual Bool lock (FileLocker::LockType, uInt nattempts);
239  virtual void unlock();
240  virtual Bool hasLock (FileLocker::LockType) const;
241  virtual void resync();
242  // </group>
243 
244 private:
248 };
249 
250 
251 
252 
253 // <summary> This LEL class handles logical binary operators </summary>
254 //
255 // <use visibility=local>
256 //
257 // <reviewed reviewer="" date="yyyy/mm/dd" tests="" demos="">
258 // </reviewed>
259 //
260 // <prerequisite>
261 // <li> <linkto class="Lattice"> Lattice</linkto>
262 // <li> <linkto class="LatticeExpr"> LatticeExpr</linkto>
263 // <li> <linkto class="LatticeExprNode"> LatticeExprNode</linkto>
264 // <li> <linkto class="LELInterface"> LELInterface</linkto>
265 // <li> <linkto class="LELBinaryEnums"> LELBinaryEnums</linkto>
266 // </prerequisite>
267 
268 // <etymology>
269 // This derived LEL letter class handles logical binary operators
270 // </etymology>
271 //
272 // <synopsis>
273 // This LEL letter class is derived from LELInterface. It
274 // is used to construct LEL objects that apply logical
275 // binary operators to Lattice expressions. They apply only
276 // to Bool Lattice expressions and result in a Bool. The
277 // available C++ operators are <src>&&,||,==,!=</src> with
278 // equivalents in the enum of AND, OR, EQ, and NE
279 //
280 // A description of the implementation details of the LEL classes can
281 // be found in
282 // <a href="../notes/216.html">Note 216</a>
283 //
284 // </synopsis>
285 //
286 // <example>
287 // Examples are not very useful as the user would never use
288 // these classes directly. Look in LatticeExprNode.cc to see
289 // how it invokes these classes. Examples of how the user
290 // would indirectly use this class (through the envelope) are:
291 // <srcblock>
292 // IPosition shape(2,5,10);
293 // ArrayLattice<Bool> x(shape); x.set(False);
294 // ArrayLattice<Bool> y(shape); y.set(True);
295 // ArrayLattice<Bool> z(shape); z.set(False);
296 // z.copyData(x&&y); // z = x && y;
297 // z.copyData(x||y); // z = x || y;
298 // z.copyData(x==y); // z = x == y;
299 // z.copyData(x!=y); // z = x != y;
300 // </srcblock>
301 // </example>
302 //
303 // <motivation>
304 // Logical binary operations are a basic mathematical expression.
305 // </motivation>
306 //
307 // <todo asof="1998/01/20">
308 // </todo>
309 
310 
311 class LELBinaryBool : public LELInterface<Bool>
312 {
313 public:
314 
315 // Constructor takes operation and left and right expressions
316 // to be operated upon.
318  const CountedPtr<LELInterface<Bool> >& pLeftExpr,
319  const CountedPtr<LELInterface<Bool> >& pRightExpr);
320 
321 // Destructor
322  ~LELBinaryBool();
323 
324 // Recursively evaluate the expression
325  virtual void eval (LELArray<Bool>& result,
326  const Slicer& section) const;
327 
328 // Recursively evaluate the scalar expression
329  virtual LELScalar<Bool> getScalar() const;
330 
331 // Do further preparations (e.g. optimization) on the expression.
332  virtual Bool prepareScalarExpr();
333 
334 // Get class name
335  virtual String className() const;
336 
337  // Handle locking/syncing of a lattice in a lattice expression.
338  // <group>
339  virtual Bool lock (FileLocker::LockType, uInt nattempts);
340  virtual void unlock();
341  virtual Bool hasLock (FileLocker::LockType) const;
342  virtual void resync();
343  // </group>
344 
345 private:
349 };
350 
351 
352 
353 
354 } //# NAMESPACE CASACORE - END
355 
356 #ifndef CASACORE_NO_AUTO_TEMPLATES
357 #include <casacore/lattices/LEL/LELBinary.tcc>
358 #endif //# CASACORE_NO_AUTO_TEMPLATES
359 #endif
virtual Bool lock(FileLocker::LockType, uInt nattempts)
Handle locking/syncing of a lattice in a lattice expression.
virtual LELScalar< Bool > getScalar() const
Recursively evaluate the scalar expression.
virtual Bool hasLock(FileLocker::LockType) const
This LEL class handles relational binary numerical operators.
Definition: LELBinary.h:210
CountedPtr< LELInterface< T > > pRightExpr_p
Definition: LELBinary.h:247
This LEL class holds an array with a mask.
Definition: LELInterface.h:44
LELBinaryCmp(const LELBinaryEnums::Operation op, const CountedPtr< LELInterface< T > > &pLeftExpr, const CountedPtr< LELInterface< T > > &pRightExpr)
Constructor takes operation and left and right expressions to be operated upon.
virtual Bool lock(FileLocker::LockType, uInt nattempts)
Handle locking/syncing of a lattice in a lattice expression.
virtual Bool lock(FileLocker::LockType, uInt nattempts)
Handle locking/syncing of a lattice in a lattice expression.
virtual LELScalar< T > getScalar() const
Recursively efvaluate the scalar expression.
virtual void resync()
virtual void resync()
virtual String className() const
Get class name.
virtual void eval(LELArray< Bool > &result, const Slicer &section) const
Recursively evaluate the expression.
LELBinaryEnums::Operation op_p
Definition: LELBinary.h:140
virtual void unlock()
virtual Bool prepareScalarExpr()
Do further preparations (e.g.
~LELBinaryBool()
Destructor.
This base class provides the interface for Lattice expressions.
Definition: LELInterface.h:150
LELBinaryEnums::Operation op_p
Definition: LELBinary.h:245
Referenced counted pointer for constant data.
Definition: VisModelData.h:42
LELBinaryEnums::Operation op_p
Definition: LELBinary.h:346
virtual Bool hasLock(FileLocker::LockType) const
virtual void resync()
virtual Bool prepareScalarExpr()
Do further preparations (e.g.
bool Bool
Define the standard types used by Casacore.
Definition: aipstype.h:42
This LEL class handles logical binary operators.
Definition: LELBinary.h:311
virtual Bool hasLock(FileLocker::LockType) const
LELBinaryBool(const LELBinaryEnums::Operation op, const CountedPtr< LELInterface< Bool > > &pLeftExpr, const CountedPtr< LELInterface< Bool > > &pRightExpr)
Constructor takes operation and left and right expressions to be operated upon.
virtual void unlock()
Specify which elements to extract from an n-dimensional array.
Definition: Slicer.h:289
This LEL class handles numerical binary operators.
Definition: LELBinary.h:102
CountedPtr< LELInterface< T > > pRightExpr_p
Definition: LELBinary.h:142
virtual Bool prepareScalarExpr()
Do further preparations (e.g.
CountedPtr< LELInterface< Bool > > pLeftExpr_p
Definition: LELBinary.h:347
virtual void eval(LELArray< Bool > &result, const Slicer &section) const
Recursively evaluate the expression.
String: the storage and methods of handling collections of characters.
Definition: String.h:223
virtual String className() const
Get class name.
virtual String className() const
Get class name.
LockType
Define the possible lock types.
Definition: FileLocker.h:95
~LELBinaryCmp()
Destructor.
virtual LELScalar< Bool > getScalar() const
Recursively evaluate the scalar expression.
LELBinary(const LELBinaryEnums::Operation op, const CountedPtr< LELInterface< T > > &pLeftExpr, const CountedPtr< LELInterface< T > > &pRightExpr)
Constructor takes operation and left and right expressions to be operated upon.
virtual void eval(LELArray< T > &result, const Slicer &section) const
Recursively evaluate the expression.
CountedPtr< LELInterface< T > > pLeftExpr_p
Definition: LELBinary.h:141
~LELBinary()
Destructor.
CountedPtr< LELInterface< Bool > > pRightExpr_p
Definition: LELBinary.h:348
CountedPtr< LELInterface< T > > pLeftExpr_p
Definition: LELBinary.h:246
unsigned int uInt
Definition: aipstype.h:51
This LEL class holds a scalar with a mask.
Definition: LELInterface.h:43
virtual void unlock()
#define casacore
&lt;X11/Intrinsic.h&gt; #defines true, false, casacore::Bool, and String.
Definition: X11Intrinsic.h:42