28 #ifndef LATTICES_LATTICEEXPRNODE_H
29 #define LATTICES_LATTICEEXPRNODE_H
33 #include <casacore/casa/aips.h>
34 #include <casacore/lattices/LEL/LELInterface.h>
35 #include <casacore/lattices/LEL/LELAttribute.h>
36 #include <casacore/lattices/LEL/LELBinaryEnums.h>
37 #include <casacore/lattices/LEL/LELUnaryEnums.h>
38 #include <casacore/lattices/LEL/LELFunctionEnums.h>
39 #include <casacore/casa/Arrays/ArrayFwd.h>
40 #include <casacore/casa/Arrays/IPosition.h>
41 #include <casacore/casa/Utilities/CountedPtr.h>
42 #include <casacore/casa/Utilities/DataType.h>
47 template <
class T>
class LatticeExpr;
48 template <
class T>
class Lattice;
49 template <
class T>
class MaskedLattice;
50 template <
class T>
class Block;
53 class LattRegionHolder;
54 class LatticeExprNode;
844 {
return fmod (left, right); }
847 {
return pow (left, right); }
Referenced counted pointer for constant data.
LockType
Define the possible lock types.
This LEL class holds a possible referenced array with a mask.
Bool isRegion() const
Is expression a region?
Bool isScalar() const
Is expression a scalar?
Bool isMasked() const
Is the expression result masked?
const IPosition & shape() const
What is the shape of the expression?
friend LatticeExprNode avdev(const LatticeExprNode &expr)
friend LatticeExprNode tan(const LatticeExprNode &expr)
const IPosition & shape() const
Return the shape of the Lattice including all degenerate axes (ie.
friend LatticeExprNode round(const LatticeExprNode &expr)
LatticeExprNode(LELInterface< Double > *expr)
void evalRef(LELArrayRef< Double > &result, const Slicer §ion) const
const LELAttribute & getAttribute() const
Get the attribute object of the expression.
CountedPtr< LELInterface< Complex > > makeComplex() const
void evalRef(LELArrayRef< Float > &result, const Slicer §ion) const
Evaluate the expression.
void eval(LELArray< Complex > &result, const Slicer §ion) const
void evalRef(LELArrayRef< DComplex > &result, const Slicer §ion) 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.
void eval(Bool &result) const
LatticeExprNode operator[](const LatticeExprNode &cond) const
Masking operator using a condition.
friend LatticeExprNode max(const LatticeExprNode &expr)
CountedPtr< LELInterface< Complex > > pExprComplex_p
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 §ion) 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
friend LatticeExprNode exp(const LatticeExprNode &expr)
friend LatticeExprNode median(const LatticeExprNode &expr)
LatticeExprNode(const LCRegion ®ion)
Create a lattice expression from a region.
friend LatticeExprNode mask(const LatticeExprNode &expr)
This function returns the mask of the given expression.
DComplex getDComplex() const
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)
friend LatticeExprNode operator+(const LatticeExprNode &expr)
All global functions need to be declared as friends.
void doPrepare() const
Do the preparation for the evaluation.
Array< Float > getArrayFloat() const
Evaluate the expression (in case it is a constant array).
LatticeExprNode(const CountedPtr< LELInterface< Complex > > &expr)
friend LatticeExprNode rebin(const LatticeExprNode &expr, const LatticeExprNode &bin)
2-argument function rebinning Lattice by given factors.
const IPosition & getIPosition() const
Get the IPosition.
LatticeExprNode(const CountedPtr< LELInterface< Double > > &expr)
LatticeExprNode & operator=(const LatticeExprNode &other)
Assignment (reference semantics)
void eval(LELArray< Float > &result, const Slicer §ion) 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)
CountedPtr< LELInterface< Float > > pExprFloat_p
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.
Array< Bool > getArrayBool() const
void eval(Complex &result) const
void eval(LELArray< Double > &result, const Slicer §ion) const
CountedPtr< LELInterface< Bool > > pExprBool_p
friend LatticeExprNode sign(const LatticeExprNode &expr)
LatticeExprNode(const Lattice< Bool > &lattice)
friend LatticeExprNode operator<(const LatticeExprNode &left, const LatticeExprNode &right)
LatticeExprNode(const CountedPtr< LELInterface< Float > > &expr)
Make the object from a Counted<LELInterface> pointer.
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
LatticeExprNode(const LattRegionHolder ®ion)
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.
friend LatticeExprNode atan2(const LatticeExprNode &left, const LatticeExprNode &right)
Numerical 2-argument functions.
LatticeExprNode(LELInterface< Bool > *expr)
Array< DComplex > getArrayDComplex() const
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)
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)
CountedPtr< LELInterface< Float > > makeFloat() const
Convert the expression to another data type.
LatticeExprNode(const Lattice< Double > &lattice)
Bool isScalar() const
Is the result of "eval" a scalar?
Array< Complex > getArrayComplex() const
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 §ion) const
friend LatticeExprNode min(const LatticeExprNode &expr)
1-argument functions operating on a numeric expression resulting in a scalar
friend LatticeExprNode all(const LatticeExprNode &expr)
friend LatticeExprNode length(const LatticeExprNode &expr, const LatticeExprNode &axis)
2-argument function to get the length of an axis.
Array< Double > getArrayDouble() const
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?
Bool isMasked() const
Is the result of "eval" masked?
void eval(LELArray< Bool > &result, const Slicer §ion) const
friend LatticeExprNode log(const LatticeExprNode &expr)
friend LatticeExprNode variance(const LatticeExprNode &expr)
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 §ion) 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.
CountedPtr< LELInterface< DComplex > > makeDComplex() const
friend LatticeExprNode operator*(const LatticeExprNode &left, const LatticeExprNode &right)
LatticeExprNode(Int constant)
CountedPtr< LELInterface< Double > > pExprDouble_p
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)
LatticeExprNode(Float constant)
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.
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.
CountedPtr< LELInterface< DComplex > > pExprDComplex_p
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 CountedPtr< LELInterface< Bool > > &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...
CountedPtr< LELInterface< Double > > makeDouble() const
friend LatticeExprNode toDComplex(const LatticeExprNode &expr)
friend LatticeExprNode operator&&(const LatticeExprNode &left, const LatticeExprNode &right)
Logical binary operators.
LatticeExprNode(const CountedPtr< LELInterface< DComplex > > &expr)
Complex getComplex() const
CountedPtr< LELInterface< Bool > > makeBool() 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.
friend LatticeExprNode iif(const LatticeExprNode &condition, const LatticeExprNode &arg1, const LatticeExprNode &arg2)
Function resembling the ternary ?: construct in C++.
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.
std::complex< Float > Complex
std::complex< Double > DComplex
this file contains all the compiler specific defines
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.
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 operator>(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)
LatticeExprNode max(const LatticeExprNode &left, const LatticeExprNode &right)
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)
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)
LatticeExprNode operator+(const LatticeExprNode &expr)
Global functions operating on a LatticeExprNode.
MVBaseline operator*(const RotMatrix &left, const MVBaseline &right)
Rotate a Baseline vector with rotation matrix and other multiplications.
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)
bool operator==(const casacore_allocator< T, ALIGNMENT > &, const casacore_allocator< T, ALIGNMENT > &)
LatticeExprNode mask(const LatticeExprNode &expr)
This function returns the mask of the given expression.
LatticeExprNode sin(const LatticeExprNode &expr)
Numerical 1-argument functions.
bool operator!=(const casacore_allocator< T, ALIGNMENT > &, const casacore_allocator< T, ALIGNMENT > &)
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)
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)
LatticeExprNode ntrue(const LatticeExprNode &expr)
LatticeExprNode amp(const LatticeExprNode &left, const LatticeExprNode &right)
This function finds sqrt(left^2+right^2).
LatticeExprNode operator<(const LatticeExprNode &left, const LatticeExprNode &right)
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 operator>=(const LatticeExprNode &left, const LatticeExprNode &right)
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 ?: construct in C++.
LatticeExprNode spectralindex(const LatticeExprNode &left, const LatticeExprNode &right)
This function finds the spectral index alpha = log(s1/s2) / log(f1/f2).
bool Bool
Define the standard types used by Casacore.
LatticeExprNode operator^(const LatticeExprNode &left, const LatticeExprNode &right)
LatticeExprNode value(const LatticeExprNode &expr)
This function returns the value of the expression without a mask.
LatticeExprNode cos(const LatticeExprNode &expr)
LatticeExprNode operator!(const LatticeExprNode &expr)
LatticeExprNode floor(const LatticeExprNode &expr)
LatticeExprNode median(const LatticeExprNode &expr)
LatticeExprNode all(const LatticeExprNode &expr)
LatticeExprNode nelements(const LatticeExprNode &expr)
1-argument function to get the number of elements in a lattice.
LatticeExprNode round(const LatticeExprNode &expr)
LatticeExprNode operator<=(const LatticeExprNode &left, const LatticeExprNode &right)
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.