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