00001 //# LELFunction.h: LELFunction.h 00002 //# Copyright (C) 1997,1998,1999,2000,2001 00003 //# Associated Universities, Inc. Washington DC, USA. 00004 //# 00005 //# This library is free software; you can redistribute it and/or modify it 00006 //# under the terms of the GNU Library General Public License as published by 00007 //# the Free Software Foundation; either version 2 of the License, or (at your 00008 //# option) any later version. 00009 //# 00010 //# This library is distributed in the hope that it will be useful, but WITHOUT 00011 //# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 00012 //# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public 00013 //# License for more details. 00014 //# 00015 //# You should have received a copy of the GNU Library General Public License 00016 //# along with this library; if not, write to the Free Software Foundation, 00017 //# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA. 00018 //# 00019 //# Correspondence concerning AIPS++ should be addressed as follows: 00020 //# Internet email: aips2-request@nrao.edu. 00021 //# Postal address: AIPS++ Project Office 00022 //# National Radio Astronomy Observatory 00023 //# 520 Edgemont Road 00024 //# Charlottesville, VA 22903-2475 USA 00025 //# 00026 //# $Id$ 00027 00028 #ifndef LATTICES_LELFUNCTION_H 00029 #define LATTICES_LELFUNCTION_H 00030 00031 00032 //# Includes 00033 #include <casacore/casa/aips.h> 00034 #include <casacore/lattices/LEL/LELInterface.h> 00035 #include <casacore/lattices/LEL/LatticeExprNode.h> 00036 #include <casacore/lattices/LEL/LELFunctionEnums.h> 00037 #include <casacore/casa/Containers/Block.h> 00038 00039 namespace casacore { //# NAMESPACE CASACORE - BEGIN 00040 00041 //# Forward Declarations 00042 00043 00044 // <summary> 00045 // This LEL class handles numerical (real and complex) 1-argument functions 00046 // </summary> 00047 // 00048 // <use visibility=local> 00049 // 00050 // <reviewed reviewer="" date="yyyy/mm/dd" tests="" demos=""> 00051 // </reviewed> 00052 // 00053 // <prerequisite> 00054 // <li> <linkto class="Lattice"> Lattice</linkto> 00055 // <li> <linkto class="LatticeExpr"> LatticeExpr</linkto> 00056 // <li> <linkto class="LatticeExprNode"> LatticeExprNode</linkto> 00057 // <li> <linkto class="LELInterface"> LELInterface</linkto> 00058 // <li> <linkto class="LELFunctionEnums"> LELFunctionEnums</linkto> 00059 // </prerequisite> 00060 // 00061 // <etymology> 00062 // This derived LEL letter class handles numerical (real and complex) 00063 // 1-argument functions 00064 // </etymology> 00065 // 00066 // <synopsis> 00067 // This LEL letter class is derived from LELInterface. It is used to construct 00068 // LEL objects that apply numerical 1-argument functions to Lattice 00069 // expressions. They operate on numerical (Float,Double,Complex,DComplex) 00070 // Lattice expressions and return the same type. The available C++ functions are 00071 // <src>sin,sinh,cos,cosh,exp,log,log10,sqrt,min,max,mean,sum</src> with 00072 // equivalents in the enum of SIN,SINH,COS,COSH,EXP,LOG,LOG10,SQRT,MIN1D,MAX1D, 00073 // MEAN1D, and SUM. 00074 // 00075 // A description of the implementation details of the LEL classes can 00076 // be found in 00077 // <a href="../notes/216.html">Note 216</a> 00078 // </synopsis> 00079 // 00080 // <example> 00081 // Examples are not very useful as the user would never use 00082 // these classes directly. Look in LatticeExprNode.cc to see 00083 // how it invokes these classes. Examples of how the user 00084 // would indirectly use this class (through the envelope) are: 00085 // <srcblock> 00086 // IPosition shape(2,5,10); 00087 // ArrayLattice<Complex> x(shape); x.set(1.0); 00088 // ArrayLattice<Complex> y(shape); 00089 // y.copyData(sin(x)); // y = sin(x) 00090 // y.copyData(min(x)); // y = min(x) 00091 // </srcblock> 00092 // Note that the min function returns a scalar, and the output 00093 // Lattice is filled with that one value. 00094 // </example> 00095 // 00096 // <motivation> 00097 // Numerical functions are a basic mathematical expression. 00098 // </motivation> 00099 // 00100 // <todo asof="1998/01/21"> 00101 // </todo> 00102 00103 00104 template <class T> class LELFunction1D : public LELInterface<T> 00105 { 00106 //# Make members of parent class known. 00107 protected: 00108 using LELInterface<T>::setAttr; 00109 00110 public: 00111 // Constructor takes operation and expression to be operated upon 00112 LELFunction1D(const LELFunctionEnums::Function function, 00113 const CountedPtr<LELInterface<T> >& expr); 00114 00115 // Destructor 00116 ~LELFunction1D(); 00117 00118 // Recursively evaluate the expression 00119 virtual void eval (LELArray<T>& result, 00120 const Slicer& section) const; 00121 00122 // Recursively evaluate the scalar expression. 00123 virtual LELScalar<T> getScalar() const; 00124 00125 // Do further preparations (e.g. optimization) on the expression. 00126 virtual Bool prepareScalarExpr(); 00127 00128 // Get class name 00129 virtual String className() const; 00130 00131 // Handle locking/syncing of a lattice in a lattice expression. 00132 // <group> 00133 virtual Bool lock (FileLocker::LockType, uInt nattempts); 00134 virtual void unlock(); 00135 virtual Bool hasLock (FileLocker::LockType) const; 00136 virtual void resync(); 00137 // </group> 00138 00139 private: 00140 LELFunctionEnums::Function function_p; 00141 CountedPtr<LELInterface<T> > pExpr_p; 00142 }; 00143 00144 00145 00146 00147 // <summary> 00148 // This LEL class handles numerical (real only) 1-argument functions 00149 // </summary> 00150 // 00151 // <use visibility=local> 00152 // 00153 // <reviewed reviewer="" date="yyyy/mm/dd" tests="" demos=""> 00154 // </reviewed> 00155 // 00156 // <prerequisite> 00157 // <li> <linkto class="Lattice"> Lattice</linkto> 00158 // <li> <linkto class="LatticeExpr"> LatticeExpr</linkto> 00159 // <li> <linkto class="LatticeExprNode"> LatticeExprNode</linkto> 00160 // <li> <linkto class="LELInterface"> LELInterface</linkto> 00161 // <li> <linkto class="LELFunctionEnums"> LELFunctionEnums</linkto> 00162 // </prerequisite> 00163 // 00164 // <etymology> 00165 // This derived LEL letter class handles numerical (real only) 00166 // 1-argument functions 00167 // </etymology> 00168 // 00169 // <synopsis> 00170 // This LEL letter class is derived from LELInterface. It is used to construct 00171 // LEL objects that apply numerical (real only) 1-argument functions to 00172 // Lattice expressions. They operate on Float and Double numerical Lattice 00173 // expressions and return the same type. The available C++ functions are 00174 // <src>asin,acos,tan,tanh,ceil,floor</src> with 00175 // equivalents in the enum of ASIN, ACOS, TAN, TANH, CEIL, and FLOOR. 00176 // 00177 // A description of the implementation details of the LEL classes can 00178 // be found in 00179 // <a href="../notes/216.html">Note 216</a> 00180 // </synopsis> 00181 // 00182 // <example> 00183 // Examples are not very useful as the user would never use 00184 // these classes directly. Look in LatticeExprNode.cc to see 00185 // how it invokes these classes. Examples of how the user 00186 // would indirectly use this class (through the envelope) are: 00187 // <srcblock> 00188 // IPosition shape(2,5,10); 00189 // ArrayLattice<Float> x(shape); x.set(0.05); 00190 // ArrayLattice<Float> y(shape); 00191 // y.copyData(asin(x)); // y = asin(x) 00192 // y.copyData(tan(x)); // y = tan(x) 00193 // </srcblock> 00194 // Note that the min function returns a scalar, and the output 00195 // Lattice is filled with that one value. 00196 // </example> 00197 // 00198 // <motivation> 00199 // Numerical functions are a basic mathematical expression. 00200 // </motivation> 00201 // 00202 // <todo asof="1998/01/21"> 00203 // </todo> 00204 00205 00206 template <class T> class LELFunctionReal1D : public LELInterface<T> 00207 { 00208 //# Make members of parent class known. 00209 protected: 00210 using LELInterface<T>::setAttr; 00211 00212 public: 00213 // Constructor takes operation and expression to be operated upon 00214 LELFunctionReal1D(const LELFunctionEnums::Function function, 00215 const CountedPtr<LELInterface<T> >& expr); 00216 00217 // Destructor 00218 ~LELFunctionReal1D(); 00219 00220 // Recursively evaluate the expression 00221 virtual void eval (LELArray<T>& result, 00222 const Slicer& section) const; 00223 00224 // Recursively evaluate the scalar expression 00225 virtual LELScalar<T> getScalar() const; 00226 00227 // Do further preparations (e.g. optimization) on the expression. 00228 virtual Bool prepareScalarExpr(); 00229 00230 // Get class name 00231 virtual String className() const; 00232 00233 // Handle locking/syncing of a lattice in a lattice expression. 00234 // <group> 00235 virtual Bool lock (FileLocker::LockType, uInt nattempts); 00236 virtual void unlock(); 00237 virtual Bool hasLock (FileLocker::LockType) const; 00238 virtual void resync(); 00239 // </group> 00240 00241 00242 private: 00243 LELFunctionEnums::Function function_p; 00244 CountedPtr<LELInterface<T> > pExpr_p; 00245 }; 00246 00247 00248 00249 00250 // <summary> 00251 // This LEL class handles functions with a variable number of arguments. 00252 // </summary> 00253 // 00254 // <use visibility=local> 00255 // 00256 // <reviewed reviewer="" date="yyyy/mm/dd" tests="" demos=""> 00257 // </reviewed> 00258 // 00259 // <prerequisite> 00260 // <li> <linkto class="Lattice"> Lattice</linkto> 00261 // <li> <linkto class="LatticeExpr"> LatticeExpr</linkto> 00262 // <li> <linkto class="LatticeExprNode"> LatticeExprNode</linkto> 00263 // <li> <linkto class="LELInterface"> LELInterface</linkto> 00264 // <li> <linkto class="LELFunctionEnums"> LELFunctionEnums</linkto> 00265 // </prerequisite> 00266 // 00267 // <etymology> 00268 // This derived LEL letter class handles numerical functions (arbitrary 00269 // number of arguments) which return any data type 00270 // </etymology> 00271 // 00272 // <synopsis> 00273 // This templated LEL letter class is derived from LELInterface. 00274 // It is used to construct LEL objects that apply functions of 00275 // arbitrary number of arguments to Lattice expressions. 00276 // They operate lattices with any type and return the same type. 00277 // The available C++ function is 00278 // <src>iif</src> with equivalents in the enum of IIF. 00279 // 00280 // A description of the implementation details of the LEL classes can 00281 // be found in 00282 // <a href="../notes/216.html">Note 216</a> 00283 // </synopsis> 00284 // 00285 // <example> 00286 // Examples are not very useful as the user would never use 00287 // these classes directly. Look in LatticeExprNode.cc to see 00288 // how it invokes these classes. Examples of how the user 00289 // would indirectly use this class (through the envelope) are: 00290 // <srcblock> 00291 // IPosition shape(2,5,10); 00292 // ArrayLattice<Complex> w(shape); w.set(Complex(2.0,3.0)); 00293 // ArrayLattice<Float> x(shape); x.set(0.05); 00294 // ArrayLattice<Float> y(shape); y.set(2.0); 00295 // ArrayLattice<Float> z(shape); y.set(2.0); 00296 // 00297 // z.copyData(iif(x==0, y, x)); 00298 // 00299 // </srcblock> 00300 // Copy x to z, but where x==0, take the correpsonding element from y. 00301 // </example>b 00302 // 00303 // <motivation> 00304 // An "if-then-else" like construction is very useful. 00305 // </motivation> 00306 // 00307 // <todo asof="1998/01/21"> 00308 // </todo> 00309 00310 00311 template<class T> class LELFunctionND : public LELInterface<T> 00312 { 00313 //# Make members of parent class known. 00314 protected: 00315 using LELInterface<T>::setAttr; 00316 00317 public: 00318 // Constructor takes operation and expressions to be operated upon 00319 LELFunctionND(const LELFunctionEnums::Function function, 00320 const Block<LatticeExprNode>& expr); 00321 00322 // Destructor 00323 ~LELFunctionND(); 00324 00325 // Recursively evaluate the expression 00326 virtual void eval (LELArray<T>& result, 00327 const Slicer& section) const; 00328 00329 // Recursively evaluate the scalar expression 00330 virtual LELScalar<T> getScalar() const; 00331 00332 // Do further preparations (e.g. optimization) on the expression. 00333 virtual Bool prepareScalarExpr(); 00334 00335 // Get class name 00336 virtual String className() const; 00337 00338 // Handle locking/syncing of a lattice in a lattice expression. 00339 // <group> 00340 virtual Bool lock (FileLocker::LockType, uInt nattempts); 00341 virtual void unlock(); 00342 virtual Bool hasLock (FileLocker::LockType) const; 00343 virtual void resync(); 00344 // </group> 00345 00346 private: 00347 LELFunctionEnums::Function function_p; 00348 Block<LatticeExprNode> arg_p; 00349 }; 00350 00351 00352 00353 00354 // <summary> 00355 // This LEL class handles numerical functions whose return type is a Float 00356 // </summary> 00357 // 00358 // <use visibility=local> 00359 // 00360 // <reviewed reviewer="" date="yyyy/mm/dd" tests="" demos=""> 00361 // </reviewed> 00362 // 00363 // <prerequisite> 00364 // <li> <linkto class="Lattice"> Lattice</linkto> 00365 // <li> <linkto class="LatticeExpr"> LatticeExpr</linkto> 00366 // <li> <linkto class="LatticeExprNode"> LatticeExprNode</linkto> 00367 // <li> <linkto class="LELInterface"> LELInterface</linkto> 00368 // <li> <linkto class="LELFunctionEnums"> LELFunctionEnums</linkto> 00369 // </prerequisite> 00370 // 00371 // <etymology> 00372 // This derived LEL letter class handles numerical functions (arbitrary 00373 // number of arguments) which return a Float 00374 // </etymology> 00375 // 00376 // <synopsis> 00377 // This LEL letter class is derived from LELInterface. It is used to construct 00378 // LEL objects that apply numerical functions of arbitrary number of 00379 // arguments (but only 1 or 2 arguments currently implemented) to Lattice 00380 // expressions. They operate on Float or Complex Lattices 00381 // and return a Float. The available C++ functions are 00382 // <src>min,max,pow,atan2,fmod,abs,arg,real,imag</src> with 00383 // equivalents in the enum of MIN,MAX,POW,ATAN2,FMOD,ABS,ARG,REAL, and IMAG. 00384 // 00385 // A description of the implementation details of the LEL classes can 00386 // be found in 00387 // <a href="../notes/216.html">Note 216</a> 00388 // </synopsis> 00389 // 00390 // <example> 00391 // Examples are not very useful as the user would never use 00392 // these classes directly. Look in LatticeExprNode.cc to see 00393 // how it invokes these classes. Examples of how the user 00394 // would indirectly use this class (through the envelope) are: 00395 // <srcblock> 00396 // IPosition shape(2,5,10); 00397 // ArrayLattice<Complex> w(shape); w.set(Complex(2.0,3.0)); 00398 // ArrayLattice<Float> x(shape); x.set(0.05); 00399 // ArrayLattice<Float> y(shape); y.set(2.0); 00400 // ArrayLattice<Float> z(shape); y.set(2.0); 00401 // 00402 // z.copyData(min(x,y)); // z = min(x,y) 00403 // z.copyData(imag(w)); // z = imag(w) 00404 // 00405 // </srcblock> 00406 // Note that this min function takes two arguments and returns 00407 // the minimum of the two, pixel by pixel (i.e. it does not 00408 // return one scalar from the whole Lattice) 00409 // </example>b 00410 // 00411 // <motivation> 00412 // Numerical functions are a basic mathematical expression. 00413 // </motivation> 00414 // 00415 // <todo asof="1998/01/21"> 00416 // </todo> 00417 00418 00419 class LELFunctionFloat : public LELInterface<Float> 00420 { 00421 public: 00422 00423 // Constructor takes operation and left and right expressions 00424 // to be operated upon 00425 LELFunctionFloat(const LELFunctionEnums::Function function, 00426 const Block<LatticeExprNode>& expr); 00427 00428 // Destructor 00429 ~LELFunctionFloat(); 00430 00431 // Recursively evaluate the expression 00432 virtual void eval (LELArray<Float>& result, 00433 const Slicer& section) const; 00434 00435 // Recursively evaluate the scalar expression 00436 virtual LELScalar<Float> getScalar() const; 00437 00438 // Do further preparations (e.g. optimization) on the expression. 00439 virtual Bool prepareScalarExpr(); 00440 00441 // Get class name 00442 virtual String className() const; 00443 00444 // Handle locking/syncing of a lattice in a lattice expression. 00445 // <group> 00446 virtual Bool lock (FileLocker::LockType, uInt nattempts); 00447 virtual void unlock(); 00448 virtual Bool hasLock (FileLocker::LockType) const; 00449 virtual void resync(); 00450 // </group> 00451 00452 private: 00453 LELFunctionEnums::Function function_p; 00454 Block<LatticeExprNode> arg_p; 00455 }; 00456 00457 00458 00459 // <summary> 00460 // This LEL class handles numerical functions whose return type is a Double 00461 // </summary> 00462 // 00463 // <use visibility=local> 00464 // 00465 // <reviewed reviewer="" date="yyyy/mm/dd" tests="" demos=""> 00466 // </reviewed> 00467 // 00468 // <prerequisite> 00469 // <li> <linkto class="Lattice"> Lattice</linkto> 00470 // <li> <linkto class="LatticeExpr"> LatticeExpr</linkto> 00471 // <li> <linkto class="LatticeExprNode"> LatticeExprNode</linkto> 00472 // <li> <linkto class="LELInterface"> LELInterface</linkto> 00473 // <li> <linkto class="LELFunctionEnums"> LELFunctionEnums</linkto> 00474 // </prerequisite> 00475 // 00476 // <etymology> 00477 // This derived LEL letter class handles numerical functions (arbitrary 00478 // number of arguments) which return a Double 00479 // </etymology> 00480 // 00481 // <synopsis> 00482 // This LEL letter class is derived from LELInterface. It is used to construct 00483 // LEL objects that apply numerical functions of arbitrary number of 00484 // arguments (but only 1 or 2 arguments currently implemented) to Lattice 00485 // expressions. They operate on Double or DComplex Lattices 00486 // and return a Double. The available C++ functions are 00487 // <src>min,max,pow,atan2,fmod,abs,arg,real,imag</src> with 00488 // equivalents in the enum of MIN,MAX,POW,ATAN2,FMOD,ABS,ARG,REAL, and IMAG. 00489 // 00490 // There are also two other functions for which the input Lattice expression 00491 // type must be a Bool. These are <src>ntrue,nfalse</src> with 00492 // equivalents in the enum of NTRUE and NFALSE. 00493 // 00494 // There is a further function for which the input Lattice expression 00495 // type can be anything. This is <src>nelements</src> with 00496 // equivalent in the enum of NELEM. 00497 // 00498 // A description of the implementation details of the LEL classes can 00499 // be found in 00500 // <a href="../notes/216.html">Note 216</a> 00501 // </synopsis> 00502 // 00503 // <example> 00504 // Examples are not very useful as the user would never use 00505 // these classes directly. Look in LatticeExprNode.cc to see 00506 // how it invokes these classes. Examples of how the user 00507 // would indirectly use this class (through the envelope) are: 00508 // <srcblock> 00509 // IPosition shape(2,5,10); 00510 // ArrayLattice<Bool> v(shape); v.set(True); 00511 // ArrayLattice<DComplex> w(shape); w.set(DComplex(2.0,3.0)); 00512 // ArrayLattice<Double> x(shape); x.set(0.05); 00513 // ArrayLattice<Double> y(shape); y.set(2.0); 00514 // ArrayLattice<Double> z(shape); y.set(2.0); 00515 // 00516 // z.copyData(min(x,y)); // z = min(x,y) 00517 // z.copyData(imag(w)); // z = imag(w) 00518 // z.copyData(nelements(v)); // z = nelements(v) 00519 // z.copyData(ntrue(v)); // z = ntrue(v) 00520 // </srcblock> 00521 // </example> 00522 // 00523 // <motivation> 00524 // Numerical functions are a basic mathematical expression. 00525 // </motivation> 00526 // 00527 // <todo asof="1998/01/21"> 00528 // </todo> 00529 00530 00531 class LELFunctionDouble : public LELInterface<Double> 00532 { 00533 public: 00534 00535 // Constructor takes operation and left and right expressions 00536 // to be operated upon 00537 LELFunctionDouble(const LELFunctionEnums::Function function, 00538 const Block<LatticeExprNode>& expr); 00539 00540 // Destructor 00541 ~LELFunctionDouble(); 00542 00543 // Recursively evaluate the expression 00544 virtual void eval (LELArray<Double>& result, 00545 const Slicer& section) const; 00546 00547 // Recursively evaluate the scalar expression 00548 virtual LELScalar<Double> getScalar() const; 00549 00550 // Do further preparations (e.g. optimization) on the expression. 00551 virtual Bool prepareScalarExpr(); 00552 00553 // Get class name 00554 virtual String className() const; 00555 00556 // Handle locking/syncing of a lattice in a lattice expression. 00557 // <group> 00558 virtual Bool lock (FileLocker::LockType, uInt nattempts); 00559 virtual void unlock(); 00560 virtual Bool hasLock (FileLocker::LockType) const; 00561 virtual void resync(); 00562 // </group> 00563 00564 private: 00565 // Count number of masked elements in a LatticeExprNode. 00566 // <group> 00567 uInt nMaskedElements (const LatticeExprNode&) const; 00568 uInt nMaskedOn (const Array<Bool>& mask) const; 00569 // </group> 00570 00571 LELFunctionEnums::Function function_p; 00572 Block<LatticeExprNode> arg_p; 00573 }; 00574 00575 00576 00577 // <summary> 00578 // This LEL class handles complex numerical functions 00579 // </summary> 00580 // 00581 // <use visibility=local> 00582 // 00583 // <reviewed reviewer="" date="yyyy/mm/dd" tests="" demos=""> 00584 // </reviewed> 00585 // 00586 // <prerequisite> 00587 // <li> <linkto class="Lattice"> Lattice</linkto> 00588 // <li> <linkto class="LatticeExpr"> LatticeExpr</linkto> 00589 // <li> <linkto class="LatticeExprNode"> LatticeExprNode</linkto> 00590 // <li> <linkto class="LELInterface"> LELInterface</linkto> 00591 // <li> <linkto class="LELFunctionEnums"> LELFunctionEnums</linkto> 00592 // </prerequisite> 00593 // 00594 // <etymology> 00595 // This derived LEL letter class handles complex numerical functions (arbitrary 00596 // number of arguments) 00597 // </etymology> 00598 // 00599 // <synopsis> 00600 // This LEL letter class is derived from LELInterface. It is used to construct 00601 // LEL objects that apply complex numerical functions of arbitrary number of 00602 // arguments (but only 1 or 2 arguments currently implemented) to Lattice 00603 // expressions. They operate on Complex Lattice expressions only 00604 // and return a Complex. The available C++ functions are 00605 // <src>pow,conj</src> with equivalents in the enum of POW and CONJ. 00606 // 00607 // A description of the implementation details of the LEL classes can 00608 // be found in 00609 // <a href="../notes/216.html">Note 216</a> 00610 // </synopsis> 00611 // 00612 // <example> 00613 // Examples are not very useful as the user would never use 00614 // these classes directly. Look in LatticeExprNode.cc to see 00615 // how it invokes these classes. Examples of how the user 00616 // would indirectly use this class (through the envelope) are: 00617 // <srcblock> 00618 // IPosition shape(2,5,10); 00619 // ArrayLattice<Complex> x(shape); x.set(Complex(2.0,3.0)); 00620 // ArrayLattice<Complex> y(shape); 00621 // y.copyData(conj(x)); // y = conj(x) 00622 // </srcblock> 00623 // </example> 00624 // 00625 // <motivation> 00626 // Numerical functions are a basic mathematical expression. 00627 // </motivation> 00628 // 00629 // <todo asof="1998/01/21"> 00630 // </todo> 00631 00632 00633 class LELFunctionComplex : public LELInterface<Complex> 00634 { 00635 public: 00636 00637 // Constructor takes operation and left and right expressions 00638 // to be operated upon 00639 LELFunctionComplex(const LELFunctionEnums::Function function, 00640 const Block<LatticeExprNode>& expr); 00641 00642 // Destructor 00643 ~LELFunctionComplex(); 00644 00645 // Recursively evaluate the expression 00646 virtual void eval (LELArray<Complex>& result, 00647 const Slicer& section) const; 00648 00649 // Recursively evaluate the scalar expression 00650 virtual LELScalar<Complex> getScalar() const; 00651 00652 // Do further preparations (e.g. optimization) on the expression. 00653 virtual Bool prepareScalarExpr(); 00654 00655 // Get class name 00656 virtual String className() const; 00657 00658 // Handle locking/syncing of a lattice in a lattice expression. 00659 // <group> 00660 virtual Bool lock (FileLocker::LockType, uInt nattempts); 00661 virtual void unlock(); 00662 virtual Bool hasLock (FileLocker::LockType) const; 00663 virtual void resync(); 00664 // </group> 00665 00666 private: 00667 LELFunctionEnums::Function function_p; 00668 Block<LatticeExprNode> arg_p; 00669 }; 00670 00671 00672 00673 00674 00675 // <summary> 00676 // This LEL class handles double complex numerical functions 00677 // </summary> 00678 // 00679 // <use visibility=local> 00680 // 00681 // <reviewed reviewer="" date="yyyy/mm/dd" tests="" demos=""> 00682 // </reviewed> 00683 // 00684 // <prerequisite> 00685 // <li> <linkto class="Lattice"> Lattice</linkto> 00686 // <li> <linkto class="LatticeExpr"> LatticeExpr</linkto> 00687 // <li> <linkto class="LatticeExprNode"> LatticeExprNode</linkto> 00688 // <li> <linkto class="LELInterface"> LELInterface</linkto> 00689 // <li> <linkto class="LELFunctionEnums"> LELFunctionEnums</linkto> 00690 // </prerequisite> 00691 // 00692 // <etymology> 00693 // This derived LEL letter class handles double complex numerical functions (arbitrary 00694 // number of arguments) 00695 // </etymology> 00696 // 00697 // <synopsis> 00698 // This LEL letter class is derived from LELInterface. It is used to construct 00699 // LEL objects that apply double complex numerical functions of arbitrary number of 00700 // arguments (but only 1 or 2 arguments currently implemented) to Lattice 00701 // expressions. They operate on DComplex Lattice expressions only 00702 // and return a DComplex. The available C++ functions are 00703 // <src>pow,conj</src> with equivalents in the enum of POW and CONJ. 00704 // 00705 // A description of the implementation details of the LEL classes can 00706 // be found in 00707 // <a href="../notes/216.html">Note 216</a> 00708 // </synopsis> 00709 // 00710 // <example> 00711 // Examples are not very useful as the user would never use 00712 // these classes directly. Look in LatticeExprNode.cc to see 00713 // how it invokes these classes. Examples of how the user 00714 // would indirectly use this class (through the envelope) are: 00715 // <srcblock> 00716 // IPosition shape(2,5,10); 00717 // ArrayLattice<DComplex> x(shape); x.set(DComplex(2.0,3.0)); 00718 // ArrayLattice<DComplex> y(shape); 00719 // y.copyData(conj(x)); // y = conj(x) 00720 // </srcblock> 00721 // </example> 00722 // 00723 // <motivation> 00724 // Numerical functions are a basic mathematical expression. 00725 // </motivation> 00726 // 00727 // <todo asof="1998/01/21"> 00728 // </todo> 00729 00730 class LELFunctionDComplex : public LELInterface<DComplex> 00731 { 00732 public: 00733 00734 // Constructor takes operation and left and right expressions 00735 // to be operated upon 00736 LELFunctionDComplex(const LELFunctionEnums::Function function, 00737 const Block<LatticeExprNode>& expr); 00738 00739 // Destructor 00740 ~LELFunctionDComplex(); 00741 00742 // Recursively evaluate the expression 00743 virtual void eval (LELArray<DComplex>& result, 00744 const Slicer& section) const; 00745 00746 // Recursively evaluate the scalar expression 00747 virtual LELScalar<DComplex> getScalar() const; 00748 00749 // Do further preparations (e.g. optimization) on the expression. 00750 virtual Bool prepareScalarExpr(); 00751 00752 // Get class name 00753 virtual String className() const; 00754 00755 // Handle locking/syncing of a lattice in a lattice expression. 00756 // <group> 00757 virtual Bool lock (FileLocker::LockType, uInt nattempts); 00758 virtual void unlock(); 00759 virtual Bool hasLock (FileLocker::LockType) const; 00760 virtual void resync(); 00761 // </group> 00762 00763 private: 00764 LELFunctionEnums::Function function_p; 00765 Block<LatticeExprNode> arg_p; 00766 }; 00767 00768 00769 // <summary> 00770 // This LEL class handles logical functions 00771 // </summary> 00772 // 00773 // <use visibility=local> 00774 // 00775 // <reviewed reviewer="" date="yyyy/mm/dd" tests="" demos=""> 00776 // </reviewed> 00777 // 00778 // <prerequisite> 00779 // <li> <linkto class="Lattice"> Lattice</linkto> 00780 // <li> <linkto class="LatticeExpr"> LatticeExpr</linkto> 00781 // <li> <linkto class="LatticeExprNode"> LatticeExprNode</linkto> 00782 // <li> <linkto class="LELInterface"> LELInterface</linkto> 00783 // <li> <linkto class="LELFunctionEnums"> LELFunctionEnums</linkto> 00784 // </prerequisite> 00785 // 00786 // <etymology> 00787 // This derived LEL letter class handles logical functions (arbitrary 00788 // number of arguments) 00789 // </etymology> 00790 // 00791 // <synopsis> 00792 // This LEL letter class is derived from LELInterface. It is used to construct 00793 // LEL objects that apply logical functions of arbitrary number of 00794 // arguments (but only 1 or 2 arguments currently implemented) to Lattice 00795 // expressions. They operate on Bool Lattice expressions only 00796 // and return a Bool. The available C++ functions are 00797 // <src>all,any</src> with equivalents in the enum of ALL and ANY. 00798 // 00799 // A description of the implementation details of the LEL classes can 00800 // be found in 00801 // <a href="../notes/216.html">Note 216</a> 00802 // </synopsis> 00803 // 00804 // <example> 00805 // Examples are not very useful as the user would never use 00806 // these classes directly. Look in LatticeExprNode.cc to see 00807 // how it invokes these classes. Examples of how the user 00808 // would indirectly use this class (through the envelope) are: 00809 // <srcblock> 00810 // IPosition shape(2,5,10); 00811 // ArrayLattice<Bool> x(shape); x.set(True); 00812 // ArrayLattice<Bool> y(shape); 00813 // y.copyData(any(x)); // y = any(x) 00814 // </srcblock> 00815 // The result of the any function (were any of the values True) is 00816 // a Bool scalar. So the output Lattice is filled with that one value. 00817 // </example> 00818 // 00819 // <motivation> 00820 // Logical functions are a basic mathematical expression. 00821 // </motivation> 00822 // 00823 // <todo asof="1998/01/21"> 00824 // </todo> 00825 00826 class LELFunctionBool : public LELInterface<Bool> 00827 { 00828 public: 00829 00830 // Constructor takes operation and left and right expressions 00831 // to be operated upon 00832 LELFunctionBool(const LELFunctionEnums::Function function, 00833 const Block<LatticeExprNode>& expr); 00834 00835 // Destructor 00836 ~LELFunctionBool(); 00837 00838 // Recursively evaluate the expression 00839 virtual void eval (LELArray<Bool>& result, 00840 const Slicer& section) const; 00841 00842 // Recursively evaluate the scalar expression 00843 virtual LELScalar<Bool> getScalar() const; 00844 00845 // Do further preparations (e.g. optimization) on the expression. 00846 virtual Bool prepareScalarExpr(); 00847 00848 // Get class name 00849 virtual String className() const; 00850 00851 // Handle locking/syncing of a lattice in a lattice expression. 00852 // <group> 00853 virtual Bool lock (FileLocker::LockType, uInt nattempts); 00854 virtual void unlock(); 00855 virtual Bool hasLock (FileLocker::LockType) const; 00856 virtual void resync(); 00857 // </group> 00858 00859 private: 00860 LELFunctionEnums::Function function_p; 00861 Block<LatticeExprNode> arg_p; 00862 }; 00863 00864 00865 00866 00867 } //# NAMESPACE CASACORE - END 00868 00869 #ifndef CASACORE_NO_AUTO_TEMPLATES 00870 #include <casacore/lattices/LEL/LELFunction.tcc> 00871 #endif //# CASACORE_NO_AUTO_TEMPLATES 00872 #endif