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