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