casacore
LELFunction.h
Go to the documentation of this file.
1//# LELFunction.h: LELFunction.h
2//# Copyright (C) 1997,1998,1999,2000,2001
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_LELFUNCTION_H
29#define LATTICES_LELFUNCTION_H
30
31
32//# Includes
33#include <casacore/casa/aips.h>
34#include <casacore/lattices/LEL/LELInterface.h>
35#include <casacore/lattices/LEL/LatticeExprNode.h>
36#include <casacore/lattices/LEL/LELFunctionEnums.h>
37#include <casacore/casa/Containers/Block.h>
38
39namespace casacore { //# NAMESPACE CASACORE - BEGIN
40
41//# Forward Declarations
42
43
44// <summary>
45// This LEL class handles numerical (real and complex) 1-argument functions
46// </summary>
47//
48// <use visibility=local>
49//
50// <reviewed reviewer="" date="yyyy/mm/dd" tests="" demos="">
51// </reviewed>
52//
53// <prerequisite>
54// <li> <linkto class="Lattice"> Lattice</linkto>
55// <li> <linkto class="LatticeExpr"> LatticeExpr</linkto>
56// <li> <linkto class="LatticeExprNode"> LatticeExprNode</linkto>
57// <li> <linkto class="LELInterface"> LELInterface</linkto>
58// <li> <linkto class="LELFunctionEnums"> LELFunctionEnums</linkto>
59// </prerequisite>
60//
61// <etymology>
62// This derived LEL letter class handles numerical (real and complex)
63// 1-argument functions
64// </etymology>
65//
66// <synopsis>
67// This LEL letter class is derived from LELInterface. It is used to construct
68// LEL objects that apply numerical 1-argument functions to Lattice
69// expressions. They operate on numerical (Float,Double,Complex,DComplex)
70// Lattice expressions and return the same type. The available C++ functions are
71// <src>sin,sinh,cos,cosh,exp,log,log10,sqrt,min,max,mean,sum</src> with
72// equivalents in the enum of SIN,SINH,COS,COSH,EXP,LOG,LOG10,SQRT,MIN1D,MAX1D,
73// MEAN1D, and SUM.
74//
75// A description of the implementation details of the LEL classes can
76// be found in
77// <a href="../notes/216.html">Note 216</a>
78// </synopsis>
79//
80// <example>
81// Examples are not very useful as the user would never use
82// these classes directly. Look in LatticeExprNode.cc to see
83// how it invokes these classes. Examples of how the user
84// would indirectly use this class (through the envelope) are:
85// <srcblock>
86// IPosition shape(2,5,10);
87// ArrayLattice<Complex> x(shape); x.set(1.0);
88// ArrayLattice<Complex> y(shape);
89// y.copyData(sin(x)); // y = sin(x)
90// y.copyData(min(x)); // y = min(x)
91// </srcblock>
92// Note that the min function returns a scalar, and the output
93// Lattice is filled with that one value.
94// </example>
95//
96// <motivation>
97// Numerical functions are a basic mathematical expression.
98// </motivation>
99//
100// <todo asof="1998/01/21">
101// </todo>
102
103
104template <class T> class LELFunction1D : public LELInterface<T>
105{
106 //# Make members of parent class known.
107protected:
108 using LELInterface<T>::setAttr;
109
110public:
111// Constructor takes operation and expression to be operated upon
113 const CountedPtr<LELInterface<T> >& expr);
114
115// Destructor
117
118// Recursively evaluate the expression
119 virtual void eval (LELArray<T>& result,
120 const Slicer& section) const;
121
122// Recursively evaluate the scalar expression.
123 virtual LELScalar<T> getScalar() const;
124
125// Do further preparations (e.g. optimization) on the expression.
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();
136 virtual void resync();
137 // </group>
138
139private:
142};
143
144
145
146
147// <summary>
148// This LEL class handles numerical (real only) 1-argument functions
149// </summary>
150//
151// <use visibility=local>
152//
153// <reviewed reviewer="" date="yyyy/mm/dd" tests="" demos="">
154// </reviewed>
155//
156// <prerequisite>
157// <li> <linkto class="Lattice"> Lattice</linkto>
158// <li> <linkto class="LatticeExpr"> LatticeExpr</linkto>
159// <li> <linkto class="LatticeExprNode"> LatticeExprNode</linkto>
160// <li> <linkto class="LELInterface"> LELInterface</linkto>
161// <li> <linkto class="LELFunctionEnums"> LELFunctionEnums</linkto>
162// </prerequisite>
163//
164// <etymology>
165// This derived LEL letter class handles numerical (real only)
166// 1-argument functions
167// </etymology>
168//
169// <synopsis>
170// This LEL letter class is derived from LELInterface. It is used to construct
171// LEL objects that apply numerical (real only) 1-argument functions to
172// Lattice expressions. They operate on Float and Double numerical Lattice
173// expressions and return the same type. The available C++ functions are
174// <src>asin,acos,tan,tanh,ceil,floor</src> with
175// equivalents in the enum of ASIN, ACOS, TAN, TANH, CEIL, and FLOOR.
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// </synopsis>
181//
182// <example>
183// Examples are not very useful as the user would never use
184// these classes directly. Look in LatticeExprNode.cc to see
185// how it invokes these classes. Examples of how the user
186// would indirectly use this class (through the envelope) are:
187// <srcblock>
188// IPosition shape(2,5,10);
189// ArrayLattice<Float> x(shape); x.set(0.05);
190// ArrayLattice<Float> y(shape);
191// y.copyData(asin(x)); // y = asin(x)
192// y.copyData(tan(x)); // y = tan(x)
193// </srcblock>
194// Note that the min function returns a scalar, and the output
195// Lattice is filled with that one value.
196// </example>
197//
198// <motivation>
199// Numerical functions are a basic mathematical expression.
200// </motivation>
201//
202// <todo asof="1998/01/21">
203// </todo>
204
205
206template <class T> class LELFunctionReal1D : public LELInterface<T>
207{
208 //# Make members of parent class known.
209protected:
210 using LELInterface<T>::setAttr;
211
212public:
213// Constructor takes operation and expression to be operated upon
215 const CountedPtr<LELInterface<T> >& expr);
216
217// Destructor
219
220// Recursively evaluate the expression
221 virtual void eval (LELArray<T>& result,
222 const Slicer& section) const;
223
224// Recursively evaluate the scalar expression
225 virtual LELScalar<T> getScalar() const;
226
227// Do further preparations (e.g. optimization) on the expression.
229
230// Get class name
231 virtual String className() const;
232
233// Handle locking/syncing of a lattice in a lattice expression.
234 // <group>
235 virtual Bool lock (FileLocker::LockType, uInt nattempts);
236 virtual void unlock();
238 virtual void resync();
239 // </group>
240
241
242private:
245};
246
247
248
249
250// <summary>
251// This LEL class handles functions with a variable number of arguments.
252// </summary>
253//
254// <use visibility=local>
255//
256// <reviewed reviewer="" date="yyyy/mm/dd" tests="" demos="">
257// </reviewed>
258//
259// <prerequisite>
260// <li> <linkto class="Lattice"> Lattice</linkto>
261// <li> <linkto class="LatticeExpr"> LatticeExpr</linkto>
262// <li> <linkto class="LatticeExprNode"> LatticeExprNode</linkto>
263// <li> <linkto class="LELInterface"> LELInterface</linkto>
264// <li> <linkto class="LELFunctionEnums"> LELFunctionEnums</linkto>
265// </prerequisite>
266//
267// <etymology>
268// This derived LEL letter class handles numerical functions (arbitrary
269// number of arguments) which return any data type
270// </etymology>
271//
272// <synopsis>
273// This templated LEL letter class is derived from LELInterface.
274// It is used to construct LEL objects that apply functions of
275// arbitrary number of arguments to Lattice expressions.
276// They operate lattices with any type and return the same type.
277// The available C++ function is
278// <src>iif</src> with equivalents in the enum of IIF.
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// </synopsis>
284//
285// <example>
286// Examples are not very useful as the user would never use
287// these classes directly. Look in LatticeExprNode.cc to see
288// how it invokes these classes. Examples of how the user
289// would indirectly use this class (through the envelope) are:
290// <srcblock>
291// IPosition shape(2,5,10);
292// ArrayLattice<Complex> w(shape); w.set(Complex(2.0,3.0));
293// ArrayLattice<Float> x(shape); x.set(0.05);
294// ArrayLattice<Float> y(shape); y.set(2.0);
295// ArrayLattice<Float> z(shape); y.set(2.0);
296//
297// z.copyData(iif(x==0, y, x));
298//
299// </srcblock>
300// Copy x to z, but where x==0, take the correpsonding element from y.
301// </example>b
302//
303// <motivation>
304// An "if-then-else" like construction is very useful.
305// </motivation>
306//
307// <todo asof="1998/01/21">
308// </todo>
309
310
311template<class T> class LELFunctionND : public LELInterface<T>
312{
313 //# Make members of parent class known.
314protected:
315 using LELInterface<T>::setAttr;
316
317public:
318// Constructor takes operation and expressions to be operated upon
320 const Block<LatticeExprNode>& expr);
321
322// Destructor
324
325// Recursively evaluate the expression
326 virtual void eval (LELArray<T>& result,
327 const Slicer& section) const;
328
329// Recursively evaluate the scalar expression
330 virtual LELScalar<T> getScalar() const;
331
332// Do further preparations (e.g. optimization) on the expression.
334
335// Get class name
336 virtual String className() const;
337
338 // Handle locking/syncing of a lattice in a lattice expression.
339 // <group>
340 virtual Bool lock (FileLocker::LockType, uInt nattempts);
341 virtual void unlock();
343 virtual void resync();
344 // </group>
345
346private:
349};
350
351
352
353
354// <summary>
355// This LEL class handles numerical functions whose return type is a Float
356// </summary>
357//
358// <use visibility=local>
359//
360// <reviewed reviewer="" date="yyyy/mm/dd" tests="" demos="">
361// </reviewed>
362//
363// <prerequisite>
364// <li> <linkto class="Lattice"> Lattice</linkto>
365// <li> <linkto class="LatticeExpr"> LatticeExpr</linkto>
366// <li> <linkto class="LatticeExprNode"> LatticeExprNode</linkto>
367// <li> <linkto class="LELInterface"> LELInterface</linkto>
368// <li> <linkto class="LELFunctionEnums"> LELFunctionEnums</linkto>
369// </prerequisite>
370//
371// <etymology>
372// This derived LEL letter class handles numerical functions (arbitrary
373// number of arguments) which return a Float
374// </etymology>
375//
376// <synopsis>
377// This LEL letter class is derived from LELInterface. It is used to construct
378// LEL objects that apply numerical functions of arbitrary number of
379// arguments (but only 1 or 2 arguments currently implemented) to Lattice
380// expressions. They operate on Float or Complex Lattices
381// and return a Float. The available C++ functions are
382// <src>min,max,pow,atan2,fmod,abs,arg,real,imag</src> with
383// equivalents in the enum of MIN,MAX,POW,ATAN2,FMOD,ABS,ARG,REAL, and IMAG.
384//
385// A description of the implementation details of the LEL classes can
386// be found in
387// <a href="../notes/216.html">Note 216</a>
388// </synopsis>
389//
390// <example>
391// Examples are not very useful as the user would never use
392// these classes directly. Look in LatticeExprNode.cc to see
393// how it invokes these classes. Examples of how the user
394// would indirectly use this class (through the envelope) are:
395// <srcblock>
396// IPosition shape(2,5,10);
397// ArrayLattice<Complex> w(shape); w.set(Complex(2.0,3.0));
398// ArrayLattice<Float> x(shape); x.set(0.05);
399// ArrayLattice<Float> y(shape); y.set(2.0);
400// ArrayLattice<Float> z(shape); y.set(2.0);
401//
402// z.copyData(min(x,y)); // z = min(x,y)
403// z.copyData(imag(w)); // z = imag(w)
404//
405// </srcblock>
406// Note that this min function takes two arguments and returns
407// the minimum of the two, pixel by pixel (i.e. it does not
408// return one scalar from the whole Lattice)
409// </example>b
410//
411// <motivation>
412// Numerical functions are a basic mathematical expression.
413// </motivation>
414//
415// <todo asof="1998/01/21">
416// </todo>
417
418
419class LELFunctionFloat : public LELInterface<Float>
420{
421public:
422
423// Constructor takes operation and left and right expressions
424// to be operated upon
426 const Block<LatticeExprNode>& expr);
427
428// Destructor
430
431// Recursively evaluate the expression
432 virtual void eval (LELArray<Float>& result,
433 const Slicer& section) const;
434
435// Recursively evaluate the scalar expression
437
438// Do further preparations (e.g. optimization) on the expression.
440
441// Get class name
442 virtual String className() const;
443
444 // Handle locking/syncing of a lattice in a lattice expression.
445 // <group>
446 virtual Bool lock (FileLocker::LockType, uInt nattempts);
447 virtual void unlock();
449 virtual void resync();
450 // </group>
451
452private:
455};
456
457
458
459// <summary>
460// This LEL class handles numerical functions whose return type is a Double
461// </summary>
462//
463// <use visibility=local>
464//
465// <reviewed reviewer="" date="yyyy/mm/dd" tests="" demos="">
466// </reviewed>
467//
468// <prerequisite>
469// <li> <linkto class="Lattice"> Lattice</linkto>
470// <li> <linkto class="LatticeExpr"> LatticeExpr</linkto>
471// <li> <linkto class="LatticeExprNode"> LatticeExprNode</linkto>
472// <li> <linkto class="LELInterface"> LELInterface</linkto>
473// <li> <linkto class="LELFunctionEnums"> LELFunctionEnums</linkto>
474// </prerequisite>
475//
476// <etymology>
477// This derived LEL letter class handles numerical functions (arbitrary
478// number of arguments) which return a Double
479// </etymology>
480//
481// <synopsis>
482// This LEL letter class is derived from LELInterface. It is used to construct
483// LEL objects that apply numerical functions of arbitrary number of
484// arguments (but only 1 or 2 arguments currently implemented) to Lattice
485// expressions. They operate on Double or DComplex Lattices
486// and return a Double. The available C++ functions are
487// <src>min,max,pow,atan2,fmod,abs,arg,real,imag</src> with
488// equivalents in the enum of MIN,MAX,POW,ATAN2,FMOD,ABS,ARG,REAL, and IMAG.
489//
490// There are also two other functions for which the input Lattice expression
491// type must be a Bool. These are <src>ntrue,nfalse</src> with
492// equivalents in the enum of NTRUE and NFALSE.
493//
494// There is a further function for which the input Lattice expression
495// type can be anything. This is <src>nelements</src> with
496// equivalent in the enum of NELEM.
497//
498// A description of the implementation details of the LEL classes can
499// be found in
500// <a href="../notes/216.html">Note 216</a>
501// </synopsis>
502//
503// <example>
504// Examples are not very useful as the user would never use
505// these classes directly. Look in LatticeExprNode.cc to see
506// how it invokes these classes. Examples of how the user
507// would indirectly use this class (through the envelope) are:
508// <srcblock>
509// IPosition shape(2,5,10);
510// ArrayLattice<Bool> v(shape); v.set(True);
511// ArrayLattice<DComplex> w(shape); w.set(DComplex(2.0,3.0));
512// ArrayLattice<Double> x(shape); x.set(0.05);
513// ArrayLattice<Double> y(shape); y.set(2.0);
514// ArrayLattice<Double> z(shape); y.set(2.0);
515//
516// z.copyData(min(x,y)); // z = min(x,y)
517// z.copyData(imag(w)); // z = imag(w)
518// z.copyData(nelements(v)); // z = nelements(v)
519// z.copyData(ntrue(v)); // z = ntrue(v)
520// </srcblock>
521// </example>
522//
523// <motivation>
524// Numerical functions are a basic mathematical expression.
525// </motivation>
526//
527// <todo asof="1998/01/21">
528// </todo>
529
530
531class LELFunctionDouble : public LELInterface<Double>
532{
533public:
534
535// Constructor takes operation and left and right expressions
536// to be operated upon
538 const Block<LatticeExprNode>& expr);
539
540// Destructor
542
543// Recursively evaluate the expression
544 virtual void eval (LELArray<Double>& result,
545 const Slicer& section) const;
546
547// Recursively evaluate the scalar expression
549
550// Do further preparations (e.g. optimization) on the expression.
552
553// Get class name
554 virtual String className() const;
555
556 // Handle locking/syncing of a lattice in a lattice expression.
557 // <group>
558 virtual Bool lock (FileLocker::LockType, uInt nattempts);
559 virtual void unlock();
561 virtual void resync();
562 // </group>
563
564private:
565 // Count number of masked elements in a LatticeExprNode.
566 // <group>
569 // </group>
570
573};
574
575
576
577// <summary>
578// This LEL class handles complex numerical functions
579// </summary>
580//
581// <use visibility=local>
582//
583// <reviewed reviewer="" date="yyyy/mm/dd" tests="" demos="">
584// </reviewed>
585//
586// <prerequisite>
587// <li> <linkto class="Lattice"> Lattice</linkto>
588// <li> <linkto class="LatticeExpr"> LatticeExpr</linkto>
589// <li> <linkto class="LatticeExprNode"> LatticeExprNode</linkto>
590// <li> <linkto class="LELInterface"> LELInterface</linkto>
591// <li> <linkto class="LELFunctionEnums"> LELFunctionEnums</linkto>
592// </prerequisite>
593//
594// <etymology>
595// This derived LEL letter class handles complex numerical functions (arbitrary
596// number of arguments)
597// </etymology>
598//
599// <synopsis>
600// This LEL letter class is derived from LELInterface. It is used to construct
601// LEL objects that apply complex numerical functions of arbitrary number of
602// arguments (but only 1 or 2 arguments currently implemented) to Lattice
603// expressions. They operate on Complex Lattice expressions only
604// and return a Complex. The available C++ functions are
605// <src>pow,conj</src> with equivalents in the enum of POW and CONJ.
606//
607// A description of the implementation details of the LEL classes can
608// be found in
609// <a href="../notes/216.html">Note 216</a>
610// </synopsis>
611//
612// <example>
613// Examples are not very useful as the user would never use
614// these classes directly. Look in LatticeExprNode.cc to see
615// how it invokes these classes. Examples of how the user
616// would indirectly use this class (through the envelope) are:
617// <srcblock>
618// IPosition shape(2,5,10);
619// ArrayLattice<Complex> x(shape); x.set(Complex(2.0,3.0));
620// ArrayLattice<Complex> y(shape);
621// y.copyData(conj(x)); // y = conj(x)
622// </srcblock>
623// </example>
624//
625// <motivation>
626// Numerical functions are a basic mathematical expression.
627// </motivation>
628//
629// <todo asof="1998/01/21">
630// </todo>
631
632
633class LELFunctionComplex : public LELInterface<Complex>
634{
635public:
636
637// Constructor takes operation and left and right expressions
638// to be operated upon
640 const Block<LatticeExprNode>& expr);
641
642// Destructor
644
645// Recursively evaluate the expression
646 virtual void eval (LELArray<Complex>& result,
647 const Slicer& section) const;
648
649// Recursively evaluate the scalar expression
651
652// Do further preparations (e.g. optimization) on the expression.
654
655// Get class name
656 virtual String className() const;
657
658 // Handle locking/syncing of a lattice in a lattice expression.
659 // <group>
660 virtual Bool lock (FileLocker::LockType, uInt nattempts);
661 virtual void unlock();
663 virtual void resync();
664 // </group>
665
666private:
669};
670
671
672
673
674
675// <summary>
676// This LEL class handles double complex numerical functions
677// </summary>
678//
679// <use visibility=local>
680//
681// <reviewed reviewer="" date="yyyy/mm/dd" tests="" demos="">
682// </reviewed>
683//
684// <prerequisite>
685// <li> <linkto class="Lattice"> Lattice</linkto>
686// <li> <linkto class="LatticeExpr"> LatticeExpr</linkto>
687// <li> <linkto class="LatticeExprNode"> LatticeExprNode</linkto>
688// <li> <linkto class="LELInterface"> LELInterface</linkto>
689// <li> <linkto class="LELFunctionEnums"> LELFunctionEnums</linkto>
690// </prerequisite>
691//
692// <etymology>
693// This derived LEL letter class handles double complex numerical functions (arbitrary
694// number of arguments)
695// </etymology>
696//
697// <synopsis>
698// This LEL letter class is derived from LELInterface. It is used to construct
699// LEL objects that apply double complex numerical functions of arbitrary number of
700// arguments (but only 1 or 2 arguments currently implemented) to Lattice
701// expressions. They operate on DComplex Lattice expressions only
702// and return a DComplex. The available C++ functions are
703// <src>pow,conj</src> with equivalents in the enum of POW and CONJ.
704//
705// A description of the implementation details of the LEL classes can
706// be found in
707// <a href="../notes/216.html">Note 216</a>
708// </synopsis>
709//
710// <example>
711// Examples are not very useful as the user would never use
712// these classes directly. Look in LatticeExprNode.cc to see
713// how it invokes these classes. Examples of how the user
714// would indirectly use this class (through the envelope) are:
715// <srcblock>
716// IPosition shape(2,5,10);
717// ArrayLattice<DComplex> x(shape); x.set(DComplex(2.0,3.0));
718// ArrayLattice<DComplex> y(shape);
719// y.copyData(conj(x)); // y = conj(x)
720// </srcblock>
721// </example>
722//
723// <motivation>
724// Numerical functions are a basic mathematical expression.
725// </motivation>
726//
727// <todo asof="1998/01/21">
728// </todo>
729
730class LELFunctionDComplex : public LELInterface<DComplex>
731{
732public:
733
734// Constructor takes operation and left and right expressions
735// to be operated upon
737 const Block<LatticeExprNode>& expr);
738
739// Destructor
741
742// Recursively evaluate the expression
743 virtual void eval (LELArray<DComplex>& result,
744 const Slicer& section) const;
745
746// Recursively evaluate the scalar expression
748
749// Do further preparations (e.g. optimization) on the expression.
751
752// Get class name
753 virtual String className() const;
754
755 // Handle locking/syncing of a lattice in a lattice expression.
756 // <group>
757 virtual Bool lock (FileLocker::LockType, uInt nattempts);
758 virtual void unlock();
760 virtual void resync();
761 // </group>
762
763private:
766};
767
768
769// <summary>
770// This LEL class handles logical functions
771// </summary>
772//
773// <use visibility=local>
774//
775// <reviewed reviewer="" date="yyyy/mm/dd" tests="" demos="">
776// </reviewed>
777//
778// <prerequisite>
779// <li> <linkto class="Lattice"> Lattice</linkto>
780// <li> <linkto class="LatticeExpr"> LatticeExpr</linkto>
781// <li> <linkto class="LatticeExprNode"> LatticeExprNode</linkto>
782// <li> <linkto class="LELInterface"> LELInterface</linkto>
783// <li> <linkto class="LELFunctionEnums"> LELFunctionEnums</linkto>
784// </prerequisite>
785//
786// <etymology>
787// This derived LEL letter class handles logical functions (arbitrary
788// number of arguments)
789// </etymology>
790//
791// <synopsis>
792// This LEL letter class is derived from LELInterface. It is used to construct
793// LEL objects that apply logical functions of arbitrary number of
794// arguments (but only 1 or 2 arguments currently implemented) to Lattice
795// expressions. They operate on Bool Lattice expressions only
796// and return a Bool. The available C++ functions are
797// <src>all,any</src> with equivalents in the enum of ALL and ANY.
798//
799// A description of the implementation details of the LEL classes can
800// be found in
801// <a href="../notes/216.html">Note 216</a>
802// </synopsis>
803//
804// <example>
805// Examples are not very useful as the user would never use
806// these classes directly. Look in LatticeExprNode.cc to see
807// how it invokes these classes. Examples of how the user
808// would indirectly use this class (through the envelope) are:
809// <srcblock>
810// IPosition shape(2,5,10);
811// ArrayLattice<Bool> x(shape); x.set(True);
812// ArrayLattice<Bool> y(shape);
813// y.copyData(any(x)); // y = any(x)
814// </srcblock>
815// The result of the any function (were any of the values True) is
816// a Bool scalar. So the output Lattice is filled with that one value.
817// </example>
818//
819// <motivation>
820// Logical functions are a basic mathematical expression.
821// </motivation>
822//
823// <todo asof="1998/01/21">
824// </todo>
825
826class LELFunctionBool : public LELInterface<Bool>
827{
828public:
829
830// Constructor takes operation and left and right expressions
831// to be operated upon
833 const Block<LatticeExprNode>& expr);
834
835// Destructor
837
838// Recursively evaluate the expression
839 virtual void eval (LELArray<Bool>& result,
840 const Slicer& section) const;
841
842// Recursively evaluate the scalar expression
843 virtual LELScalar<Bool> getScalar() const;
844
845// Do further preparations (e.g. optimization) on the expression.
847
848// Get class name
849 virtual String className() const;
850
851 // Handle locking/syncing of a lattice in a lattice expression.
852 // <group>
853 virtual Bool lock (FileLocker::LockType, uInt nattempts);
854 virtual void unlock();
856 virtual void resync();
857 // </group>
858
859private:
862};
863
864
865
866
867} //# NAMESPACE CASACORE - END
868
869#ifndef CASACORE_NO_AUTO_TEMPLATES
870#include <casacore/lattices/LEL/LELFunction.tcc>
871#endif //# CASACORE_NO_AUTO_TEMPLATES
872#endif
simple 1-D array
Definition: Block.h:200
Referenced counted pointer for constant data.
Definition: CountedPtr.h:81
LockType
Define the possible lock types.
Definition: FileLocker.h:95
virtual LELScalar< T > getScalar() const
Recursively evaluate the scalar expression.
virtual Bool lock(FileLocker::LockType, uInt nattempts)
Handle locking/syncing of a lattice in a lattice expression.
CountedPtr< LELInterface< T > > pExpr_p
Definition: LELFunction.h:141
~LELFunction1D()
Destructor
virtual Bool hasLock(FileLocker::LockType) const
LELFunction1D(const LELFunctionEnums::Function function, const CountedPtr< LELInterface< T > > &expr)
Constructor takes operation and expression to be operated upon.
LELFunctionEnums::Function function_p
Definition: LELFunction.h:140
virtual Bool prepareScalarExpr()
Do further preparations (e.g.
virtual String className() const
Get class name.
virtual void resync()
virtual void eval(LELArray< T > &result, const Slicer &section) const
Recursively evaluate the expression
virtual void unlock()
This LEL class handles logical functions.
Definition: LELFunction.h:827
virtual Bool prepareScalarExpr()
Do further preparations (e.g.
LELFunctionEnums::Function function_p
Definition: LELFunction.h:860
LELFunctionBool(const LELFunctionEnums::Function function, const Block< LatticeExprNode > &expr)
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.
Block< LatticeExprNode > arg_p
Definition: LELFunction.h:861
virtual void eval(LELArray< Bool > &result, const Slicer &section) const
Recursively evaluate the expression
virtual LELScalar< Bool > getScalar() const
Recursively evaluate the scalar expression
virtual String className() const
Get class name.
virtual Bool hasLock(FileLocker::LockType) const
This LEL class handles complex numerical functions.
Definition: LELFunction.h:634
virtual String className() const
Get class name.
virtual Bool prepareScalarExpr()
Do further preparations (e.g.
virtual Bool hasLock(FileLocker::LockType) const
virtual void eval(LELArray< Complex > &result, const Slicer &section) const
Recursively evaluate the expression
LELFunctionEnums::Function function_p
Definition: LELFunction.h:667
virtual LELScalar< Complex > getScalar() const
Recursively evaluate the scalar expression
Block< LatticeExprNode > arg_p
Definition: LELFunction.h:668
virtual Bool lock(FileLocker::LockType, uInt nattempts)
Handle locking/syncing of a lattice in a lattice expression.
LELFunctionComplex(const LELFunctionEnums::Function function, const Block< LatticeExprNode > &expr)
Constructor takes operation and left and right expressions to be operated upon.
This LEL class handles double complex numerical functions.
Definition: LELFunction.h:731
virtual Bool hasLock(FileLocker::LockType) const
virtual void eval(LELArray< DComplex > &result, const Slicer &section) const
Recursively evaluate the expression
virtual String className() const
Get class name.
virtual Bool lock(FileLocker::LockType, uInt nattempts)
Handle locking/syncing of a lattice in a lattice expression.
LELFunctionEnums::Function function_p
Definition: LELFunction.h:764
virtual LELScalar< DComplex > getScalar() const
Recursively evaluate the scalar expression
Block< LatticeExprNode > arg_p
Definition: LELFunction.h:765
LELFunctionDComplex(const LELFunctionEnums::Function function, const Block< LatticeExprNode > &expr)
Constructor takes operation and left and right expressions to be operated upon.
virtual Bool prepareScalarExpr()
Do further preparations (e.g.
This LEL class handles numerical functions whose return type is a Double.
Definition: LELFunction.h:532
virtual Bool prepareScalarExpr()
Do further preparations (e.g.
virtual LELScalar< Double > getScalar() const
Recursively evaluate the scalar expression
uInt nMaskedOn(const Array< Bool > &mask) const
virtual void eval(LELArray< Double > &result, const Slicer &section) const
Recursively evaluate the expression
Block< LatticeExprNode > arg_p
Definition: LELFunction.h:572
virtual Bool hasLock(FileLocker::LockType) const
virtual String className() const
Get class name.
virtual Bool lock(FileLocker::LockType, uInt nattempts)
Handle locking/syncing of a lattice in a lattice expression.
LELFunctionEnums::Function function_p
Definition: LELFunction.h:571
uInt nMaskedElements(const LatticeExprNode &) const
Count number of masked elements in a LatticeExprNode.
LELFunctionDouble(const LELFunctionEnums::Function function, const Block< LatticeExprNode > &expr)
Constructor takes operation and left and right expressions to be operated upon.
This LEL class handles numerical functions whose return type is a Float.
Definition: LELFunction.h:420
virtual Bool prepareScalarExpr()
Do further preparations (e.g.
virtual void eval(LELArray< Float > &result, const Slicer &section) const
Recursively evaluate the expression
LELFunctionEnums::Function function_p
Definition: LELFunction.h:453
Block< LatticeExprNode > arg_p
Definition: LELFunction.h:454
virtual String className() const
Get class name.
virtual Bool lock(FileLocker::LockType, uInt nattempts)
Handle locking/syncing of a lattice in a lattice expression.
virtual LELScalar< Float > getScalar() const
Recursively evaluate the scalar expression
virtual Bool hasLock(FileLocker::LockType) const
LELFunctionFloat(const LELFunctionEnums::Function function, const Block< LatticeExprNode > &expr)
Constructor takes operation and left and right expressions to be operated upon.
This LEL class handles functions with a variable number of arguments.
Definition: LELFunction.h:312
Block< LatticeExprNode > arg_p
Definition: LELFunction.h:348
LELFunctionND(const LELFunctionEnums::Function function, const Block< LatticeExprNode > &expr)
Constructor takes operation and expressions to be operated upon.
LELFunctionEnums::Function function_p
Definition: LELFunction.h:347
~LELFunctionND()
Destructor
virtual Bool prepareScalarExpr()
Do further preparations (e.g.
virtual void resync()
virtual void unlock()
virtual String className() const
Get class name.
virtual LELScalar< T > getScalar() const
Recursively evaluate the scalar expression
virtual Bool lock(FileLocker::LockType, uInt nattempts)
Handle locking/syncing of a lattice in a lattice expression.
virtual void eval(LELArray< T > &result, const Slicer &section) const
Recursively evaluate the expression
virtual Bool hasLock(FileLocker::LockType) const
This LEL class handles numerical (real only) 1-argument functions.
Definition: LELFunction.h:207
virtual LELScalar< T > getScalar() const
Recursively evaluate the scalar expression
virtual Bool hasLock(FileLocker::LockType) const
virtual void eval(LELArray< T > &result, const Slicer &section) const
Recursively evaluate the expression
LELFunctionReal1D(const LELFunctionEnums::Function function, const CountedPtr< LELInterface< T > > &expr)
Constructor takes operation and expression to be operated upon.
virtual Bool prepareScalarExpr()
Do further preparations (e.g.
virtual String className() const
Get class name.
LELFunctionEnums::Function function_p
Definition: LELFunction.h:243
virtual Bool lock(FileLocker::LockType, uInt nattempts)
Handle locking/syncing of a lattice in a lattice expression.
CountedPtr< LELInterface< T > > pExpr_p
Definition: LELFunction.h:244
void setAttr(const LELAttribute &attrib)
Set the expression attributes of this object.
String: the storage and methods of handling collections of characters.
Definition: String.h:225
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