casacore
Loading...
Searching...
No Matches
LatticeExprNode.h
Go to the documentation of this file.
1// # LatticeExprNode.h: LatticeExprNode.h
2// # Copyright (C) 1997,1998,1999,2000,2001,2002,2003
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_LATTICEEXPRNODE_H
27#define LATTICES_LATTICEEXPRNODE_H
28
29// # Includes
30#include <casacore/casa/aips.h>
31#include <casacore/lattices/LEL/LELInterface.h>
32#include <casacore/lattices/LEL/LELAttribute.h>
33#include <casacore/lattices/LEL/LELBinaryEnums.h>
34#include <casacore/lattices/LEL/LELUnaryEnums.h>
35#include <casacore/lattices/LEL/LELFunctionEnums.h>
36#include <casacore/casa/Arrays/ArrayFwd.h>
37#include <casacore/casa/Arrays/IPosition.h>
38#include <casacore/casa/Utilities/DataType.h>
39#include <memory>
40
41namespace casacore { // # NAMESPACE CASACORE - BEGIN
42
43// # Forward Declarations
44template <class T>
45class LatticeExpr;
46template <class T>
47class Lattice;
48template <class T>
49class MaskedLattice;
50template <class T>
51class Block;
52class LCRegion;
53class Slicer;
55class LatticeExprNode;
56
57// Global functions operating on a LatticeExprNode.
58// <group name=GlobalLatticeExprNode>
59// Unary functions.
60// <group>
64// </group>
65
66// Numerical binary operators
67// <group>
74// </group>
75
76// Relational binary operators
77// <group>
84// </group>
85
86// Logical binary operators
87// <group>
90// </group>
91
92// Numerical 1-argument functions
93// <group>
112// </group>
113
114// Numerical 2-argument functions
115// <group>
121// </group>
122
123// Form a complex number from two real numbers.
125
126// Numerical 1-argument functions which result in a real number
127// regardless of input expression type
128// <group>
133// </group>
134
135// 1-argument functions operating on a numeric expression resulting
136// in a scalar
137// <group>
146// </group>
147
148// Determine the value of the element at the part <src>fraction</src>
149// from the beginning of the given lattice.
150// Thus <src>fraction=0.5</src> is equal to the median.
152
153// Determine the value range of the elements at the part <src>fraction1</src>
154// and fraction2 from the beginning of the given lattice. Both fractions
155// must be >=0 and <=1 and fraction1 must be <= fraction2.
156// By default <src>fraction2</src> is equal to <src>1-fraction1</src>.
157// Thus <src>fraction=0.25</src> gives the quartile range of the lattice.
158// <group>
160 const LatticeExprNode& fraction2);
162// </group>
163
164// 1-argument function to get the number of elements in a lattice.
165// If the lattice is masked, only the True elements are counted.
166// Results in a scalar Double.
168
169// 1-argument function to get the dimensionality of a lattice.
170// 0 is returned if it is a scalar.
171// Results in a scalar Float.
173
174// 2-argument function to get the length of an axis.
175// Results in a scalar Float.
176// The 2nd expression (giving the axis number) has to be a real scalar.
177// <note role=caution>
178// Axes start counting at 0.
179// If the axis is a number < 0, an exception is thrown.
180// If the axis is a number exceeding the dimensionality, 1 is returned.
181// </note>
183
184// 2-argument function telling per pixel if its index on the given axis
185// is contained in the 2nd argument. The 2nd argument should be a boolean
186// vector where True means that the index is contained.
187// For indices >= vector_length, the 2nd argument defaults to False.
188// Results in a Bool array.
189// <note role=caution>
190// Axes start counting at 0.
191// If the axis is a number < 0 or >= ndim, an exception is thrown.
192// </note>
194
195// 2-argument function rebinning Lattice by given factors. The 2nd argument
196// should be a vector (preferably Float - really Int but Int not well
197// supported in LEL yet). Results in a T array.
199
200// Test if a value is a NaN.
202
203// Functions operating on a logical expression resulting in a scalar;
204// Functions "any" (are any pixels "True") and "all" (are all pixels
205// "True") result in a Bool; functions "ntrue" and "nfalse" result
206// in a Double.
207// <group>
212// </group>
213
214// This function returns the mask of the given expression.
215// If it has no mask, the result is an array with all True values.
217
218// This function returns the value of the expression without a mask.
220
221// This function finds <src>sqrt(left^2+right^2)</src>. This
222// could be used to find the (biased) polarized intensity if
223// left and right are images of Stokes Q and U.
225
226// This function finds <src>180/pi*atan2(left,right)/2</src>. This could be
227// used to find the position of linear polarization if left
228// and right are images of Stokes U and Q, respectively.
230
231// This function finds the spectral index
232// <src>alpha = log(s1/s2) / log(f1/f2)</src>.
234
235// Function resembling the ternary <src>?:</src> construct in C++.
236// The argument "condition" has to be a Bool scalar or lattice.
237// If an element in "condition" is True, the corresponding element from
238// "arg1" is taken, otherwise it is taken from "arg2".
240 const LatticeExprNode& arg2);
241
242// This function replaces every masked-off element in the first argument
243// with the corresponding element from the second argument.
244// The first argument has to be a lattice (expression), the second can
245// be a scalar or lattice. The mask of the first argument is not changed.
246// If the first argument does not have a mask, this function does nothing.
248
249// Functions to convert to the given data type. These are mostly
250// meaningful for down-conversions (e.g. double to float),
251// since up-conversions are automatically done to get matching data types
252// when needed. Note that some conversions are not supported, such
253// as Complex to Double or Float.
254// <br>The conversion to Bool is useful to convert a region to a
255// boolean lattice, which is only possible if the region is given
256// in world coordinates. Otherwise an exception is thrown.
257// <group>
265LatticeExprNode convertType(const LatticeExprNode& expr, const Complex*);
266LatticeExprNode convertType(const LatticeExprNode& expr, const DComplex*);
268// </group>
269// </group>
270
271// <summary>
272// Bridging class to allow C++ expressions involving lattices
273// </summary>
274//
275// <use visibility=export>
276//
277// <reviewed reviewer="" date="yyyy/mm/dd" tests="" demos="">
278// </reviewed>
279//
280// <prerequisite>
281// <li> <linkto class="Lattice"> Lattice</linkto>
282// <li> <linkto class="LatticeExpr"> LatticeExpr</linkto>
283// <li> <linkto class="LELInterface"> LELInterface</linkto>
284// </prerequisite>
285//
286// <etymology>
287// The name is derived from the fact that this class provides
288// an expression interface to the user which s/he may use to
289// write C++ expressions involving Lattices. This class actually
290// constructs the nodes of the expression tree, hence its name.
291// It is used by the envelope class LatticeExpr and provides a
292// bridge to the letter classes derived from LELInterface.
293// </etymology>
294//
295// <synopsis>
296// This class is part of the interface which allows the C++ programmer
297// to enter mathematical expressions involving Lattices. It is
298// is part of a Letter/envelope scheme. It's actually a bridge
299// between the envelope class (LatticeExpr) and the letter classes
300// (derived from LELInterface) and it exists largely to handle
301// type conversions. In a single type environment, the envelope
302// class could have directly called the letter classes.
303//
304// The envelope and bridge provide the interface which the programmer
305// sees. The letter classes do the real work and are hidden from
306// the programmer.
307//
308// All the expression manipulation functionality that the user has
309// access to is viewable in this class; it is here that the operators,
310// functions and constructors are defined. These allow the programmer
311// to write mathematical expressions which involve Lattices. The
312// letter classes take care of the optimal traversal of the Lattice
313// and the memory mangement thereof. Thus the Lattices are iterated
314// through and the expressions evaluated for each chunk (usually
315// a tile shape) of the iteration.
316//
317// A description of the implementation details of these classes can
318// be found in
319// <a href="../notes/216.html">Note 216</a>
320//
321// The available functionality is defined by the global friend functions
322// and operators, plus the public constructors. The other public members
323// functions are generally not of interest to the user of this class.
324//
325// Generally, if one writes an expression such as <src>a.copyData(sin(b))</src>,
326// the expression is automatically converted first to a LatticeExprNode and
327// then to a LatticeExpr (which is a Lattice) before evaluation occurs.
328// However, it may occur that you wish to build an expression from
329// subexpressions. To do this, you must explcitly create objects of
330// class LatticeExprNode. You cannot manipulate subexpressions of type
331// LatticeExpr<T>. See below for an example.
332// </synopsis>
333//
334// <example>
335// <srcblock>
336// ArrayLattice<Float> f1(IPosition (2,nx,ny));
337// ArrayLattice<Float> f2(IPosition (2,nx,ny));
338// f2.set(2.0);
339// f1.copyData(2*f2+f2);
340// </srcblock>
341// In this example, the values of the pixels in Lattice f1 are set
342// to the values resulting from the expression "2*f2 + f2"
343// I.e. the expression is evaluated for each pixel in the Lattices
344//
345// Note that :
346//
347// 1) the Lattice::copyData function is expecting a Lattice argument.
348// 2) LatticeExpr inherits from Lattice and therefore a LatticeExpr
349// object is a valid argument object type
350// 3) The expression in the copyData call is automatically converted to
351// a LatticeExprNode by the constructors and operators in LatticeExprNode
352// 4) The LatticeExprNode object so created is automatically converted
353// to a LatticeExpr by casting functions in LatticeExprNode.
354//
355// </example>
356//
357// <example>
358// <srcblock>
359// ArrayLattice<Float> f1(IPosition (2,nx,ny));
360// ArrayLattice<Float> f2(IPosition (2,nx,ny));
361// ArrayLattice<Double> d(IPosition (2,nx,ny));
362// ArrayLattice<Complex> c(IPosition (2,nx,ny));
363// ArrayLattice<Bool> b(IPosition (2,nx,ny));
364//
365// f2.set(1.0); d.set(2.0); c.set(Complex(2.0,3.0)); b.set(True);
366// f1.copyData( (3.5*f2) + (cos(d)) - (10/min(d,f2)*(-abs(c))*ntrue(b)) - (C::pi) );
367// </srcblock>
368//
369// In this rather silly example, we fill Lattice "f1" with the result of the
370// expression. The expression shows the use of constants, unary operations,
371// binary operations, 1D and 2D functions. It also shows how mixed types can
372// be handled. The output Lattice is a Float, whereas mixed into the
373// expression are subexpressions involving Float, Double, Complex and Bool
374// Lattices.
375//
376// </example>
377//
378// <example>
379// <srcblock>
380// ArrayLattice<Float> f1(IPosition (2,nx,ny));
381// ArrayLattice<Float> f2(IPosition (2,nx,ny));
382// f2.set(2.0);
383// LatticeExprNode exp1(sin(f2));
384// LatticeExprNode exp2(pow(f2,2.0));
385// f1.copyData(exp1+exp2);
386// </srcblock>
387// In this example, the expression is "sin(f2) + pow(f2,2.0)",
388// but we have put it together from two subexpressions contained
389// in LatticeExprNode objects exp1 and exp2. Again the LatticeExprNode
390// object formed from summing exp1 and exp2 is automatically converted
391// to a LatticeExpr for consumption by copyData
392//
393// </example>
394//
395// <motivation>
396// The Lattice expression classes enable the C++ programmer much simpler
397// handling of mathematical expressions involving lattices. In addition,
398// these classes provide the infrastructure on top of which we can build
399// an image calculator for Glish users
400// </motivation>
401//
402// <todo asof="1997/01/15">
403// <li> masks
404// <li> regions
405// </todo>
406
408 // All global functions need to be declared as friends.
409 // <group>
413 friend LatticeExprNode operator+(const LatticeExprNode& left, const LatticeExprNode& right);
414 friend LatticeExprNode operator-(const LatticeExprNode& left, const LatticeExprNode& right);
415 friend LatticeExprNode operator*(const LatticeExprNode& left, const LatticeExprNode& right);
416 friend LatticeExprNode operator/(const LatticeExprNode& left, const LatticeExprNode& right);
417 friend LatticeExprNode operator%(const LatticeExprNode& left, const LatticeExprNode& right);
418 friend LatticeExprNode operator^(const LatticeExprNode& left, const LatticeExprNode& right);
420 friend LatticeExprNode operator>(const LatticeExprNode& left, const LatticeExprNode& right);
422 friend LatticeExprNode operator<(const LatticeExprNode& left, const LatticeExprNode& right);
445 friend LatticeExprNode atan2(const LatticeExprNode& left, const LatticeExprNode& right);
446 friend LatticeExprNode pow(const LatticeExprNode& left, const LatticeExprNode& right);
447 friend LatticeExprNode fmod(const LatticeExprNode& left, const LatticeExprNode& right);
448 friend LatticeExprNode min(const LatticeExprNode& left, const LatticeExprNode& right);
449 friend LatticeExprNode max(const LatticeExprNode& left, const LatticeExprNode& right);
463 friend LatticeExprNode fractile(const LatticeExprNode& expr, const LatticeExprNode& fraction);
465 const LatticeExprNode& fraction1,
466 const LatticeExprNode& fraction2);
468 const LatticeExprNode& fraction);
471 friend LatticeExprNode length(const LatticeExprNode& expr, const LatticeExprNode& axis);
472 friend LatticeExprNode indexin(const LatticeExprNode& axis, const LatticeExprNode& indexFlags);
473 friend LatticeExprNode rebin(const LatticeExprNode& expr, const LatticeExprNode& bin);
481 friend LatticeExprNode amp(const LatticeExprNode& left, const LatticeExprNode& right);
482 friend LatticeExprNode pa(const LatticeExprNode& left, const LatticeExprNode& right);
484 friend LatticeExprNode iif(const LatticeExprNode& condition, const LatticeExprNode& arg1,
485 const LatticeExprNode& arg2);
486 friend LatticeExprNode replace(const LatticeExprNode& arg1, const LatticeExprNode& arg2);
492 // </group>
493
494 public:
495 // Default constructor
497
498 // Unary constant expression constructors.
499 // <group>
506 LatticeExprNode(const Complex& constant);
507 LatticeExprNode(const DComplex& constant);
509 // </group>
510
511 // Constructor from an IPosition (containing indices or axes).
513
514 // Lattice expression (gets Lattice pixels) constructors.
515 // <group>
526 // </group>
527
528 // Create a lattice expression from a region.
529 // It results in a boolean expression node.
530 // <group>
531 LatticeExprNode(const LCRegion& region);
532 LatticeExprNode(const Slicer& slicer);
534 // </group>
535
536 // Masking operator using a condition.
537 // The given boolean expression forms a mask/region for this expression node.
539
540 // Copy constructor (reference semantics)
542
543 // Destructor, does nothing
545
546 // Assignment (reference semantics)
548
549 // Get the IPosition.
550 // It throws an exception if the node does not contain an IPosition.
551 const IPosition& getIPosition() const;
552
553 // Convert the expression to another data type.
554 // <group>
555 std::shared_ptr<LELInterface<Float>> makeFloat() const;
556 std::shared_ptr<LELInterface<Double>> makeDouble() const;
557 std::shared_ptr<LELInterface<Complex>> makeComplex() const;
558 std::shared_ptr<LELInterface<DComplex>> makeDComplex() const;
559 std::shared_ptr<LELInterface<Bool>> makeBool() const;
560 // </group>
561
562 // Evaluate the expression.
563 // One can be sure that the result is not a reference to another array.
564 // This function should be used by LatticeExpr and other users.
565 // <group>
566 void eval(LELArray<Float>& result, const Slicer& section) const;
567 void eval(LELArray<Double>& result, const Slicer& section) const;
568 void eval(LELArray<Complex>& result, const Slicer& section) const;
569 void eval(LELArray<DComplex>& result, const Slicer& section) const;
570 void eval(LELArray<Bool>& result, const Slicer& section) const;
571 // </group>
572
573 // Evaluate the expression.
574 // The result can be a reference to some internal array (in particular
575 // to an array in an ArrayLattice object used as a lattice).
576 // This function is meant for internal use by the LEL classes and
577 // should not be used externally.
578 // <group>
579 void evalRef(LELArrayRef<Float>& result, const Slicer& section) const {
580 pExprFloat_p->evalRef(result, section);
581 }
582 void evalRef(LELArrayRef<Double>& result, const Slicer& section) const {
583 pExprDouble_p->evalRef(result, section);
584 }
585 void evalRef(LELArrayRef<Complex>& result, const Slicer& section) const {
586 pExprComplex_p->evalRef(result, section);
587 }
588 void evalRef(LELArrayRef<DComplex>& result, const Slicer& section) const {
589 pExprDComplex_p->evalRef(result, section);
590 }
591 void evalRef(LELArrayRef<Bool>& result, const Slicer& section) const {
592 pExprBool_p->evalRef(result, section);
593 }
594 // </group>
595
596 // Evaluate the expression (in case it is a scalar). The "eval"
597 // and "get*" functions do the same thing, they just have
598 // a slightly different interface.
599 // <group>
600 void eval(Float& result) const;
601 void eval(Double& result) const;
602 void eval(Complex& result) const;
603 void eval(DComplex& result) const;
604 void eval(Bool& result) const;
607 Complex getComplex() const;
608 DComplex getDComplex() const;
609 Bool getBool() const;
610 // </group>
611
612 // Evaluate the expression (in case it is a constant array).
613 // <group>
619 // </group>
620
621 // Get the data type of the expression.
622 DataType dataType() const { return dtype_p; }
623
624 // Is the expression node a region?
625 Bool isRegion() const { return pAttr_p->isRegion(); }
626
627 // Is the result of "eval" a scalar?
628 Bool isScalar() const { return pAttr_p->isScalar(); }
629
630 // Is the result of "eval" masked?
631 Bool isMasked() const { return pAttr_p->isMasked(); }
632
633 // Holds the node an invalid scalar?
635 if (!donePrepare_p) doPrepare();
636 return isInvalid_p;
637 }
638
639 // Return the shape of the Lattice including all degenerate axes
640 // (ie. axes with a length of one)
641 const IPosition& shape() const { return pAttr_p->shape(); }
642
643 // Get the attribute object of the expression.
644 const LELAttribute& getAttribute() const { return *pAttr_p; }
645
646 // Replace a scalar subexpression by its result.
648
649 // Make the object from a std::shared_ptr<LELInterface> pointer.
650 // Ideally this function is private, but alas it is needed in LELFunction1D,
651 // operator==, and more (too many to make them friend).
652 // <group>
653 LatticeExprNode(const std::shared_ptr<LELInterface<Float>>& expr);
654 LatticeExprNode(const std::shared_ptr<LELInterface<Double>>& expr);
655 LatticeExprNode(const std::shared_ptr<LELInterface<Complex>>& expr);
656 LatticeExprNode(const std::shared_ptr<LELInterface<DComplex>>& expr);
657 LatticeExprNode(const std::shared_ptr<LELInterface<Bool>>& expr);
658 // </group>
659
660 // Determine the resulting data type from the given data types.
661 // An exception is thrown if they are incompatible.
662 static DataType resultDataType(DataType left, DataType right);
663
664 // Check the arguments of a function and return the resulting attribute object.
665 // The matchAxes argument tells if the axes have to match exactly or
666 // whether it is possible that one expression is a subset of another
667 // (i.e. that axes may be missing).
668 // <br>The expectArray argument tells if the result should be an array
669 // which is the case if one of the arguments is an array.
671 Bool expectArray, Bool matchAxes = True);
672
673 // Handle locking of the LatticeExpr which is delegated to all of its parts.
674 // <group>
676 void unlock();
678 void resync();
679 // </group>
680
681 private:
682 // Make the object from a LELInterface* pointer.
683 // <group>
689 // </group>
690
691 // Test if both operands represent a region.
692 // An exception is thrown if only one of them is a region.
693 static Bool areRegions(const LatticeExprNode& left, const LatticeExprNode& right);
694
695 // Create a new node for a numerical unary operation.
696 // The result has the same data type as the input.
698
699 // Create a new node for a numerical function with 1 argument.
700 // The result has the same data type as the input.
702
703 // Create a new node for a real numerical function with 1 argument.
704 // The result has the same data type as the input.
706 const LatticeExprNode& expr);
707
708 // Create a new node for a complex numerical function with 1 argument.
709 // The result has the same data type as the input.
711 const LatticeExprNode& expr);
712
713 // Create a new node for a numerical function with 1 argument that
714 // returns a real number
716
717 // Create a new node for a numerical function with 2 arguments.
718 // The result has the same data type as the combined input type.
720 const LatticeExprNode& right);
721
722 // Create a new node for a numerical binary operator.
723 // The result has the same data type as the combined input type.
725 const LatticeExprNode& right);
726
727 // Create a new node for a logical binary operator.
728 // The result has the same data type as the combined input type.
730 const LatticeExprNode& right);
731
732 // Create a new node for a comparison binary operator.
733 // The result has the same data type as the combined input type.
735 const LatticeExprNode& right);
736
737 // Make (if needed and if possible) the expression nodes such that
738 // the dimensionalities are equal. This is only possible if both
739 // nodes have a coordinate system.
740 // It is done by creating an ExtendLattice object for the node
741 // with the lower dimensionality.
743
744 // Do the preparation for the evaluation.
745 void doPrepare() const;
746
747 // Member variables.
748
750 DataType dtype_p;
754 std::shared_ptr<LELInterface<Float>> pExprFloat_p;
755 std::shared_ptr<LELInterface<Double>> pExprDouble_p;
756 std::shared_ptr<LELInterface<Complex>> pExprComplex_p;
757 std::shared_ptr<LELInterface<DComplex>> pExprDComplex_p;
758 std::shared_ptr<LELInterface<Bool>> pExprBool_p;
759};
760
761inline LatticeExprNode operator%(const LatticeExprNode& left, const LatticeExprNode& right) {
762 return fmod(left, right);
763}
764inline LatticeExprNode operator^(const LatticeExprNode& left, const LatticeExprNode& right) {
765 return pow(left, right);
766}
767
769 return toFloat(expr);
770}
772 return toDouble(expr);
773}
774inline LatticeExprNode convertType(const LatticeExprNode& expr, const Complex*) {
775 return toComplex(expr);
776}
777inline LatticeExprNode convertType(const LatticeExprNode& expr, const DComplex*) {
778 return toDComplex(expr);
779}
780inline LatticeExprNode convertType(const LatticeExprNode& expr, const Bool*) {
781 return toBool(expr);
782}
783
784} // namespace casacore
785
786#endif
LockType
Define the possible lock types.
Definition FileLocker.h:89
This LEL class holds a possible referenced array with a mask.
Definition LELArray.h:119
std::shared_ptr< LELInterface< DComplex > > makeDComplex() const
friend LatticeExprNode avdev(const LatticeExprNode &expr)
friend LatticeExprNode tan(const LatticeExprNode &expr)
friend LatticeExprNode round(const LatticeExprNode &expr)
LatticeExprNode(const std::shared_ptr< LELInterface< Complex > > &expr)
Array< Complex > getArrayComplex() const
LatticeExprNode(LELInterface< Double > *expr)
void evalRef(LELArrayRef< Double > &result, const Slicer &section) const
void evalRef(LELArrayRef< Float > &result, const Slicer &section) const
Evaluate the expression.
void eval(LELArray< Complex > &result, const Slicer &section) const
void evalRef(LELArrayRef< DComplex > &result, const Slicer &section) const
friend LatticeExprNode operator>(const LatticeExprNode &left, const LatticeExprNode &right)
friend LatticeExprNode formComplex(const LatticeExprNode &left, const LatticeExprNode &right)
Form a complex number from two real numbers.
std::shared_ptr< LELInterface< Bool > > makeBool() const
void eval(Bool &result) const
LatticeExprNode operator[](const LatticeExprNode &cond) const
Masking operator using a condition.
friend LatticeExprNode max(const LatticeExprNode &expr)
LatticeExprNode(const std::shared_ptr< LELInterface< Double > > &expr)
LatticeExprNode(const DComplex &constant)
friend LatticeExprNode asin(const LatticeExprNode &expr)
friend LatticeExprNode toComplex(const LatticeExprNode &expr)
friend LatticeExprNode log10(const LatticeExprNode &expr)
static LatticeExprNode newBinaryCmp(LELBinaryEnums::Operation oper, const LatticeExprNode &left, const LatticeExprNode &right)
Create a new node for a comparison binary operator.
void evalRef(LELArrayRef< Complex > &result, const Slicer &section) const
LatticeExprNode(const Lattice< Float > &lattice)
Lattice expression (gets Lattice pixels) constructors.
friend LatticeExprNode pow(const LatticeExprNode &left, const LatticeExprNode &right)
void eval(Double &result) const
Double getDouble() const
friend LatticeExprNode exp(const LatticeExprNode &expr)
const IPosition & shape() const
Return the shape of the Lattice including all degenerate axes (ie.
friend LatticeExprNode median(const LatticeExprNode &expr)
LatticeExprNode(const LCRegion &region)
Create a lattice expression from a region.
LatticeExprNode(const std::shared_ptr< LELInterface< Bool > > &expr)
friend LatticeExprNode mask(const LatticeExprNode &expr)
This function returns the mask of the given expression.
DComplex getDComplex() const
friend LatticeExprNode operator+(const LatticeExprNode &left, const LatticeExprNode &right)
Numerical binary operators.
friend LatticeExprNode ceil(const LatticeExprNode &expr)
friend LatticeExprNode operator-(const LatticeExprNode &expr)
friend LatticeExprNode fractileRange(const LatticeExprNode &expr, const LatticeExprNode &fraction1, const LatticeExprNode &fraction2)
Determine the value range of the elements at the part fraction1 and fraction2 from the beginning of t...
LatticeExprNode(const MaskedLattice< Bool > &lattice)
friend LatticeExprNode tanh(const LatticeExprNode &expr)
Array< DComplex > getArrayDComplex() const
friend LatticeExprNode operator+(const LatticeExprNode &expr)
All global functions need to be declared as friends.
void doPrepare() const
Do the preparation for the evaluation.
std::shared_ptr< LELInterface< Bool > > pExprBool_p
friend LatticeExprNode rebin(const LatticeExprNode &expr, const LatticeExprNode &bin)
2-argument function rebinning Lattice by given factors.
std::shared_ptr< LELInterface< Double > > makeDouble() const
void eval(LELArray< Float > &result, const Slicer &section) const
Evaluate the expression.
friend LatticeExprNode min(const LatticeExprNode &left, const LatticeExprNode &right)
friend LatticeExprNode real(const LatticeExprNode &expr)
friend LatticeExprNode floor(const LatticeExprNode &expr)
Bool replaceScalarExpr()
Replace a scalar subexpression by its result.
friend LatticeExprNode arg(const LatticeExprNode &expr)
static LatticeExprNode newRealFunc1D(LELFunctionEnums::Function func, const LatticeExprNode &expr)
Create a new node for a real numerical function with 1 argument.
friend LatticeExprNode operator^(const LatticeExprNode &left, const LatticeExprNode &right)
friend LatticeExprNode value(const LatticeExprNode &expr)
This function returns the value of the expression without a mask.
friend LatticeExprNode toDouble(const LatticeExprNode &expr)
static LatticeExprNode newLogBinary(LELBinaryEnums::Operation oper, const LatticeExprNode &left, const LatticeExprNode &right)
Create a new node for a logical binary operator.
void eval(Complex &result) const
void eval(LELArray< Double > &result, const Slicer &section) const
friend LatticeExprNode sign(const LatticeExprNode &expr)
LatticeExprNode(const Lattice< Bool > &lattice)
friend LatticeExprNode operator<(const LatticeExprNode &left, const LatticeExprNode &right)
static LatticeExprNode newNumFunc1D(LELFunctionEnums::Function func, const LatticeExprNode &expr)
Create a new node for a numerical function with 1 argument.
Bool hasLock(FileLocker::LockType) const
Array< Double > getArrayDouble() const
LatticeExprNode(const LattRegionHolder &region)
friend LatticeExprNode fractile(const LatticeExprNode &expr, const LatticeExprNode &fraction)
Determine the value of the element at the part fraction from the beginning of the given lattice.
LatticeExprNode & operator=(const LatticeExprNode &other)
Assignment (reference semantics).
friend LatticeExprNode atan2(const LatticeExprNode &left, const LatticeExprNode &right)
Numerical 2-argument functions.
LatticeExprNode(LELInterface< Bool > *expr)
friend LatticeExprNode nfalse(const LatticeExprNode &expr)
friend LatticeExprNode stddev(const LatticeExprNode &expr)
const LELAttribute * pAttr_p
friend LatticeExprNode amp(const LatticeExprNode &left, const LatticeExprNode &right)
This function finds sqrt(left^2+right^2).
friend LatticeExprNode max(const LatticeExprNode &left, const LatticeExprNode &right)
LatticeExprNode(Long constant)
friend LatticeExprNode operator!=(const LatticeExprNode &left, const LatticeExprNode &right)
Array< Float > getArrayFloat() const
Evaluate the expression (in case it is a constant array).
LatticeExprNode(uInt constant)
friend LatticeExprNode conj(const LatticeExprNode &expr)
LatticeExprNode(const Complex &constant)
friend LatticeExprNode ntrue(const LatticeExprNode &expr)
friend LatticeExprNode fractileRange(const LatticeExprNode &expr, const LatticeExprNode &fraction)
LatticeExprNode(const Lattice< Complex > &lattice)
static LatticeExprNode newNumFunc2D(LELFunctionEnums::Function func, const LatticeExprNode &left, const LatticeExprNode &right)
Create a new node for a numerical function with 2 arguments.
LatticeExprNode(const Slicer &slicer)
friend LatticeExprNode atan(const LatticeExprNode &expr)
std::shared_ptr< LELInterface< Complex > > makeComplex() const
LatticeExprNode(const Lattice< Double > &lattice)
Bool isScalar() const
Is the result of "eval" a scalar?
std::shared_ptr< LELInterface< DComplex > > pExprDComplex_p
LatticeExprNode(const MaskedLattice< Double > &lattice)
LatticeExprNode(LELInterface< Complex > *expr)
friend LatticeExprNode toBool(const LatticeExprNode &expr)
friend LatticeExprNode operator<=(const LatticeExprNode &left, const LatticeExprNode &right)
void evalRef(LELArrayRef< Bool > &result, const Slicer &section) const
const IPosition & getIPosition() const
Get the IPosition.
const LELAttribute & getAttribute() const
Get the attribute object of the expression.
friend LatticeExprNode min(const LatticeExprNode &expr)
1-argument functions operating on a numeric expression resulting in a scalar
friend LatticeExprNode all(const LatticeExprNode &expr)
LatticeExprNode(const std::shared_ptr< LELInterface< Float > > &expr)
Make the object from a std::shared_ptr<LELInterface> pointer.
friend LatticeExprNode length(const LatticeExprNode &expr, const LatticeExprNode &axis)
2-argument function to get the length of an axis.
friend LatticeExprNode abs(const LatticeExprNode &expr)
Numerical 1-argument functions which result in a real number regardless of input expression type.
LatticeExprNode(const MaskedLattice< Complex > &lattice)
friend LatticeExprNode replace(const LatticeExprNode &arg1, const LatticeExprNode &arg2)
This function replaces every masked-off element in the first argument with the corresponding element ...
LatticeExprNode(const MaskedLattice< Float > &lattice)
Bool isRegion() const
Is the expression node a region?
std::shared_ptr< LELInterface< Float > > makeFloat() const
Convert the expression to another data type.
Bool isMasked() const
Is the result of "eval" masked?
void eval(LELArray< Bool > &result, const Slicer &section) const
friend LatticeExprNode log(const LatticeExprNode &expr)
friend LatticeExprNode variance(const LatticeExprNode &expr)
Array< Bool > getArrayBool() const
static Int makeEqualDim(LatticeExprNode &expr0, LatticeExprNode &expr1)
Make (if needed and if possible) the expression nodes such that the dimensionalities are equal.
void eval(LELArray< DComplex > &result, const Slicer &section) const
LatticeExprNode()
Default constructor.
LatticeExprNode(Bool constant)
friend LatticeExprNode cosh(const LatticeExprNode &expr)
static LELAttribute checkArg(const Block< LatticeExprNode > &arg, const Block< Int > &argType, Bool expectArray, Bool matchAxes=True)
Check the arguments of a function and return the resulting attribute object.
friend LatticeExprNode sin(const LatticeExprNode &expr)
Numerical 1-argument functions.
friend LatticeExprNode ndim(const LatticeExprNode &expr)
1-argument function to get the dimensionality of a lattice.
friend LatticeExprNode operator*(const LatticeExprNode &left, const LatticeExprNode &right)
LatticeExprNode(Int constant)
friend LatticeExprNode toFloat(const LatticeExprNode &expr)
Functions to convert to the given data type.
friend LatticeExprNode any(const LatticeExprNode &expr)
Functions operating on a logical expression resulting in a scalar; Functions "any" (are any pixels "T...
friend LatticeExprNode operator||(const LatticeExprNode &left, const LatticeExprNode &right)
std::shared_ptr< LELInterface< Complex > > pExprComplex_p
LatticeExprNode(Float constant)
std::shared_ptr< LELInterface< Float > > pExprFloat_p
friend LatticeExprNode operator-(const LatticeExprNode &left, const LatticeExprNode &right)
Bool isInvalidScalar() const
Holds the node an invalid scalar?
friend LatticeExprNode cos(const LatticeExprNode &expr)
static Bool areRegions(const LatticeExprNode &left, const LatticeExprNode &right)
Test if both operands represent a region.
LatticeExprNode(const LatticeExprNode &other)
Copy constructor (reference semantics).
void eval(DComplex &result) const
LatticeExprNode(Int64 constant)
Unary constant expression constructors.
virtual ~LatticeExprNode()
Destructor, does nothing.
std::shared_ptr< LELInterface< Double > > pExprDouble_p
friend LatticeExprNode sinh(const LatticeExprNode &expr)
friend LatticeExprNode sum(const LatticeExprNode &expr)
friend LatticeExprNode isNaN(const LatticeExprNode &expr)
Test if a value is a NaN.
friend LatticeExprNode fmod(const LatticeExprNode &left, const LatticeExprNode &right)
static LatticeExprNode newNumUnary(LELUnaryEnums::Operation oper, const LatticeExprNode &expr)
Create a new node for a numerical unary operation.
friend LatticeExprNode spectralindex(const LatticeExprNode &left, const LatticeExprNode &right)
This function finds the spectral index alpha = log(s1/s2) / log(f1/f2).
LatticeExprNode(Double constant)
Bool lock(FileLocker::LockType, uInt nattempts)
Handle locking of the LatticeExpr which is delegated to all of its parts.
friend LatticeExprNode operator!(const LatticeExprNode &expr)
LatticeExprNode(LELInterface< Float > *expr)
Make the object from a LELInterface* pointer.
friend LatticeExprNode acos(const LatticeExprNode &expr)
void eval(Float &result) const
Evaluate the expression (in case it is a scalar).
friend LatticeExprNode operator>=(const LatticeExprNode &left, const LatticeExprNode &right)
friend LatticeExprNode sqrt(const LatticeExprNode &expr)
LatticeExprNode(const IPosition &)
Constructor from an IPosition (containing indices or axes).
friend LatticeExprNode operator%(const LatticeExprNode &left, const LatticeExprNode &right)
Bool donePrepare_p
Member variables.
LatticeExprNode(LELInterface< DComplex > *expr)
friend LatticeExprNode indexin(const LatticeExprNode &axis, const LatticeExprNode &indexFlags)
2-argument function telling per pixel if its index on the given axis is contained in the 2nd argument...
friend LatticeExprNode toDComplex(const LatticeExprNode &expr)
friend LatticeExprNode operator&&(const LatticeExprNode &left, const LatticeExprNode &right)
Logical binary operators.
Complex getComplex() const
friend LatticeExprNode pa(const LatticeExprNode &left, const LatticeExprNode &right)
This function finds 180/pi*atan2(left,right)/2.
DataType dataType() const
Get the data type of the expression.
friend LatticeExprNode mean(const LatticeExprNode &expr)
friend LatticeExprNode nelements(const LatticeExprNode &expr)
1-argument function to get the number of elements in a lattice.
LatticeExprNode(const MaskedLattice< DComplex > &lattice)
friend LatticeExprNode operator/(const LatticeExprNode &left, const LatticeExprNode &right)
static LatticeExprNode newNumBinary(LELBinaryEnums::Operation oper, const LatticeExprNode &left, const LatticeExprNode &right)
Create a new node for a numerical binary operator.
LatticeExprNode(const Lattice< DComplex > &lattice)
static DataType resultDataType(DataType left, DataType right)
Determine the resulting data type from the given data types.
friend LatticeExprNode imag(const LatticeExprNode &expr)
static LatticeExprNode newComplexFunc1D(LELFunctionEnums::Function func, const LatticeExprNode &expr)
Create a new node for a complex numerical function with 1 argument.
LatticeExprNode(const std::shared_ptr< LELInterface< DComplex > > &expr)
friend LatticeExprNode iif(const LatticeExprNode &condition, const LatticeExprNode &arg1, const LatticeExprNode &arg2)
Function resembling the ternary ?
static LatticeExprNode newNumReal1D(LELFunctionEnums::Function func, const LatticeExprNode &expr)
Create a new node for a numerical function with 1 argument that returns a real number.
friend LatticeExprNode operator==(const LatticeExprNode &left, const LatticeExprNode &right)
Relational binary operators.
bool operator==(const String &x, const String &y)
Global comparison operators.
Definition String.h:849
String operator+(const String &lhs, const String &rhs)
Global concatenation operators.
Definition String.h:816
For temporary backward namespace compatibility, use casa as alias for casacore.
Definition mainpage.dox:28
LatticeExprNode pa(const LatticeExprNode &left, const LatticeExprNode &right)
This function finds 180/pi*atan2(left,right)/2.
LatticeExprNode fractile(const LatticeExprNode &expr, const LatticeExprNode &fraction)
Determine the value of the element at the part fraction from the beginning of the given lattice.
size_t nelements() const
The number of elements contained in this Block<T>.
Definition Block.h:565
LatticeExprNode exp(const LatticeExprNode &expr)
LatticeExprNode isNaN(const LatticeExprNode &expr)
Test if a value is a NaN.
LatticeExprNode operator&&(const LatticeExprNode &left, const LatticeExprNode &right)
Logical binary operators.
LatticeExprNode fractileRange(const LatticeExprNode &expr, const LatticeExprNode &fraction1, const LatticeExprNode &fraction2)
Determine the value range of the elements at the part fraction1 and fraction2 from the beginning of t...
LatticeExprNode asin(const LatticeExprNode &expr)
LatticeExprNode fmod(const LatticeExprNode &left, const LatticeExprNode &right)
LatticeExprNode acos(const LatticeExprNode &expr)
LatticeExprNode ndim(const LatticeExprNode &expr)
1-argument function to get the dimensionality of a lattice.
LatticeExprNode replace(const LatticeExprNode &arg1, const LatticeExprNode &arg2)
This function replaces every masked-off element in the first argument with the corresponding element ...
LatticeExprNode mean(const LatticeExprNode &expr)
bool operator<(const String &x, const String &y)
Definition String.h:853
LatticeExprNode max(const LatticeExprNode &left, const LatticeExprNode &right)
long Long
Definition aipstype.h:50
LatticeExprNode cosh(const LatticeExprNode &expr)
LatticeExprNode atan(const LatticeExprNode &expr)
LatticeExprNode indexin(const LatticeExprNode &axis, const LatticeExprNode &indexFlags)
2-argument function telling per pixel if its index on the given axis is contained in the 2nd argument...
LatticeExprNode tanh(const LatticeExprNode &expr)
LatticeExprNode sign(const LatticeExprNode &expr)
bool operator>=(const String &x, const String &y)
Definition String.h:852
LatticeExprNode arg(const LatticeExprNode &expr)
LatticeExprNode log10(const LatticeExprNode &expr)
LatticeExprNode toFloat(const LatticeExprNode &expr)
Functions to convert to the given data type.
LatticeExprNode conj(const LatticeExprNode &expr)
LatticeExprNode formComplex(const LatticeExprNode &left, const LatticeExprNode &right)
Form a complex number from two real numbers.
LatticeExprNode operator%(const LatticeExprNode &left, const LatticeExprNode &right)
LatticeExprNode sinh(const LatticeExprNode &expr)
LatticeExprNode sum(const LatticeExprNode &expr)
unsigned int uInt
Definition aipstype.h:49
LatticeExprNode stddev(const LatticeExprNode &expr)
LatticeExprNode min(const LatticeExprNode &left, const LatticeExprNode &right)
LatticeExprNode abs(const LatticeExprNode &expr)
Numerical 1-argument functions which result in a real number regardless of input expression type.
LatticeExprNode operator-(const LatticeExprNode &expr)
LatticeExprNode tan(const LatticeExprNode &expr)
LatticeExprNode mask(const LatticeExprNode &expr)
This function returns the mask of the given expression.
LatticeExprNode sin(const LatticeExprNode &expr)
Numerical 1-argument functions.
LatticeExprNode operator/(const LatticeExprNode &left, const LatticeExprNode &right)
LatticeExprNode atan2(const LatticeExprNode &left, const LatticeExprNode &right)
Numerical 2-argument functions.
LatticeExprNode variance(const LatticeExprNode &expr)
long long Int64
Define the extra non-standard types used by Casacore (like proposed uSize, Size).
Definition aipsxtype.h:36
LatticeExprNode toDouble(const LatticeExprNode &expr)
LatticeExprNode any(const LatticeExprNode &expr)
Functions operating on a logical expression resulting in a scalar; Functions "any" (are any pixels "T...
LatticeExprNode sqrt(const LatticeExprNode &expr)
float Float
Definition aipstype.h:52
bool operator<=(const String &x, const String &y)
Definition String.h:854
LatticeExprNode ntrue(const LatticeExprNode &expr)
LatticeExprNode amp(const LatticeExprNode &left, const LatticeExprNode &right)
This function finds sqrt(left^2+right^2).
LatticeExprNode toBool(const LatticeExprNode &expr)
LatticeExprNode avdev(const LatticeExprNode &expr)
LatticeExprNode length(const LatticeExprNode &expr, const LatticeExprNode &axis)
2-argument function to get the length of an axis.
LatticeExprNode convertType(const LatticeExprNode &expr, const Float *)
LatticeExprNode toComplex(const LatticeExprNode &expr)
LatticeExprNode pow(const LatticeExprNode &left, const LatticeExprNode &right)
LatticeExprNode toDComplex(const LatticeExprNode &expr)
LatticeExprNode log(const LatticeExprNode &expr)
LatticeExprNode iif(const LatticeExprNode &condition, const LatticeExprNode &arg1, const LatticeExprNode &arg2)
Function resembling the ternary ?
T & operator*()
Provide access to the field's value.
LatticeExprNode spectralindex(const LatticeExprNode &left, const LatticeExprNode &right)
This function finds the spectral index alpha = log(s1/s2) / log(f1/f2).
int Int
Definition aipstype.h:48
bool Bool
Define the standard types used by Casacore.
Definition aipstype.h:40
LatticeExprNode operator^(const LatticeExprNode &left, const LatticeExprNode &right)
bool operator>(const String &x, const String &y)
Definition String.h:851
bool operator!=(const String &x, const String &y)
Definition String.h:850
LatticeExprNode cos(const LatticeExprNode &expr)
LatticeExprNode operator!(const LatticeExprNode &expr)
LatticeExprNode floor(const LatticeExprNode &expr)
const Bool True
Definition aipstype.h:41
NewDelAllocator< T > NewDelAllocator< T >::value
Definition Allocator.h:360
double Double
Definition aipstype.h:53
LatticeExprNode median(const LatticeExprNode &expr)
LatticeExprNode all(const LatticeExprNode &expr)
LatticeExprNode round(const LatticeExprNode &expr)
LatticeExprNode ceil(const LatticeExprNode &expr)
LatticeExprNode real(const LatticeExprNode &expr)
LatticeExprNode operator||(const LatticeExprNode &left, const LatticeExprNode &right)
LatticeExprNode nfalse(const LatticeExprNode &expr)
LatticeExprNode imag(const LatticeExprNode &expr)
LatticeExprNode rebin(const LatticeExprNode &expr, const LatticeExprNode &bin)
2-argument function rebinning Lattice by given factors.