casacore
|
#include <LatticeExpr.h>
Public Member Functions | |
LatticeExpr () | |
Default constructor. More... | |
LatticeExpr (const LatticeExprNode &expr) | |
Constructor from an arbitrary LatticeExprNode expression object. More... | |
LatticeExpr (const LatticeExprNode &expr, const IPosition &latticeShape) | |
LatticeExpr (const LatticeExpr< T > &other) | |
Copy constructor (reference semantics) More... | |
virtual | ~LatticeExpr () |
Destructor, does nothing. More... | |
LatticeExpr< T > & | operator= (const LatticeExpr< T > &other) |
Assignment (reference semantics) More... | |
virtual MaskedLattice< T > * | cloneML () const |
Make a copy of the derived object (reference semantics). More... | |
virtual Bool | isMasked () const |
Has the object really a mask? More... | |
virtual const LatticeRegion * | getRegionPtr () const |
Get the region used (always returns 0). More... | |
virtual Bool | isWritable () const |
Returns False, as the LatticeExpr lattice is not writable. More... | |
virtual Bool | lock (FileLocker::LockType, uInt nattempts) |
Handle locking of the LatticeExpr which is delegated to all of its parts. More... | |
virtual void | unlock () |
virtual Bool | hasLock (FileLocker::LockType) const |
virtual void | resync () |
Resynchronize the Lattice object with the lattice file. More... | |
virtual IPosition | shape () const |
Returns the shape of the Lattice including all degenerate axes (i.e. More... | |
virtual IPosition | doNiceCursorShape (uInt maxPixels) const |
Return the best cursor shape. More... | |
virtual LELCoordinates | lelCoordinates () const |
Returns the coordinates of the lattice expression. More... | |
virtual Bool | doGetSlice (Array< T > &buffer, const Slicer §ion) |
Do the actual get of the data. More... | |
virtual Bool | doGetMaskSlice (Array< Bool > &buffer, const Slicer §ion) |
Do the actual get of the mask data. More... | |
virtual void | doPutSlice (const Array< T > &sourceBuffer, const IPosition &where, const IPosition &stride) |
An expression is not writable so this functions throws an exception. More... | |
virtual void | copyDataTo (Lattice< T > &to) const |
Copy the data from this lattice to the given lattice. More... | |
virtual void | handleMathTo (Lattice< T > &to, int oper) const |
Handle the Math operators (+=, -=, *=, /=). More... | |
void | handleMathTo (Lattice< Bool > &, int) const |
Public Member Functions inherited from casacore::MaskedLattice< T > | |
MaskedLattice () | |
Default constructor. More... | |
MaskedLattice (const MaskedLattice< T > &) | |
Copy constructor. More... | |
virtual | ~MaskedLattice () |
a virtual destructor is needed so that it will use the actual destructor in the derived class More... | |
virtual Lattice< T > * | clone () const |
Make a copy of the derived object (reference semantics). More... | |
virtual Bool | hasPixelMask () const |
Does the lattice have a pixelmask? The default implementation returns False. More... | |
virtual const Lattice< Bool > & | pixelMask () const |
Get access to the pixelmask. More... | |
virtual Lattice< Bool > & | pixelMask () |
const LatticeRegion & | region () const |
Get the region used. More... | |
Bool | getMask (COWPtr< Array< Bool > > &buffer, Bool removeDegenerateAxes=False) const |
Get the mask or a slice from the mask. More... | |
Bool | getMaskSlice (COWPtr< Array< Bool > > &buffer, const Slicer §ion, Bool removeDegenerateAxes=False) const |
Bool | getMaskSlice (COWPtr< Array< Bool > > &buffer, const IPosition &start, const IPosition &shape, Bool removeDegenerateAxes=False) const |
Bool | getMaskSlice (COWPtr< Array< Bool > > &buffer, const IPosition &start, const IPosition &shape, const IPosition &stride, Bool removeDegenerateAxes=False) const |
Bool | getMask (Array< Bool > &buffer, Bool removeDegenerateAxes=False) |
Bool | getMaskSlice (Array< Bool > &buffer, const Slicer §ion, Bool removeDegenerateAxes=False) |
Bool | getMaskSlice (Array< Bool > &buffer, const IPosition &start, const IPosition &shape, Bool removeDegenerateAxes=False) |
Bool | getMaskSlice (Array< Bool > &buffer, const IPosition &start, const IPosition &shape, const IPosition &stride, Bool removeDegenerateAxes=False) |
Array< Bool > | getMask (Bool removeDegenerateAxes=False) const |
Array< Bool > | getMaskSlice (const Slicer §ion, Bool removeDegenerateAxes=False) const |
Array< Bool > | getMaskSlice (const IPosition &start, const IPosition &shape, Bool removeDegenerateAxes=False) const |
Array< Bool > | getMaskSlice (const IPosition &start, const IPosition &shape, const IPosition &stride, Bool removeDegenerateAxes=False) const |
Public Member Functions inherited from casacore::Lattice< T > | |
virtual | ~Lattice () |
a virtual destructor is needed so that it will use the actual destructor in the derived class More... | |
virtual DataType | dataType () const |
Get the data type of the lattice. More... | |
T | operator() (const IPosition &where) const |
Return the value of the single element located at the argument IPosition. More... | |
virtual T | getAt (const IPosition &where) const |
virtual void | putAt (const T &value, const IPosition &where) |
Put the value of a single element. More... | |
Bool | get (COWPtr< Array< T > > &buffer, Bool removeDegenerateAxes=False) const |
Functions which extract an Array of values from a Lattice. More... | |
Bool | getSlice (COWPtr< Array< T > > &buffer, const Slicer §ion, Bool removeDegenerateAxes=False) const |
Bool | getSlice (COWPtr< Array< T > > &buffer, const IPosition &start, const IPosition &shape, Bool removeDegenerateAxes=False) const |
Bool | getSlice (COWPtr< Array< T > > &buffer, const IPosition &start, const IPosition &shape, const IPosition &stride, Bool removeDegenerateAxes=False) const |
Bool | get (Array< T > &buffer, Bool removeDegenerateAxes=False) |
Bool | getSlice (Array< T > &buffer, const Slicer §ion, Bool removeDegenerateAxes=False) |
Bool | getSlice (Array< T > &buffer, const IPosition &start, const IPosition &shape, Bool removeDegenerateAxes=False) |
Bool | getSlice (Array< T > &buffer, const IPosition &start, const IPosition &shape, const IPosition &stride, Bool removeDegenerateAxes=False) |
Array< T > | get (Bool removeDegenerateAxes=False) const |
Array< T > | getSlice (const Slicer §ion, Bool removeDegenerateAxes=False) const |
Array< T > | getSlice (const IPosition &start, const IPosition &shape, Bool removeDegenerateAxes=False) const |
Array< T > | getSlice (const IPosition &start, const IPosition &shape, const IPosition &stride, Bool removeDegenerateAxes=False) const |
void | putSlice (const Array< T > &sourceBuffer, const IPosition &where, const IPosition &stride) |
A function which places an Array of values within this instance of the Lattice at the location specified by the IPosition "where", incrementing by "stride". More... | |
void | putSlice (const Array< T > &sourceBuffer, const IPosition &where) |
void | put (const Array< T > &sourceBuffer) |
virtual void | set (const T &value) |
Set all elements in the Lattice to the given value. More... | |
virtual void | apply (T(*function)(T)) |
Replace every element, x, of the Lattice with the result of f(x). More... | |
virtual void | apply (T(*function)(const T &)) |
virtual void | apply (const Functional< T, T > &function) |
void | operator+= (const Lattice< T > &other) |
Add, subtract, multiple, or divide by another Lattice. More... | |
void | operator-= (const Lattice< T > &other) |
void | operator*= (const Lattice< T > &other) |
void | operator/= (const Lattice< T > &other) |
virtual void | copyData (const Lattice< T > &from) |
Copy the data from the given lattice to this one. More... | |
virtual uInt | advisedMaxPixels () const |
This function returns the advised maximum number of pixels to include in the cursor of an iterator. More... | |
virtual LatticeIterInterface< T > * | makeIter (const LatticeNavigator &navigator, Bool useRef) const |
These functions are used by the LatticeIterator class to generate an iterator of the correct type for a specified Lattice. More... | |
Public Member Functions inherited from casacore::LatticeBase | |
virtual | ~LatticeBase () |
A virtual destructor is needed so that it will use the actual destructor in the derived class. More... | |
virtual String | imageType () const |
Get the image type (returns name of derived class). More... | |
virtual Bool | isPersistent () const |
Is the lattice persistent and can it be loaded by other processes as well? That is the case for a PagedArray or PagedImage and for an ImageExpr which does not use transient lattices or regions. More... | |
virtual Bool | isPaged () const |
Is the lattice paged to disk? The default implementation returns False. More... | |
virtual Bool | canReferenceArray () const |
Can the lattice data be referenced as an array section? That is the case for an ArrayLattice or a Temp/SubLattice using it. More... | |
virtual void | save (const String &fileName) const |
Save the image in an AipsIO file with the given name. More... | |
virtual void | flush () |
Flush the data (but do not unlock). More... | |
virtual void | tempClose () |
Temporarily close the lattice. More... | |
virtual void | reopen () |
Explicitly reopen the temporarily closed lattice. More... | |
virtual String | name (Bool stripPath=False) const |
Return the name of the current Lattice object. More... | |
virtual uInt | ndim () const |
Return the number of axes in this Lattice. More... | |
virtual size_t | nelements () const |
Return the total number of elements in this Lattice. More... | |
size_t | size () const |
Bool | conform (const LatticeBase &other) const |
Return a value of "True" if this instance of Lattice and 'other' have the same shape, otherwise returns a value of "False". More... | |
IPosition | niceCursorShape (uInt maxPixels) const |
Returns a recommended cursor shape for iterating through all the pixels in the Lattice. More... | |
IPosition | niceCursorShape () const |
virtual Bool | ok () const |
Check class internals - used for debugging. More... | |
virtual uInt | maximumCacheSize () const |
Maximum cache size - not necessarily all used. More... | |
virtual void | setMaximumCacheSize (uInt howManyPixels) |
Set the maximum (allowed) cache size as indicated. More... | |
virtual void | setCacheSizeInTiles (uInt howManyTiles) |
Set the actual cache size for this Array to be big enough for the indicated number of tiles. More... | |
virtual void | setCacheSizeFromPath (const IPosition &sliceShape, const IPosition &windowStart, const IPosition &windowLength, const IPosition &axisPath) |
Set the cache size as to "fit" the indicated path. More... | |
virtual void | clearCache () |
Clears and frees up the caches, but the maximum allowed cache size is unchanged from when setCacheSize was called. More... | |
virtual void | showCacheStatistics (ostream &os) const |
Report on cache success. More... | |
Private Member Functions | |
void | init (const LatticeExprNode &expr) |
Initialize the object from the expression. More... | |
Private Attributes | |
LatticeExprNode | expr_p |
IPosition | shape_p |
LELArray< T > * | lastChunkPtr_p |
Slicer | lastSlicer_p |
Additional Inherited Members | |
Protected Member Functions inherited from casacore::MaskedLattice< T > | |
MaskedLattice< T > & | operator= (const MaskedLattice< T > &) |
Assignment can only be used by derived classes. More... | |
Protected Member Functions inherited from casacore::Lattice< T > | |
Lattice () | |
Define default constructor to satisfy compiler. More... | |
virtual void | handleMath (const Lattice< T > &from, int oper) |
Handle the Math operators (+=, -=, *=, /=). More... | |
Lattice (const Lattice< T > &) | |
Copy constructor and assignment can only be used by derived classes. More... | |
Lattice< T > & | operator= (const Lattice< T > &) |
void | handleMathTo (Lattice< Bool > &, int) const |
Protected Member Functions inherited from casacore::LatticeBase | |
LatticeBase () | |
Define default constructor to be used by derived classes. More... | |
LatticeBase (const LatticeBase &) | |
Copy constructor and assignment can only be used by derived classes. More... | |
LatticeBase & | operator= (const LatticeBase &) |
void | throwBoolMath () const |
Throw an exception for arithmetic on a Bool Lattice. More... | |
Class to allow C++ expressions involving lattices
Public interface
The name is derived from the fact that this class provides an expression interface to the user which s/he may use to write C++ expressions involving Lattices.
This class provides an interface which allows the C++ programmer to enter expressions such as "sin(a)+b" where "a" and "b" are Lattices.
This class is termed an envelope class, and inside it are the letter classes which do the real work. In reality, the letter classes are actually accessed via a bridging class called LatticeExprNode, which exists to handle type conversions. The letter classes iterate through the Lattices and evaluate the expression for each chunk of the iteration (usually a tile shape).
It is in the LatticeExprNode class that all the available expression operations are defined, so you should look there to see what functionality is available.
A description of the implementation details of these classes can be found in Note 216
In this example, the values of the pixels in Lattice f1 are set to the values resulting from the expression "2*f2 + f2" I.e. the expression is evaluated for each pixel in the Lattices
Note that : 1) the Lattice::copyData function is expecting a Lattice argument.
2) LatticeExpr inherits from Lattice and therefore a LatticeExpr object is a valid argument object type 3) The expression in the copyData call is automatically converted to a LatticeExprNode by the constructors and operators in LatticeExprNode 4) The LatticeExprNode object so created is automatically converted to a LatticeExpr by casting functions in LatticeExprNode.
In this rather silly example, we fill Lattice "f1" with the result of the expression. The expression shows the use of constants, unary operations, binary operations, 1D and 2D functions. It also shows how mixed types can be handled. The output Lattice is a Float, whereas mixed into the expression are subexpressions involving Float, Double, Complex and Bool Lattices.
The Lattice expression classes enable the C++ programmer much simpler handling of mathematical expressions involving lattices. In addition, these classes provide the infrastructure on top of which we can build an image calculator for Glish users
Definition at line 142 of file LatticeExpr.h.
casacore::LatticeExpr< T >::LatticeExpr | ( | ) |
Default constructor.
casacore::LatticeExpr< T >::LatticeExpr | ( | const LatticeExprNode & | expr | ) |
Constructor from an arbitrary LatticeExprNode expression object.
An exception is thrown if the expression data type cannot be converted to the template data type. The shape argument is mandatory if the expression has no shape. If the expression has a shape and if shape is given, it is checked if they are equal.
casacore::LatticeExpr< T >::LatticeExpr | ( | const LatticeExprNode & | expr, |
const IPosition & | latticeShape | ||
) |
casacore::LatticeExpr< T >::LatticeExpr | ( | const LatticeExpr< T > & | other | ) |
Copy constructor (reference semantics)
|
virtual |
Destructor, does nothing.
|
virtual |
Make a copy of the derived object (reference semantics).
Implements casacore::MaskedLattice< T >.
|
virtual |
Copy the data from this lattice to the given lattice.
Reimplemented from casacore::Lattice< T >.
|
virtual |
Do the actual get of the mask data.
The return value is always False, thus the buffer does not reference another array.
Reimplemented from casacore::MaskedLattice< T >.
|
virtual |
Do the actual get of the data.
The return value is always False, thus the buffer does not reference another array.
Implements casacore::Lattice< T >.
|
virtual |
|
virtual |
An expression is not writable so this functions throws an exception.
Implements casacore::Lattice< T >.
|
virtual |
Get the region used (always returns 0).
Implements casacore::MaskedLattice< T >.
|
inline |
Definition at line 245 of file LatticeExpr.h.
|
virtual |
Handle the Math operators (+=, -=, *=, /=).
They work similarly to copyData(To). However, they are not defined for Bool types, thus specialized below.
Reimplemented from casacore::Lattice< T >.
|
virtual |
Reimplemented from casacore::LatticeBase.
|
private |
Initialize the object from the expression.
|
virtual |
Has the object really a mask?
Reimplemented from casacore::MaskedLattice< T >.
|
virtual |
Returns False, as the LatticeExpr lattice is not writable.
Reimplemented from casacore::LatticeBase.
|
virtual |
Returns the coordinates of the lattice expression.
Reimplemented from casacore::LatticeBase.
|
virtual |
Handle locking of the LatticeExpr which is delegated to all of its parts.
hasLock() is True if all parts of the expression return True.
It is strongly recommended to use class LatticeLocker to handle lattice locking. It also contains a more detailed explanation of the locking process.
Reimplemented from casacore::LatticeBase.
LatticeExpr<T>& casacore::LatticeExpr< T >::operator= | ( | const LatticeExpr< T > & | other | ) |
Assignment (reference semantics)
|
virtual |
Resynchronize the Lattice object with the lattice file.
This function is only useful if no read-locking is used, ie. if the table lock option is UserNoReadLocking or AutoNoReadLocking. In that cases the table system does not acquire a read-lock, thus does not synchronize itself automatically.
By default the function does not do anything at all.
Reimplemented from casacore::LatticeBase.
|
virtual |
Returns the shape of the Lattice including all degenerate axes (i.e.
axes with a length of one)
Implements casacore::LatticeBase.
|
virtual |
Reimplemented from casacore::LatticeBase.
|
private |
Definition at line 237 of file LatticeExpr.h.
|
private |
Definition at line 239 of file LatticeExpr.h.
|
private |
Definition at line 240 of file LatticeExpr.h.
|
private |
Definition at line 238 of file LatticeExpr.h.