casa
$Rev:20696$
|
00001 //# ExprNode.h: Handle class for a table column expression tree 00002 //# Copyright (C) 1994,1995,1996,1997,1998,2000,2001,2003 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: ExprNode.h 21156 2011-12-12 07:57:36Z gervandiepen $ 00027 00028 #ifndef TABLES_EXPRNODE_H 00029 #define TABLES_EXPRNODE_H 00030 00031 //# Includes 00032 #include <casa/aips.h> 00033 #include <tables/Tables/ExprNodeRep.h> 00034 #include <tables/Tables/ExprRange.h> 00035 #include <tables/Tables/ExprFuncNode.h> 00036 #include <tables/Tables/ExprConeNode.h> 00037 #include <tables/Tables/TaQLStyle.h> 00038 #include <casa/Utilities/DataType.h> 00039 #include <casa/BasicSL/Complex.h> 00040 00041 namespace casa { //# NAMESPACE CASA - BEGIN 00042 00043 //# Forward Declarations 00044 class Table; 00045 class String; 00046 class Regex; 00047 class StringDistance; 00048 class Unit; 00049 class TableRecord; 00050 class TableExprNodeSet; 00051 template<class T> class Block; 00052 template<class T> class Array; 00053 class TableExprNode; 00054 00055 00056 // Define all global functions operating on a TableExprNode. 00057 // <group name=GlobalTableExprNode> 00058 00059 //# Define the operations we allow. 00060 //# Note that the arguments are defined as const. This is necessary 00061 //# because the compiler generates temporaries when converting a constant 00062 //# to a TableExprNode using the constructors. Temporaries has to be const. 00063 //# However, we have to delete created nodes, so lnode_p and rnode_p 00064 //# cannot be const. The const arguments are casted to a non-const in 00065 //# the function fill which calls the non-const function simplify. 00066 00067 // Arithmetic operators for numeric TableExprNode's. 00068 // <group> 00069 // + is also defined for strings (means concatenation). 00070 TableExprNode operator+ (const TableExprNode& left, 00071 const TableExprNode& right); 00072 TableExprNode operator- (const TableExprNode& left, 00073 const TableExprNode& right); 00074 TableExprNode operator* (const TableExprNode& left, 00075 const TableExprNode& right); 00076 TableExprNode operator/ (const TableExprNode& left, 00077 const TableExprNode& right); 00078 TableExprNode operator% (const TableExprNode& left, 00079 const TableExprNode& right); 00080 TableExprNode operator& (const TableExprNode& left, 00081 const TableExprNode& right); 00082 TableExprNode operator| (const TableExprNode& left, 00083 const TableExprNode& right); 00084 TableExprNode operator^ (const TableExprNode& left, 00085 const TableExprNode& right); 00086 // </group> 00087 00088 // Comparison operators. 00089 // <group> 00090 TableExprNode operator== (const TableExprNode& left, 00091 const TableExprNode& right); 00092 TableExprNode operator!= (const TableExprNode& left, 00093 const TableExprNode& right); 00094 // Not defined for Bool. 00095 // <group> 00096 TableExprNode operator>= (const TableExprNode& left, 00097 const TableExprNode& right); 00098 TableExprNode operator> (const TableExprNode& left, 00099 const TableExprNode& right); 00100 TableExprNode operator<= (const TableExprNode& left, 00101 const TableExprNode& right); 00102 TableExprNode operator< (const TableExprNode& left, 00103 const TableExprNode& right); 00104 // </group> 00105 // </group> 00106 00107 // Logical operators to combine boolean TableExprNode's. 00108 // A null TableExprNode object is ignored, so it is possible to 00109 // build up a full expression gradually. 00110 // <group> 00111 TableExprNode operator&& (const TableExprNode& left, 00112 const TableExprNode& right); 00113 TableExprNode operator|| (const TableExprNode& left, 00114 const TableExprNode& right); 00115 // </group> 00116 00117 // Functions to return whether a value is "relatively" near another. 00118 // Returns <src> tol > abs(val2 - val1)/max(abs(val1),(val2))</src>. 00119 // If tol <= 0, returns val1 == val2. If either val is 0.0, takes 00120 // care of area around the minimum number that can be represented. 00121 // <br>The nearAbs functions return whether a value is "absolutely" near 00122 // another. Returns <src> tol > abs(val2 - val1)</src>. 00123 // Default tolerance is 1.0e-13. 00124 // They operate on scalars and arrays. 00125 // <group> 00126 TableExprNode near (const TableExprNode& left, 00127 const TableExprNode& right); 00128 TableExprNode near (const TableExprNode& left, 00129 const TableExprNode& right, 00130 const TableExprNode& tolerance); 00131 TableExprNode nearAbs (const TableExprNode& left, 00132 const TableExprNode& right); 00133 TableExprNode nearAbs (const TableExprNode& left, 00134 const TableExprNode& right, 00135 const TableExprNode& tolerance); 00136 // </group> 00137 00138 // Angular distance between positions. 00139 // Both arguments have to be arrays. If both arrays contain 2 values 00140 // (ra and dec), the result is a scalar. 00141 // Otherwise the arrays have to contain a multiple of 2 values and the 00142 // result is a 2-dim array giving the distance of each position in the 00143 // first array to each position in the second array. 00144 TableExprNode angdist (const TableExprNode& pos1, 00145 const TableExprNode& pos2); 00146 00147 // Cone search; test if the position of a source is inside a cone. 00148 // <br>Argument <src>sourcePos</src> must be a double array 00149 // containing two values (ra and dec of source) in radians. 00150 // <br>Argument <src>cones</src> must be a double array 00151 // specifying the position of the cone centers and radii in radians. 00152 // So the array must contain three values (ra,dec,radius) 00153 // or a multiple of it. 00154 // <group> 00155 // The result is a bool array telling for each cone if it contains the 00156 // source. If there is only one cone, the result is a scalar. 00157 TableExprNode cones (const TableExprNode& sourcePos, 00158 const TableExprNode& cones); 00159 // The result is always a Bool scalar telling if any cone contains 00160 // the source. 00161 TableExprNode anyCone (const TableExprNode& sourcePos, 00162 const TableExprNode& cones); 00163 // The sourcePos can contain multiple sources. 00164 // The result is a double array giving the index of the first 00165 // cone containing the corresponding source. 00166 // If there is one source, the result is a double scalar. 00167 TableExprNode findCone (const TableExprNode& sourcePos, 00168 const TableExprNode& cones); 00169 // </group> 00170 00171 // Cone search as above. 00172 // However, the cone positions and radii are specified separately 00173 // and (virtually) a larger array containing every combination of 00174 // position/radius is formed. 00175 // <group> 00176 TableExprNode cones (const TableExprNode& sourcePos, 00177 const TableExprNode& conePos, 00178 const TableExprNode& radii); 00179 TableExprNode anyCone (const TableExprNode& sourcePos, 00180 const TableExprNode& conePos, 00181 const TableExprNode& radii); 00182 TableExprNode findCone (const TableExprNode& sourcePos, 00183 const TableExprNode& conePos, 00184 const TableExprNode& radii); 00185 // </group> 00186 00187 // Transcendental functions that can be applied to essentially all numeric 00188 // nodes containing scalars or arrays. 00189 // <group> 00190 TableExprNode sin (const TableExprNode& node); 00191 TableExprNode sinh (const TableExprNode& node); 00192 TableExprNode cos (const TableExprNode& node); 00193 TableExprNode cosh (const TableExprNode& node); 00194 TableExprNode exp (const TableExprNode& node); 00195 TableExprNode log (const TableExprNode& node); 00196 TableExprNode log10 (const TableExprNode& node); 00197 TableExprNode pow (const TableExprNode& x, const TableExprNode& exp); 00198 TableExprNode square (const TableExprNode& node); 00199 TableExprNode cube (const TableExprNode& node); 00200 TableExprNode sqrt (const TableExprNode& node); 00201 TableExprNode norm (const TableExprNode& node); 00202 // </group> 00203 00204 // Transcendental functions applied to to nodes containing scalars or 00205 // arrays with double values. 00206 // They are invalid for Complex nodes. 00207 // <group> 00208 TableExprNode asin (const TableExprNode& node); 00209 TableExprNode acos (const TableExprNode& node); 00210 TableExprNode atan (const TableExprNode& node); 00211 TableExprNode atan2 (const TableExprNode& y, 00212 const TableExprNode& x); 00213 TableExprNode tan (const TableExprNode& node); 00214 TableExprNode tanh (const TableExprNode& node); 00215 TableExprNode sign (const TableExprNode& node); 00216 TableExprNode round (const TableExprNode& node); 00217 TableExprNode ceil (const TableExprNode& node); 00218 TableExprNode abs (const TableExprNode& node); 00219 TableExprNode floor (const TableExprNode& node); 00220 TableExprNode fmod (const TableExprNode& x, 00221 const TableExprNode& y); 00222 // </group> 00223 00224 // String functions on scalars or arrays. 00225 // <group> 00226 TableExprNode strlength (const TableExprNode& node); 00227 TableExprNode upcase (const TableExprNode& node); 00228 TableExprNode downcase (const TableExprNode& node); 00229 TableExprNode trim (const TableExprNode& node); 00230 TableExprNode ltrim (const TableExprNode& node); 00231 TableExprNode rtrim (const TableExprNode& node); 00232 TableExprNode substr (const TableExprNode& str, 00233 const TableExprNode& pos); 00234 TableExprNode substr (const TableExprNode& str, 00235 const TableExprNode& pos, 00236 const TableExprNode& npos); 00237 TableExprNode replace (const TableExprNode& str, 00238 const TableExprNode& patt); 00239 TableExprNode replace (const TableExprNode& str, 00240 const TableExprNode& patt, 00241 const TableExprNode& repl); 00242 // </group> 00243 00244 // Functions for regular expression matching and 00245 // pattern matching. Defined for scalars and arrays. 00246 // <br><src>pattern</src> is for a file name like pattern. 00247 // <br><src>sqlpattern</src> is for an SQL like pattern. 00248 // <group> 00249 TableExprNode regex (const TableExprNode& node); 00250 TableExprNode pattern (const TableExprNode& node); 00251 TableExprNode sqlpattern (const TableExprNode& node); 00252 // </group> 00253 00254 // Functions for date-values. Defined for scalars and arrays. 00255 //# Note, ctod is called ctodt, because Mac OS-X defines a macro 00256 //# ctod in param.h 00257 // <group> 00258 TableExprNode datetime (const TableExprNode& node); 00259 TableExprNode mjdtodate (const TableExprNode& node); 00260 TableExprNode mjd (const TableExprNode& node); 00261 TableExprNode date (const TableExprNode& node); 00262 TableExprNode year (const TableExprNode& node); 00263 TableExprNode month (const TableExprNode& node); 00264 TableExprNode day (const TableExprNode& node); 00265 TableExprNode cmonth (const TableExprNode& node); 00266 TableExprNode weekday (const TableExprNode& node); 00267 TableExprNode cdow (const TableExprNode& node); 00268 TableExprNode ctodt (const TableExprNode& node); 00269 TableExprNode cdate (const TableExprNode& node); 00270 TableExprNode ctime (const TableExprNode& node); 00271 TableExprNode week (const TableExprNode& node); 00272 TableExprNode time (const TableExprNode& node); 00273 // </group> 00274 00275 // Functions for angle-values. Defined for scalars and arrays. 00276 // dhms converts pairs of values to hms and dms and only works for arrays. 00277 // <group> 00278 TableExprNode hms (const TableExprNode& node); 00279 TableExprNode dms (const TableExprNode& node); 00280 TableExprNode hdms (const TableExprNode& node); 00281 // </group> 00282 00283 // Function to test if a scalar or array is NaN (not-a-number). 00284 // It results in a Bool scalar or array. 00285 TableExprNode isNaN (const TableExprNode& node); 00286 00287 // Function to test if a scalar or array is finite. 00288 // It results in a Bool scalar or array. 00289 TableExprNode isFinite (const TableExprNode& node); 00290 00291 // Minimum or maximum of 2 nodes. 00292 // Makes sense for numeric and String values. For Complex values 00293 // the norm is compared. 00294 // One or both arguments can be scalar or array. 00295 // <group> 00296 TableExprNode min (const TableExprNode& a, const TableExprNode& b); 00297 TableExprNode max (const TableExprNode& a, const TableExprNode& b); 00298 // </group> 00299 00300 // The complex conjugate of a complex node. 00301 // Defined for scalars and arrays. 00302 TableExprNode conj (const TableExprNode& node); 00303 00304 // The real part of a complex node. 00305 // Defined for scalars and arrays. 00306 TableExprNode real (const TableExprNode& node); 00307 00308 // The imaginary part of a complex node. 00309 // Defined for scalars and arrays. 00310 TableExprNode imag (const TableExprNode& node); 00311 00312 // Convert double to int (using floor). 00313 TableExprNode integer (const TableExprNode& node); 00314 00315 // The amplitude (i.e. sqrt(re*re + im*im)) of a complex node. 00316 // This is a synonym for function abs. 00317 // Defined for scalars and arrays. 00318 TableExprNode amplitude (const TableExprNode& node); 00319 00320 // The phase (i.e. atan2(im, re)) of a complex node. 00321 // This is a synonym for function arg. 00322 // Defined for scalars and arrays. 00323 TableExprNode phase (const TableExprNode& node); 00324 00325 // The arg (i.e. atan2(im, re)) of a complex node. 00326 // Defined for scalars and arrays. 00327 TableExprNode arg (const TableExprNode& node); 00328 00329 // Form a complex number from two Doubles. 00330 // One or both arguments can be scalar or array. 00331 TableExprNode formComplex (const TableExprNode& real, 00332 const TableExprNode& imag); 00333 00334 // Functions operating on a Double or Complex scalar or array resulting in 00335 // a scalar with the same data type. 00336 // <group> 00337 TableExprNode sum (const TableExprNode& array); 00338 TableExprNode product (const TableExprNode& array); 00339 TableExprNode sumSquare (const TableExprNode& array); 00340 // </group> 00341 00342 // Functions operating on a Double scalar or array resulting in 00343 // a Double scalar. 00344 // <group> 00345 TableExprNode min (const TableExprNode& array); 00346 TableExprNode max (const TableExprNode& array); 00347 TableExprNode mean (const TableExprNode& array); 00348 TableExprNode variance (const TableExprNode& array); 00349 TableExprNode stddev (const TableExprNode& array); 00350 TableExprNode avdev (const TableExprNode& array); 00351 TableExprNode rms (const TableExprNode& array); 00352 TableExprNode median (const TableExprNode& array); 00353 TableExprNode fractile (const TableExprNode& array, 00354 const TableExprNode& fraction); 00355 // </group> 00356 00357 // <group> 00358 TableExprNode any (const TableExprNode& array); 00359 TableExprNode all (const TableExprNode& array); 00360 TableExprNode ntrue (const TableExprNode& array); 00361 TableExprNode nfalse (const TableExprNode& array); 00362 // </group> 00363 00364 // The partial version of the functions above. 00365 // They are applied to the array subsets defined by the axes in the set 00366 // using the partialXXX functions in ArrayMath. 00367 // The axes must be 0-relative. 00368 // <group> 00369 TableExprNode sums (const TableExprNode& array, 00370 const TableExprNodeSet& collapseAxes); 00371 TableExprNode products (const TableExprNode& array, 00372 const TableExprNodeSet& collapseAxes); 00373 TableExprNode sumSquares (const TableExprNode& array, 00374 const TableExprNodeSet& collapseAxes); 00375 TableExprNode mins (const TableExprNode& array, 00376 const TableExprNodeSet& collapseAxes); 00377 TableExprNode maxs (const TableExprNode& array, 00378 const TableExprNodeSet& collapseAxes); 00379 TableExprNode means (const TableExprNode& array, 00380 const TableExprNodeSet& collapseAxes); 00381 TableExprNode variances (const TableExprNode& array, 00382 const TableExprNodeSet& collapseAxes); 00383 TableExprNode stddevs (const TableExprNode& array, 00384 const TableExprNodeSet& collapseAxes); 00385 TableExprNode avdevs (const TableExprNode& array, 00386 const TableExprNodeSet& collapseAxes); 00387 TableExprNode rmss (const TableExprNode& array, 00388 const TableExprNodeSet& collapseAxes); 00389 TableExprNode medians (const TableExprNode& array, 00390 const TableExprNodeSet& collapseAxes); 00391 TableExprNode fractiles (const TableExprNode& array, 00392 const TableExprNode& fraction, 00393 const TableExprNodeSet& collapseAxes); 00394 TableExprNode anys (const TableExprNode& array, 00395 const TableExprNodeSet& collapseAxes); 00396 TableExprNode alls (const TableExprNode& array, 00397 const TableExprNodeSet& collapseAxes); 00398 TableExprNode ntrues (const TableExprNode& array, 00399 const TableExprNodeSet& collapseAxes); 00400 TableExprNode nfalses (const TableExprNode& array, 00401 const TableExprNodeSet& collapseAxes); 00402 // </group> 00403 00404 // Functions operating for each element on a box around that element. 00405 // The elements at the edges (where no full box can be made) are set to 0. 00406 // <group> 00407 TableExprNode runningMin (const TableExprNode& array, 00408 const TableExprNodeSet& halfBoxWidth); 00409 TableExprNode runningMax (const TableExprNode& array, 00410 const TableExprNodeSet& halfBoxWidth); 00411 TableExprNode runningMean (const TableExprNode& array, 00412 const TableExprNodeSet& halfBoxWidth); 00413 TableExprNode runningVariance (const TableExprNode& array, 00414 const TableExprNodeSet& halfBoxWidth); 00415 TableExprNode runningStddev (const TableExprNode& array, 00416 const TableExprNodeSet& halfBoxWidth); 00417 TableExprNode runningAvdev (const TableExprNode& array, 00418 const TableExprNodeSet& halfBoxWidth); 00419 TableExprNode runningRms (const TableExprNode& array, 00420 const TableExprNodeSet& halfBoxWidth); 00421 TableExprNode runningMedian (const TableExprNode& array, 00422 const TableExprNodeSet& halfBoxWidth); 00423 TableExprNode runningAny (const TableExprNode& array, 00424 const TableExprNodeSet& halfBoxWidth); 00425 TableExprNode runningAll (const TableExprNode& array, 00426 const TableExprNodeSet& halfBoxWidth); 00427 // </group> 00428 00429 // Create an array of the given shape and fill it with the values. 00430 // The <src>values</src> array is rewound as needed. 00431 TableExprNode array (const TableExprNode& values, 00432 const TableExprNodeSet& shape); 00433 00434 // Function operating on a field resulting in a bool scalar. 00435 // It can be used to test if a column has an array in the current row. 00436 // It can also be used to test if a record contains a field. 00437 TableExprNode isdefined (const TableExprNode& array); 00438 00439 // Functions operating on any scalar or array resulting in a Double scalar. 00440 // A scalar has 1 element and dimensionality 0. 00441 // <group> 00442 TableExprNode nelements (const TableExprNode& array); 00443 TableExprNode ndim (const TableExprNode& array); 00444 // </group> 00445 00446 // Function operating on any scalar or array resulting in a Double array 00447 // containing the shape. A scalar has shape [1]. 00448 TableExprNode shape (const TableExprNode& array); 00449 00450 // Function resembling the ternary <src>?:</src> construct in C++. 00451 // The argument "condition" has to be a Bool value. 00452 // If an element in "condition" is True, the corresponding element from 00453 // "arg1" is taken, otherwise it is taken from "arg2". 00454 // The arguments can be scalars or array or any combination. 00455 TableExprNode iif (const TableExprNode& condition, 00456 const TableExprNode& arg1, 00457 const TableExprNode& arg2); 00458 // </group> 00459 00460 00461 00462 // <summary> 00463 // Handle class for a table column expression tree 00464 // </summary> 00465 00466 // <use visibility=export> 00467 00468 // <reviewed reviewer="UNKNOWN" date="before2004/08/25" tests=""> 00469 // </reviewed> 00470 00471 // <prerequisite> 00472 //# Classes you should understand before using this one. 00473 // <li> <linkto class=Table>Table</linkto> 00474 // <li> Note 199 describing 00475 // <a href="../notes/199.html"> 00476 // TaQL</a> 00477 // </prerequisite> 00478 00479 // <etymology> 00480 // TableExprNode represents a node in the tree reflecting a 00481 // table select expression. 00482 // </etymology> 00483 00484 // <synopsis> 00485 // TableExprNode is the class to store a table select expression, 00486 // which allows to select rows from the table. The selected rows form 00487 // a table which is a view of the original table. 00488 // <p> 00489 // TableExprNode is a handle class for the counted referenced class 00490 // TableExprNodeRep. 00491 // Classes (like TableExprNodePlusXX) derived from TableExprNodeRep 00492 // hold the individual 00493 // nodes in the expression, i.e. the operators and operands. The nodes 00494 // form a binary tree reflecting the expression. 00495 // E.g. the expression 2*COLUMN results in the node TableExprNodeTimes 00496 // with its children TableExprNodeConst and TableExprNodeColumn. 00497 // Constant subexpressions (like 2*3) are evaluated immediately and 00498 // only the result is stored as a node. 00499 // <p> 00500 // There are a few TableExprNode constructors taking a constant scalar or array. 00501 // In this way constant value are automatically converted to the 00502 // appropriate TableExprNodeConst object. 00503 // <p> 00504 // The derived classes also reflect the data type of the node. 00505 // Data types Bool, Double, DComplex and String are used. 00506 // Char, uChar, Short, uShort, Int, uInt and float are converted 00507 // to Double and Complex to DComplex. 00508 // Binary operators +, -, *, /, %, &, }, ^, ==, >=, >, <, <= and != are 00509 // recognized. Also &&, ||, parentheses and unary +, -, ~ and ! are recognized. 00510 // For strings the binary operator + can also be used. 00511 // The operators have the normal C++ precedence. 00512 // Furthermore functions (like sin, max, ceil) can be used in an expression. 00513 // <br>Operator() can be used to take a slice from an array. 00514 // <p> 00515 // The Table function col has to be used to create a TableExprNode 00516 // object for a column in the table. The Table 00517 // <linkto file="Table.h#keycol">operator()</linkto> can be used 00518 // the do the actual selection from the top TableExprNode object. 00519 // </synopsis> 00520 00521 // <example> 00522 // <srcblock> 00523 // // Select from table X all rows where column RA<5 and where column 00524 // // SWITCH is true. 00525 // Table table("X"); 00526 // Table subtable = table(table.col("RA") < 5 && table.col("SWITCH")); 00527 // 00528 // // Select from that result all rows where the concatenation of 00529 // // the strings in columns STR1 and STR2 is equal to the string 00530 // // in keyword STRKEY. 00531 // Table subsub = subtable(subtable.col("STR1") + subtable.col("STR2") 00532 // == subtable.key("STRKEY")); 00533 // </srcblock> 00534 // </example> 00535 00536 // <motivation> 00537 // Having TableExprNode as a handle class makes it possible to 00538 // handle temporary objects created by the compiler in a smooth way. 00539 // TableExprNode and its derivations allow to store an expression 00540 // before actually evaluating it. This also allows the classes to 00541 // be used by the table expression parser defined in TableParse and 00542 // TableGram. 00543 // 00544 // For each operator a special derived class is implemented. 00545 // Another approach could have been to store the operator as 00546 // a flag and switch on that. However, that causes extra overhead 00547 // and the C++ virtual function mechanism is the designed for 00548 // these purposes. 00549 // </motivation> 00550 00551 // <todo asof="$DATE:$"> 00552 //# A List of bugs, limitations, extensions or planned refinements. 00553 // <li> add operations on arrays 00554 // <li> add selection by comparing with a set of values 00555 // </todo> 00556 00557 00558 class TableExprNode 00559 { 00560 //# Define the next 2 classes as friends to get the node_p. 00561 friend class TableExprNodeRep; 00562 friend class TableParse; 00563 00564 //# Define the operations we allow. 00565 //# Note that the arguments are defined as const. This is necessary 00566 //# because the compiler generates temporaries when converting a constant 00567 //# to a TableExprNode using the constructors. Temporaries has to be const. 00568 //# However, we have to delete created nodes, so lnode_p and rnode_p 00569 //# cannot be const. The const arguments are casted to a non-const in 00570 //# the function fill which calls the non-const function simplify. 00571 00572 // Define all global functions as friends. 00573 // <group> 00574 friend TableExprNode operator+ (const TableExprNode& left, 00575 const TableExprNode& right); 00576 friend TableExprNode operator- (const TableExprNode& left, 00577 const TableExprNode& right); 00578 friend TableExprNode operator* (const TableExprNode& left, 00579 const TableExprNode& right); 00580 friend TableExprNode operator/ (const TableExprNode& left, 00581 const TableExprNode& right); 00582 friend TableExprNode operator% (const TableExprNode& left, 00583 const TableExprNode& right); 00584 friend TableExprNode operator& (const TableExprNode& left, 00585 const TableExprNode& right); 00586 friend TableExprNode operator| (const TableExprNode& left, 00587 const TableExprNode& right); 00588 friend TableExprNode operator^ (const TableExprNode& left, 00589 const TableExprNode& right); 00590 friend TableExprNode operator== (const TableExprNode& left, 00591 const TableExprNode& right); 00592 friend TableExprNode operator!= (const TableExprNode& left, 00593 const TableExprNode& right); 00594 friend TableExprNode operator>= (const TableExprNode& left, 00595 const TableExprNode& right); 00596 friend TableExprNode operator> (const TableExprNode& left, 00597 const TableExprNode& right); 00598 friend TableExprNode operator<= (const TableExprNode& left, 00599 const TableExprNode& right); 00600 friend TableExprNode operator< (const TableExprNode& left, 00601 const TableExprNode& right); 00602 friend TableExprNode operator&& (const TableExprNode& left, 00603 const TableExprNode& right); 00604 friend TableExprNode operator|| (const TableExprNode& left, 00605 const TableExprNode& right); 00606 friend TableExprNode near (const TableExprNode& left, 00607 const TableExprNode& right); 00608 friend TableExprNode near (const TableExprNode& left, 00609 const TableExprNode& right, 00610 const TableExprNode& tolerance); 00611 friend TableExprNode nearAbs (const TableExprNode& left, 00612 const TableExprNode& right); 00613 friend TableExprNode nearAbs (const TableExprNode& left, 00614 const TableExprNode& right, 00615 const TableExprNode& tolerance); 00616 friend TableExprNode angdist (const TableExprNode& pos1, 00617 const TableExprNode& pos2); 00618 friend TableExprNode cones (const TableExprNode& sourcePos, 00619 const TableExprNode& cones); 00620 friend TableExprNode anyCone (const TableExprNode& sourcePos, 00621 const TableExprNode& cones); 00622 friend TableExprNode findCone (const TableExprNode& sourcePos, 00623 const TableExprNode& cones); 00624 friend TableExprNode cones (const TableExprNode& sourcePos, 00625 const TableExprNode& conePos, 00626 const TableExprNode& radii); 00627 friend TableExprNode anyCone (const TableExprNode& sourcePos, 00628 const TableExprNode& conePos, 00629 const TableExprNode& radii); 00630 friend TableExprNode findCone (const TableExprNode& sourcePos, 00631 const TableExprNode& conePos, 00632 const TableExprNode& radii); 00633 friend TableExprNode sin (const TableExprNode& node); 00634 friend TableExprNode sinh (const TableExprNode& node); 00635 friend TableExprNode cos (const TableExprNode& node); 00636 friend TableExprNode cosh (const TableExprNode& node); 00637 friend TableExprNode exp (const TableExprNode& node); 00638 friend TableExprNode log (const TableExprNode& node); 00639 friend TableExprNode log10 (const TableExprNode& node); 00640 friend TableExprNode pow (const TableExprNode& x, 00641 const TableExprNode& exp); 00642 friend TableExprNode square (const TableExprNode& node); 00643 friend TableExprNode cube (const TableExprNode& node); 00644 friend TableExprNode sqrt (const TableExprNode& node); 00645 friend TableExprNode norm (const TableExprNode& node); 00646 friend TableExprNode asin (const TableExprNode& node); 00647 friend TableExprNode acos (const TableExprNode& node); 00648 friend TableExprNode atan (const TableExprNode& node); 00649 friend TableExprNode atan2 (const TableExprNode& y, 00650 const TableExprNode& x); 00651 friend TableExprNode tan (const TableExprNode& node); 00652 friend TableExprNode tanh (const TableExprNode& node); 00653 friend TableExprNode sign (const TableExprNode& node); 00654 friend TableExprNode round (const TableExprNode& node); 00655 friend TableExprNode ceil (const TableExprNode& node); 00656 friend TableExprNode abs (const TableExprNode& node); 00657 friend TableExprNode floor (const TableExprNode& node); 00658 friend TableExprNode fmod (const TableExprNode& x, 00659 const TableExprNode& y); 00660 friend TableExprNode strlength (const TableExprNode& node); 00661 friend TableExprNode upcase (const TableExprNode& node); 00662 friend TableExprNode downcase (const TableExprNode& node); 00663 friend TableExprNode trim (const TableExprNode& node); 00664 friend TableExprNode ltrim (const TableExprNode& node); 00665 friend TableExprNode rtrim (const TableExprNode& node); 00666 friend TableExprNode substr (const TableExprNode& str, 00667 const TableExprNode& pos); 00668 friend TableExprNode substr (const TableExprNode& str, 00669 const TableExprNode& pos, 00670 const TableExprNode& npos); 00671 friend TableExprNode replace (const TableExprNode& str, 00672 const TableExprNode& patt); 00673 friend TableExprNode replace (const TableExprNode& str, 00674 const TableExprNode& patt, 00675 const TableExprNode& repl); 00676 friend TableExprNode regex (const TableExprNode& node); 00677 friend TableExprNode pattern (const TableExprNode& node); 00678 friend TableExprNode sqlpattern(const TableExprNode& node); 00679 friend TableExprNode datetime (const TableExprNode& node); 00680 friend TableExprNode mjdtodate (const TableExprNode& node); 00681 friend TableExprNode mjd (const TableExprNode& node); 00682 friend TableExprNode date (const TableExprNode& node); 00683 friend TableExprNode year (const TableExprNode& node); 00684 friend TableExprNode month (const TableExprNode& node); 00685 friend TableExprNode day (const TableExprNode& node); 00686 friend TableExprNode cmonth (const TableExprNode& node); 00687 friend TableExprNode weekday (const TableExprNode& node); 00688 friend TableExprNode cdow (const TableExprNode& node); 00689 friend TableExprNode ctodt (const TableExprNode& node); 00690 friend TableExprNode cdate (const TableExprNode& node); 00691 friend TableExprNode ctime (const TableExprNode& node); 00692 friend TableExprNode week (const TableExprNode& node); 00693 friend TableExprNode time (const TableExprNode& node); 00694 friend TableExprNode isNaN (const TableExprNode& node); 00695 friend TableExprNode isFinite (const TableExprNode& node); 00696 friend TableExprNode min (const TableExprNode& a, const TableExprNode& b); 00697 friend TableExprNode max (const TableExprNode& a, const TableExprNode& b); 00698 friend TableExprNode conj (const TableExprNode& node); 00699 friend TableExprNode real (const TableExprNode& node); 00700 friend TableExprNode imag (const TableExprNode& node); 00701 friend TableExprNode amplitude (const TableExprNode& node); 00702 friend TableExprNode phase (const TableExprNode& node); 00703 friend TableExprNode arg (const TableExprNode& node); 00704 friend TableExprNode formComplex (const TableExprNode& real, 00705 const TableExprNode& imag); 00706 friend TableExprNode sum (const TableExprNode& array); 00707 friend TableExprNode product (const TableExprNode& array); 00708 friend TableExprNode sumSquare (const TableExprNode& array); 00709 friend TableExprNode min (const TableExprNode& array); 00710 friend TableExprNode max (const TableExprNode& array); 00711 friend TableExprNode mean (const TableExprNode& array); 00712 friend TableExprNode variance (const TableExprNode& array); 00713 friend TableExprNode stddev (const TableExprNode& array); 00714 friend TableExprNode avdev (const TableExprNode& array); 00715 friend TableExprNode rms (const TableExprNode& array); 00716 friend TableExprNode median (const TableExprNode& array); 00717 friend TableExprNode fractile (const TableExprNode& array, 00718 const TableExprNode& fraction); 00719 friend TableExprNode any (const TableExprNode& array); 00720 friend TableExprNode all (const TableExprNode& array); 00721 friend TableExprNode ntrue (const TableExprNode& array); 00722 friend TableExprNode nfalse (const TableExprNode& array); 00723 friend TableExprNode sums (const TableExprNode& array, 00724 const TableExprNodeSet& collapseAxes); 00725 friend TableExprNode products (const TableExprNode& array, 00726 const TableExprNodeSet& collapseAxes); 00727 friend TableExprNode sumSquares (const TableExprNode& array, 00728 const TableExprNodeSet& collapseAxes); 00729 friend TableExprNode mins (const TableExprNode& array, 00730 const TableExprNodeSet& collapseAxes); 00731 friend TableExprNode maxs (const TableExprNode& array, 00732 const TableExprNodeSet& collapseAxes); 00733 friend TableExprNode means (const TableExprNode& array, 00734 const TableExprNodeSet& collapseAxes); 00735 friend TableExprNode variances (const TableExprNode& array, 00736 const TableExprNodeSet& collapseAxes); 00737 friend TableExprNode stddevs (const TableExprNode& array, 00738 const TableExprNodeSet& collapseAxes); 00739 friend TableExprNode avdevs (const TableExprNode& array, 00740 const TableExprNodeSet& collapseAxes); 00741 friend TableExprNode rmss (const TableExprNode& array, 00742 const TableExprNodeSet& collapseAxes); 00743 friend TableExprNode medians (const TableExprNode& array, 00744 const TableExprNodeSet& collapseAxes); 00745 friend TableExprNode fractiles (const TableExprNode& array, 00746 const TableExprNode& fraction, 00747 const TableExprNodeSet& collapseAxes); 00748 friend TableExprNode anys (const TableExprNode& array, 00749 const TableExprNodeSet& collapseAxes); 00750 friend TableExprNode alls (const TableExprNode& array, 00751 const TableExprNodeSet& collapseAxes); 00752 friend TableExprNode ntrues (const TableExprNode& array, 00753 const TableExprNodeSet& collapseAxes); 00754 friend TableExprNode nfalses (const TableExprNode& array, 00755 const TableExprNodeSet& collapseAxes); 00756 friend TableExprNode runningMin (const TableExprNode& array); 00757 friend TableExprNode runningMax (const TableExprNode& array); 00758 friend TableExprNode runningMean (const TableExprNode& array); 00759 friend TableExprNode runningVariance (const TableExprNode& array); 00760 friend TableExprNode runningStddev (const TableExprNode& array); 00761 friend TableExprNode runningAvdev (const TableExprNode& array); 00762 friend TableExprNode runningRms (const TableExprNode& array); 00763 friend TableExprNode runningMedian (const TableExprNode& array); 00764 friend TableExprNode runningAny (const TableExprNode& array); 00765 friend TableExprNode runningAll (const TableExprNode& array); 00766 friend TableExprNode array (const TableExprNode& values, 00767 const TableExprNodeSet& shape); 00768 friend TableExprNode isdefined (const TableExprNode& array); 00769 friend TableExprNode nelements (const TableExprNode& array); 00770 friend TableExprNode ndim (const TableExprNode& array); 00771 friend TableExprNode shape (const TableExprNode& array); 00772 friend TableExprNode iif (const TableExprNode& condition, 00773 const TableExprNode& arg1, 00774 const TableExprNode& arg2); 00775 // </group> 00776 00777 public: 00778 TableExprNode (); 00779 00780 // Unary operators on numeric TableExprNode's. 00781 // <group> 00782 TableExprNode operator+ () const; 00783 TableExprNode operator- () const; 00784 // </group> 00785 // Unary NOT-operator on boolean TableExprNode's. 00786 TableExprNode operator! () const; 00787 // Unary bitwise negate-operator on integer TableExprNode's. 00788 TableExprNode operator~ () const; 00789 00790 // Slicing in a node containing an array. It is possible to 00791 // address a single pixel or an n-dimensional subarray. 00792 // In case of a single pixel the result is a scalar node. 00793 // Otherwise the result is an array node with the same dimensionality 00794 // as the source. 00795 // <br>Note that there exist TableExprNodeSet constructors to 00796 // convert an <src>IPosition</src> or <src>Slicer</src> object 00797 // automatically to a <src>TableExprNodeSet</src>. 00798 // An <src>IPosition</src> addresses a single element and results in 00799 // a scalar node, while a <src>Slicer</src> can address multiple 00800 // elements and always results in an array node. 00801 TableExprNode operator() (const TableExprNodeSet& indices); 00802 00803 // The IN operator to test if a value is contained in an array or set. 00804 // The array can also be a scalar. 00805 // <group> 00806 TableExprNode in (const TableExprNode& array) const; 00807 TableExprNode in (const TableExprNodeSet& set) const; 00808 // </group> 00809 00810 // Use a unit for the given TableExprNode. 00811 // Note that if a column has a unit, it is automatically set. In that case 00812 // this can be used to convert units. 00813 TableExprNode useUnit (const Unit& unit) const; 00814 00815 // Constructors to convert a constant value to a TableExprNode. 00816 // The constructor for char* is also supported to convert a 00817 // character-array to a string, since a two step conversion 00818 // is not done automatically. 00819 // <group> 00820 TableExprNode (const Bool& value); 00821 TableExprNode (const Int64& value); 00822 TableExprNode (const Int& value); 00823 TableExprNode (const uInt& value); 00824 TableExprNode (const Float& value); 00825 TableExprNode (const Double& value); 00826 TableExprNode (const Complex& value); 00827 TableExprNode (const DComplex& value); 00828 TableExprNode (const String& value); 00829 TableExprNode (const std::string& value); 00830 TableExprNode (const char*); 00831 TableExprNode (const Regex& value); 00832 TableExprNode (const StringDistance& value); 00833 TableExprNode (const TaqlRegex& value); 00834 TableExprNode (const MVTime& value); 00835 TableExprNode (const Array<Bool>& value); 00836 TableExprNode (const Array<uChar>& value); 00837 TableExprNode (const Array<Short>& value); 00838 TableExprNode (const Array<uShort>& value); 00839 TableExprNode (const Array<Int>& value); 00840 TableExprNode (const Array<uInt>& value); 00841 TableExprNode (const Array<Float>& value); 00842 TableExprNode (const Array<Double>& value); 00843 TableExprNode (const Array<Complex>& value); 00844 TableExprNode (const Array<DComplex>& value); 00845 TableExprNode (const Array<String>& value); 00846 TableExprNode (const Array<MVTime>& value); 00847 // </group> 00848 00849 // Construct a node from a node representation. 00850 TableExprNode (TableExprNodeRep*); 00851 00852 // copy constructor (reference semantics). 00853 TableExprNode (const TableExprNode&); 00854 00855 // Assignment (reference semantics). 00856 TableExprNode& operator= (const TableExprNode&); 00857 00858 // The destructor deletes all the underlying TableExprNode objects, 00859 ~TableExprNode (); 00860 00861 // Does the node contain no actual node? 00862 Bool isNull() const 00863 { return node_p == 0; } 00864 00865 // Get the unit of the expression. 00866 const Unit& unit() const 00867 { return node_p->unit(); } 00868 00869 // Get the data type of the expression. 00870 // Currently the only possible values are TpBool, TpInt, TpDouble, 00871 // TpDComplex, TpString, and TpOther. 00872 // The latter is returned for a date or regex. 00873 DataType dataType() const; 00874 00875 // Is the expression a scalar? 00876 Bool isScalar() const 00877 { return (node_p->valueType() == TableExprNodeRep::VTScalar); } 00878 00879 // Get the number of rows in the table associated with this expression. 00880 // One is returned if the expression is a constant. 00881 // Zero is returned if no table is associated with it. 00882 uInt nrow() const 00883 { return node_p->nrow(); } 00884 00885 // Is the result value defined? 00886 // Normally it is, but not for a column with an undefined value. 00887 Bool isResultDefined (const TableExprId& id) const 00888 { return node_p->isDefined (id); } 00889 00890 // Get a value for this node in the given row. 00891 // These functions are implemented in the derived classes and 00892 // will usually invoke the get in their children and apply the 00893 // operator on the resulting values. 00894 // <group> 00895 void get (const TableExprId& id, Bool& value) const; 00896 void get (const TableExprId& id, Int64& value) const; 00897 void get (const TableExprId& id, Double& value) const; 00898 void get (const TableExprId& id, DComplex& value) const; 00899 void get (const TableExprId& id, String& value) const; 00900 void get (const TableExprId& id, TaqlRegex& value) const; 00901 void get (const TableExprId& id, MVTime& value) const; 00902 void get (const TableExprId& id, Array<Bool>& value) const; 00903 void get (const TableExprId& id, Array<Int64>& value) const; 00904 void get (const TableExprId& id, Array<Double>& value) const; 00905 void get (const TableExprId& id, Array<DComplex>& value) const; 00906 void get (const TableExprId& id, Array<String>& value) const; 00907 void get (const TableExprId& id, Array<MVTime>& value) const; 00908 Bool getBool (const TableExprId& id) const; 00909 Int64 getInt (const TableExprId& id) const; 00910 Double getDouble (const TableExprId& id) const; 00911 DComplex getDComplex (const TableExprId& id) const; 00912 String getString (const TableExprId& id) const; 00913 Array<Bool> getArrayBool (const TableExprId& id) const; 00914 Array<Int64> getArrayInt (const TableExprId& id) const; 00915 Array<Double> getArrayDouble (const TableExprId& id) const; 00916 Array<DComplex> getArrayDComplex (const TableExprId& id) const; 00917 Array<String> getArrayString (const TableExprId& id) const; 00918 // Get a value as an array, even it it is a scalar. 00919 // This is useful in case one can give an argument as scalar or array. 00920 // <group> 00921 Array<Bool> getBoolAS (const TableExprId& id) const; 00922 Array<Int64> getIntAS (const TableExprId& id) const; 00923 Array<Double> getDoubleAS (const TableExprId& id) const; 00924 Array<DComplex> getDComplexAS (const TableExprId& id) const; 00925 Array<String> getStringAS (const TableExprId& id) const; 00926 // </group> 00927 00928 // </group> 00929 00930 // Get the data type for doing a getColumn on the expression. 00931 // This is the data type of the column if the expression 00932 // consists of a single column only. 00933 // Otherwise it is the expression data type as returned by 00934 // function <src>dataType</src>. 00935 DataType getColumnDataType() const; 00936 00937 // Get the value of the expression evaluated for the entire column. 00938 // The data of function called should match the data type as 00939 // returned by function <src>getColumnDataType</src>. 00940 // <group> 00941 Array<Bool> getColumnBool (const Vector<uInt>& rownrs) const; 00942 Array<uChar> getColumnuChar (const Vector<uInt>& rownrs) const; 00943 Array<Short> getColumnShort (const Vector<uInt>& rownrs) const; 00944 Array<uShort> getColumnuShort (const Vector<uInt>& rownrs) const; 00945 Array<Int> getColumnInt (const Vector<uInt>& rownrs) const; 00946 Array<uInt> getColumnuInt (const Vector<uInt>& rownrs) const; 00947 Array<Float> getColumnFloat (const Vector<uInt>& rownrs) const; 00948 Array<Double> getColumnDouble (const Vector<uInt>& rownrs) const; 00949 Array<Complex> getColumnComplex (const Vector<uInt>& rownrs) const; 00950 Array<DComplex> getColumnDComplex (const Vector<uInt>& rownrs) const; 00951 Array<String> getColumnString (const Vector<uInt>& rownrs) const; 00952 // </group> 00953 00954 // Show the tree. 00955 void show (ostream&) const; 00956 00957 // Convert the tree to a number of range vectors which at least 00958 // select the same things. 00959 // This function is very useful to convert the expression to 00960 // some intervals covering the select expression. This can 00961 // be used to do a rough fast selection via an index and do the 00962 // the slower final selection on that much smaller subset. 00963 // The function can only convert direct comparisons of columns 00964 // with constants (via ==, !=, >, >=, < or <=) and their combinations 00965 // using && or ||. 00966 void ranges (Block<TableExprRange>&); 00967 00968 // Check if tables used in expression have the same number of 00969 // rows as the given table. 00970 Bool checkTableSize (const Table& table, Bool canBeConst) const; 00971 00972 // Get table. This gets the Table object to which a 00973 // TableExprNode belongs. A TableExprNode belongs to the Table to 00974 // which the column(s) used in an expression belong. Note that 00975 // all columns in an expression have to belong to the same table. 00976 const Table& table() const; 00977 00978 // Create a column node on behalf of the Table class. 00979 // For builtin data types another type of node is created than 00980 // for other data types. 00981 // isArray indicates if the column should be an array column. 00982 static TableExprNode newColumnNode (const Table& tab, 00983 const String& name, 00984 const Vector<String>& fieldNames); 00985 00986 // Create a TableExprNodeConst for a table keyword 00987 // (which is handled as a constant). 00988 static TableExprNode newKeyConst (const TableRecord&, 00989 const Vector<String>& fieldNames); 00990 00991 // Throw invalid data type exception. 00992 static void throwInvDT (const String& message); 00993 00994 // Create function node of the given type with the given arguments. 00995 // <group> 00996 static TableExprNode newFunctionNode (TableExprFuncNode::FunctionType, 00997 const TableExprNodeSet& set, 00998 const Table& table, 00999 const TaQLStyle& = TaQLStyle(0)); 01000 static TableExprNode newFunctionNode (TableExprFuncNode::FunctionType, 01001 const TableExprNode& node); 01002 static TableExprNode newFunctionNode (TableExprFuncNode::FunctionType, 01003 const TableExprNode& node1, 01004 const TableExprNode& node2); 01005 static TableExprNode newFunctionNode (TableExprFuncNode::FunctionType, 01006 const TableExprNode& node1, 01007 const TableExprNode& node2, 01008 const TableExprNode& node3); 01009 static TableExprNode newFunctionNode (TableExprFuncNode::FunctionType, 01010 const TableExprNode& array, 01011 const TableExprNodeSet& axes); 01012 static TableExprNode newFunctionNode (TableExprFuncNode::FunctionType, 01013 const TableExprNode& array, 01014 const TableExprNode& node, 01015 const TableExprNodeSet& axes); 01016 // </group> 01017 01018 // Create a user defined function node. 01019 static TableExprNode newUDFNode (const String& name, 01020 const TableExprNodeSet& set, 01021 const Table& table, 01022 const TaQLStyle& = TaQLStyle(0)); 01023 01024 // Create cone function node of the given type with the given arguments. 01025 // <group> 01026 static TableExprNode newConeNode (TableExprFuncNode::FunctionType, 01027 const TableExprNodeSet& set, 01028 uInt origin = 0); 01029 static TableExprNode newConeNode (TableExprFuncNode::FunctionType, 01030 const TableExprNode& node1, 01031 const TableExprNode& node2); 01032 static TableExprNode newConeNode (TableExprFuncNode::FunctionType, 01033 const TableExprNode& node1, 01034 const TableExprNode& node2, 01035 const TableExprNode& node3); 01036 // </group> 01037 01038 // Create rownumber() function node. 01039 // Origin indicates whether the first row should be zero (for C++ binding) 01040 // or an other value (one for TaQL binding). 01041 static TableExprNode newRownrNode (const Table& table, uInt origin); 01042 01043 // Create rowid() function node. 01044 // Origin is always 0. 01045 static TableExprNode newRowidNode (const Table& table); 01046 01047 // Create rand() function node. 01048 static TableExprNode newRandomNode (const Table& table); 01049 01050 // Create ArrayElement node for the given array with the given index. 01051 // The origin is 0 for C++ and 1 for TaQL. 01052 static TableExprNode newArrayPartNode (const TableExprNode& arrayNode, 01053 const TableExprNodeSet& indices, 01054 const TaQLStyle& = TaQLStyle(0)); 01055 01056 // returns pointer to the representation-object of it 01057 const TableExprNodeRep* getNodeRep() const; 01058 01059 // Adapt the unit of the expression to the given unit (if not empty). 01060 void adaptUnit (const Unit&); 01061 01062 private: 01063 // returns pointer to the representation-object of it 01064 TableExprNodeRep* getRep(); 01065 01066 // convert Block of TableExprNode to PtrBlock of TableExprNodeRep*. 01067 static PtrBlock<TableExprNodeRep*> convertBlockTEN 01068 (Block<TableExprNode>& nodes); 01069 01070 // Construct a new node for the given operation. 01071 // <group> 01072 TableExprNodeRep* newPlus (TableExprNodeRep* right) const; 01073 TableExprNodeRep* newMinus (TableExprNodeRep* right) const; 01074 TableExprNodeRep* newTimes (TableExprNodeRep* right) const; 01075 TableExprNodeRep* newDivide (TableExprNodeRep* right) const; 01076 TableExprNodeRep* newModulo (TableExprNodeRep* right) const; 01077 TableExprNodeRep* newBitAnd (TableExprNodeRep* right) const; 01078 TableExprNodeRep* newBitOr (TableExprNodeRep* right) const; 01079 TableExprNodeRep* newBitXor (TableExprNodeRep* right) const; 01080 TableExprNodeRep* newEQ (TableExprNodeRep* right) const; 01081 TableExprNodeRep* newNE (TableExprNodeRep* right) const; 01082 TableExprNodeRep* newGE (TableExprNodeRep* right) const; 01083 TableExprNodeRep* newGT (TableExprNodeRep* right) const; 01084 TableExprNodeRep* newIN (TableExprNodeRep* right) const; 01085 TableExprNodeRep* newOR (TableExprNodeRep* right) const; 01086 TableExprNodeRep* newAND (TableExprNodeRep* right) const; 01087 // </group> 01088 01089 // The actual (counted referenced) representation of a node. 01090 TableExprNodeRep* node_p; 01091 }; 01092 01093 01094 01095 inline void TableExprNode::ranges (Block<TableExprRange>& blrange) 01096 { node_p->ranges (blrange); } 01097 01098 //# Get the table from which the node is derived. 01099 inline const Table& TableExprNode::table() const 01100 { return node_p->table(); } 01101 01102 //# Get the value of an expression. 01103 inline void TableExprNode::get (const TableExprId& id, Bool& value) const 01104 { value = node_p->getBool (id); } 01105 inline void TableExprNode::get (const TableExprId& id, Int64& value) const 01106 { value = node_p->getInt (id); } 01107 inline void TableExprNode::get (const TableExprId& id, Double& value) const 01108 { value = node_p->getDouble (id); } 01109 inline void TableExprNode::get (const TableExprId& id, DComplex& value) const 01110 { value = node_p->getDComplex (id); } 01111 inline void TableExprNode::get (const TableExprId& id, String& value) const 01112 { value = node_p->getString (id); } 01113 inline void TableExprNode::get (const TableExprId& id, TaqlRegex& value) const 01114 { value = node_p->getRegex (id); } 01115 inline void TableExprNode::get (const TableExprId& id, MVTime& value) const 01116 { value = node_p->getDate (id); } 01117 inline void TableExprNode::get (const TableExprId& id, 01118 Array<Bool>& value) const 01119 { value = node_p->getArrayBool (id); } 01120 inline void TableExprNode::get (const TableExprId& id, 01121 Array<Int64>& value) const 01122 { value = node_p->getArrayInt (id); } 01123 inline void TableExprNode::get (const TableExprId& id, 01124 Array<Double>& value) const 01125 { value = node_p->getArrayDouble (id); } 01126 inline void TableExprNode::get (const TableExprId& id, 01127 Array<DComplex>& value) const 01128 { value = node_p->getArrayDComplex (id); } 01129 inline void TableExprNode::get (const TableExprId& id, 01130 Array<String>& value) const 01131 { value = node_p->getArrayString (id); } 01132 inline void TableExprNode::get (const TableExprId& id, 01133 Array<MVTime>& value) const 01134 { value = node_p->getArrayDate (id); } 01135 inline Bool TableExprNode::getBool (const TableExprId& id) const 01136 { return node_p->getBool (id); } 01137 inline Int64 TableExprNode::getInt (const TableExprId& id) const 01138 { return node_p->getInt (id); } 01139 inline Double TableExprNode::getDouble (const TableExprId& id) const 01140 { return node_p->getDouble (id); } 01141 inline DComplex TableExprNode::getDComplex (const TableExprId& id) const 01142 { return node_p->getDComplex (id); } 01143 inline String TableExprNode::getString (const TableExprId& id) const 01144 { return node_p->getString (id); } 01145 inline Array<Bool> TableExprNode::getArrayBool (const TableExprId& id) const 01146 { return node_p->getArrayBool (id); } 01147 inline Array<Int64> TableExprNode::getArrayInt (const TableExprId& id) const 01148 { return node_p->getArrayInt (id); } 01149 inline Array<Double> TableExprNode::getArrayDouble (const TableExprId& id) const 01150 { return node_p->getArrayDouble (id); } 01151 inline Array<DComplex> TableExprNode::getArrayDComplex (const TableExprId& id) const 01152 { return node_p->getArrayDComplex (id); } 01153 inline Array<String> TableExprNode::getArrayString (const TableExprId& id) const 01154 { return node_p->getArrayString (id); } 01155 inline Array<Bool> TableExprNode::getBoolAS (const TableExprId& id) const 01156 { return node_p->getBoolAS (id); } 01157 inline Array<Int64> TableExprNode::getIntAS (const TableExprId& id) const 01158 { return node_p->getIntAS (id); } 01159 inline Array<Double> TableExprNode::getDoubleAS (const TableExprId& id) const 01160 { return node_p->getDoubleAS (id); } 01161 inline Array<DComplex> TableExprNode::getDComplexAS (const TableExprId& id) const 01162 { return node_p->getDComplexAS (id); } 01163 inline Array<String> TableExprNode::getStringAS (const TableExprId& id) const 01164 { return node_p->getStringAS (id); } 01165 01166 inline Array<Bool> TableExprNode::getColumnBool (const Vector<uInt>& rownrs) const 01167 { return node_p->getColumnBool (rownrs); } 01168 inline Array<uChar> TableExprNode::getColumnuChar (const Vector<uInt>& rownrs) const 01169 { return node_p->getColumnuChar (rownrs); } 01170 inline Array<Short> TableExprNode::getColumnShort (const Vector<uInt>& rownrs) const 01171 { return node_p->getColumnShort (rownrs); } 01172 inline Array<uShort> TableExprNode::getColumnuShort (const Vector<uInt>& rownrs) const 01173 { return node_p->getColumnuShort (rownrs); } 01174 inline Array<Int> TableExprNode::getColumnInt (const Vector<uInt>& rownrs) const 01175 { return node_p->getColumnInt (rownrs); } 01176 inline Array<uInt> TableExprNode::getColumnuInt (const Vector<uInt>& rownrs) const 01177 { return node_p->getColumnuInt (rownrs); } 01178 inline Array<Float> TableExprNode::getColumnFloat (const Vector<uInt>& rownrs) const 01179 { return node_p->getColumnFloat (rownrs); } 01180 inline Array<Double> TableExprNode::getColumnDouble (const Vector<uInt>& rownrs) const 01181 { return node_p->getColumnDouble (rownrs); } 01182 inline Array<Complex> TableExprNode::getColumnComplex (const Vector<uInt>& rownrs) const 01183 { return node_p->getColumnComplex (rownrs); } 01184 inline Array<DComplex> TableExprNode::getColumnDComplex (const Vector<uInt>& rownrs) const 01185 { return node_p->getColumnDComplex (rownrs); } 01186 inline Array<String> TableExprNode::getColumnString (const Vector<uInt>& rownrs) const 01187 { return node_p->getColumnString (rownrs); } 01188 01189 01190 inline TableExprNode operator+ (const TableExprNode& left, 01191 const TableExprNode& right) 01192 { 01193 return left.newPlus (right.node_p); 01194 } 01195 inline TableExprNode operator- (const TableExprNode& left, 01196 const TableExprNode& right) 01197 { 01198 return left.newMinus (right.node_p); 01199 } 01200 inline TableExprNode operator* (const TableExprNode& left, 01201 const TableExprNode& right) 01202 { 01203 return left.newTimes (right.node_p); 01204 } 01205 inline TableExprNode operator/ (const TableExprNode& left, 01206 const TableExprNode& right) 01207 { 01208 return left.newDivide (right.node_p); 01209 } 01210 inline TableExprNode operator% (const TableExprNode& left, 01211 const TableExprNode& right) 01212 { 01213 return left.newModulo (right.node_p); 01214 } 01215 inline TableExprNode operator& (const TableExprNode& left, 01216 const TableExprNode& right) 01217 { 01218 return left.newBitAnd (right.node_p); 01219 } 01220 inline TableExprNode operator| (const TableExprNode& left, 01221 const TableExprNode& right) 01222 { 01223 return left.newBitOr (right.node_p); 01224 } 01225 inline TableExprNode operator^ (const TableExprNode& left, 01226 const TableExprNode& right) 01227 { 01228 return left.newBitXor (right.node_p); 01229 } 01230 inline TableExprNode operator== (const TableExprNode& left, 01231 const TableExprNode& right) 01232 { 01233 return left.newEQ (right.node_p); 01234 } 01235 inline TableExprNode operator!= (const TableExprNode& left, 01236 const TableExprNode& right) 01237 { 01238 return left.newNE (right.node_p); 01239 } 01240 inline TableExprNode operator> (const TableExprNode& left, 01241 const TableExprNode& right) 01242 { 01243 return left.newGT (right.node_p); 01244 } 01245 inline TableExprNode operator>= (const TableExprNode& left, 01246 const TableExprNode& right) 01247 { 01248 return left.newGE (right.node_p); 01249 } 01250 inline TableExprNode operator<= (const TableExprNode& left, 01251 const TableExprNode& right) 01252 { 01253 return right.newGE (left.node_p); 01254 } 01255 inline TableExprNode operator< (const TableExprNode& left, 01256 const TableExprNode& right) 01257 { 01258 return right.newGT (left.node_p); 01259 } 01260 inline TableExprNode TableExprNode::in (const TableExprNode& right) const 01261 { 01262 return newIN (right.node_p); 01263 } 01264 inline TableExprNode TableExprNode::operator() (const TableExprNodeSet& indices) 01265 { 01266 // C++ indexing is 0-based. 01267 return newArrayPartNode (*this, indices, TaQLStyle(0)); 01268 } 01269 01270 inline TableExprNode near (const TableExprNode& left, 01271 const TableExprNode& right) 01272 { 01273 return TableExprNode::newFunctionNode (TableExprFuncNode::near2FUNC, 01274 left, right); 01275 } 01276 inline TableExprNode near (const TableExprNode& left, 01277 const TableExprNode& right, 01278 const TableExprNode& tolerance) 01279 { 01280 return TableExprNode::newFunctionNode (TableExprFuncNode::near3FUNC, 01281 left, right, tolerance); 01282 } 01283 inline TableExprNode nearAbs (const TableExprNode& left, 01284 const TableExprNode& right) 01285 { 01286 return TableExprNode::newFunctionNode (TableExprFuncNode::nearabs2FUNC, 01287 left, right); 01288 } 01289 inline TableExprNode nearAbs (const TableExprNode& left, 01290 const TableExprNode& right, 01291 const TableExprNode& tolerance) 01292 { 01293 return TableExprNode::newFunctionNode (TableExprFuncNode::nearabs3FUNC, 01294 left, right, tolerance); 01295 } 01296 inline TableExprNode angdist (const TableExprNode& pos1, 01297 const TableExprNode& pos2) 01298 { 01299 return TableExprNode::newFunctionNode (TableExprFuncNode::angdistFUNC, 01300 pos1, pos2); 01301 } 01302 inline TableExprNode cones (const TableExprNode& sourcePos, 01303 const TableExprNode& cones) 01304 { 01305 return TableExprNode::newConeNode (TableExprFuncNode::conesFUNC, 01306 sourcePos, cones); 01307 } 01308 inline TableExprNode anyCone (const TableExprNode& sourcePos, 01309 const TableExprNode& cones) 01310 { 01311 return TableExprNode::newConeNode (TableExprFuncNode::anyconeFUNC, 01312 sourcePos, cones); 01313 } 01314 inline TableExprNode findCone (const TableExprNode& sourcePos, 01315 const TableExprNode& cones) 01316 { 01317 return TableExprNode::newConeNode (TableExprFuncNode::findconeFUNC, 01318 sourcePos, cones); 01319 } 01320 inline TableExprNode cones (const TableExprNode& sourcePos, 01321 const TableExprNode& conePos, 01322 const TableExprNode& radii) 01323 { 01324 return TableExprNode::newConeNode (TableExprFuncNode::cones3FUNC, 01325 sourcePos, conePos, radii); 01326 } 01327 inline TableExprNode anyCone (const TableExprNode& sourcePos, 01328 const TableExprNode& conePos, 01329 const TableExprNode& radii) 01330 { 01331 return TableExprNode::newConeNode (TableExprFuncNode::anycone3FUNC, 01332 sourcePos, conePos, radii); 01333 } 01334 inline TableExprNode findCone (const TableExprNode& sourcePos, 01335 const TableExprNode& conePos, 01336 const TableExprNode& radii) 01337 { 01338 return TableExprNode::newConeNode (TableExprFuncNode::findcone3FUNC, 01339 sourcePos, conePos, radii); 01340 } 01341 inline TableExprNode cos (const TableExprNode& node) 01342 { 01343 return TableExprNode::newFunctionNode (TableExprFuncNode::cosFUNC, node); 01344 } 01345 inline TableExprNode cosh (const TableExprNode& node) 01346 { 01347 return TableExprNode::newFunctionNode (TableExprFuncNode::coshFUNC, node); 01348 } 01349 inline TableExprNode exp (const TableExprNode& node) 01350 { 01351 return TableExprNode::newFunctionNode (TableExprFuncNode::expFUNC, node); 01352 } 01353 inline TableExprNode log (const TableExprNode& node) 01354 { 01355 return TableExprNode::newFunctionNode (TableExprFuncNode::logFUNC, node); 01356 } 01357 inline TableExprNode log10 (const TableExprNode& node) 01358 { 01359 return TableExprNode::newFunctionNode (TableExprFuncNode::log10FUNC, node); 01360 } 01361 inline TableExprNode pow (const TableExprNode& x, const TableExprNode& y) 01362 { 01363 return TableExprNode::newFunctionNode (TableExprFuncNode::powFUNC, x, y); 01364 } 01365 inline TableExprNode sin (const TableExprNode& node) 01366 { 01367 return TableExprNode::newFunctionNode (TableExprFuncNode::sinFUNC, node); 01368 } 01369 inline TableExprNode sinh (const TableExprNode& node) 01370 { 01371 return TableExprNode::newFunctionNode (TableExprFuncNode::sinhFUNC, node); 01372 } 01373 inline TableExprNode square (const TableExprNode& node) 01374 { 01375 return TableExprNode::newFunctionNode (TableExprFuncNode::squareFUNC, 01376 node); 01377 } 01378 inline TableExprNode cube (const TableExprNode& node) 01379 { 01380 return TableExprNode::newFunctionNode (TableExprFuncNode::cubeFUNC, 01381 node); 01382 } 01383 inline TableExprNode sqrt (const TableExprNode& node) 01384 { 01385 return TableExprNode::newFunctionNode (TableExprFuncNode::sqrtFUNC, node); 01386 } 01387 inline TableExprNode norm (const TableExprNode& node) 01388 { 01389 return TableExprNode::newFunctionNode (TableExprFuncNode::normFUNC, node); 01390 } 01391 inline TableExprNode acos (const TableExprNode& node) 01392 { 01393 return TableExprNode::newFunctionNode (TableExprFuncNode::acosFUNC, node); 01394 } 01395 inline TableExprNode asin (const TableExprNode& node) 01396 { 01397 return TableExprNode::newFunctionNode (TableExprFuncNode::asinFUNC, node); 01398 } 01399 inline TableExprNode atan (const TableExprNode& node) 01400 { 01401 return TableExprNode::newFunctionNode (TableExprFuncNode::atanFUNC, node); 01402 } 01403 inline TableExprNode atan2 (const TableExprNode& y, const TableExprNode& x) 01404 { 01405 return TableExprNode::newFunctionNode (TableExprFuncNode::atan2FUNC, y, x); 01406 } 01407 inline TableExprNode sign (const TableExprNode& node) 01408 { 01409 return TableExprNode::newFunctionNode (TableExprFuncNode::signFUNC, node); 01410 } 01411 inline TableExprNode round (const TableExprNode& node) 01412 { 01413 return TableExprNode::newFunctionNode (TableExprFuncNode::roundFUNC, node); 01414 } 01415 inline TableExprNode ceil (const TableExprNode& node) 01416 { 01417 return TableExprNode::newFunctionNode (TableExprFuncNode::ceilFUNC, node); 01418 } 01419 inline TableExprNode abs (const TableExprNode& node) 01420 { 01421 return TableExprNode::newFunctionNode (TableExprFuncNode::absFUNC, node); 01422 } 01423 inline TableExprNode floor (const TableExprNode& node) 01424 { 01425 return TableExprNode::newFunctionNode (TableExprFuncNode::floorFUNC, node); 01426 } 01427 inline TableExprNode fmod (const TableExprNode& x, const TableExprNode& y) 01428 { 01429 return TableExprNode::newFunctionNode (TableExprFuncNode::fmodFUNC, x, y); 01430 } 01431 inline TableExprNode tan (const TableExprNode& node) 01432 { 01433 return TableExprNode::newFunctionNode (TableExprFuncNode::tanFUNC, node); 01434 } 01435 inline TableExprNode tanh (const TableExprNode& node) 01436 { 01437 return TableExprNode::newFunctionNode (TableExprFuncNode::tanhFUNC, node); 01438 } 01439 inline TableExprNode min (const TableExprNode& a, const TableExprNode& b) 01440 { 01441 return TableExprNode::newFunctionNode (TableExprFuncNode::minFUNC, a, b); 01442 } 01443 inline TableExprNode max (const TableExprNode& a, const TableExprNode& b) 01444 { 01445 return TableExprNode::newFunctionNode (TableExprFuncNode::maxFUNC, a, b); 01446 } 01447 inline TableExprNode real (const TableExprNode& node) 01448 { 01449 return TableExprNode::newFunctionNode (TableExprFuncNode::realFUNC, node); 01450 } 01451 inline TableExprNode imag (const TableExprNode& node) 01452 { 01453 return TableExprNode::newFunctionNode (TableExprFuncNode::imagFUNC, node); 01454 } 01455 inline TableExprNode integer (const TableExprNode& node) 01456 { 01457 return TableExprNode::newFunctionNode (TableExprFuncNode::intFUNC, node); 01458 } 01459 inline TableExprNode conj (const TableExprNode& node) 01460 { 01461 return TableExprNode::newFunctionNode (TableExprFuncNode::conjFUNC, node); 01462 } 01463 inline TableExprNode amplitude (const TableExprNode& node) 01464 { 01465 return TableExprNode::newFunctionNode (TableExprFuncNode::absFUNC, node); 01466 } 01467 inline TableExprNode arg (const TableExprNode& node) 01468 { 01469 return TableExprNode::newFunctionNode (TableExprFuncNode::argFUNC, node); 01470 } 01471 inline TableExprNode phase (const TableExprNode& node) 01472 { 01473 return TableExprNode::newFunctionNode (TableExprFuncNode::argFUNC, node); 01474 } 01475 inline TableExprNode formComplex (const TableExprNode& real, 01476 const TableExprNode& imag) 01477 { 01478 return TableExprNode::newFunctionNode (TableExprFuncNode::complexFUNC, 01479 real, imag); 01480 } 01481 inline TableExprNode strlength (const TableExprNode& node) 01482 { 01483 return TableExprNode::newFunctionNode (TableExprFuncNode::strlengthFUNC, 01484 node); 01485 } 01486 inline TableExprNode upcase (const TableExprNode& node) 01487 { 01488 return TableExprNode::newFunctionNode (TableExprFuncNode::upcaseFUNC, 01489 node); 01490 } 01491 inline TableExprNode downcase (const TableExprNode& node) 01492 { 01493 return TableExprNode::newFunctionNode (TableExprFuncNode::downcaseFUNC, 01494 node); 01495 } 01496 inline TableExprNode regex (const TableExprNode& node) 01497 { 01498 return TableExprNode::newFunctionNode (TableExprFuncNode::regexFUNC, node); 01499 } 01500 inline TableExprNode pattern (const TableExprNode& node) 01501 { 01502 return TableExprNode::newFunctionNode (TableExprFuncNode::patternFUNC, 01503 node); 01504 } 01505 inline TableExprNode sqlpattern (const TableExprNode& node) 01506 { 01507 return TableExprNode::newFunctionNode (TableExprFuncNode::sqlpatternFUNC, 01508 node); 01509 } 01510 inline TableExprNode datetime (const TableExprNode& node) 01511 { 01512 return TableExprNode::newFunctionNode (TableExprFuncNode::datetimeFUNC, 01513 node); 01514 } 01515 inline TableExprNode mjdtodate (const TableExprNode& node) 01516 { 01517 return TableExprNode::newFunctionNode (TableExprFuncNode::mjdtodateFUNC, 01518 node); 01519 } 01520 inline TableExprNode mjd (const TableExprNode& node) 01521 { 01522 return TableExprNode::newFunctionNode (TableExprFuncNode::mjdFUNC, node); 01523 } 01524 inline TableExprNode date (const TableExprNode& node) 01525 { 01526 return TableExprNode::newFunctionNode (TableExprFuncNode::dateFUNC, node); 01527 } 01528 inline TableExprNode year (const TableExprNode& node) 01529 { 01530 return TableExprNode::newFunctionNode (TableExprFuncNode::yearFUNC, node); 01531 } 01532 inline TableExprNode month (const TableExprNode& node) 01533 { 01534 return TableExprNode::newFunctionNode (TableExprFuncNode::monthFUNC, node); 01535 } 01536 inline TableExprNode day (const TableExprNode& node) 01537 { 01538 return TableExprNode::newFunctionNode (TableExprFuncNode::dayFUNC, node); 01539 } 01540 inline TableExprNode cmonth (const TableExprNode& node) 01541 { 01542 return TableExprNode::newFunctionNode (TableExprFuncNode::cmonthFUNC, 01543 node); 01544 } 01545 inline TableExprNode weekday (const TableExprNode& node) 01546 { 01547 return TableExprNode::newFunctionNode (TableExprFuncNode::weekdayFUNC, 01548 node); 01549 } 01550 inline TableExprNode cdow (const TableExprNode& node) 01551 { 01552 return TableExprNode::newFunctionNode (TableExprFuncNode::cdowFUNC, node); 01553 } 01554 inline TableExprNode ctodt (const TableExprNode& node) 01555 { 01556 return TableExprNode::newFunctionNode (TableExprFuncNode::ctodFUNC, node); 01557 } 01558 inline TableExprNode cdate (const TableExprNode& node) 01559 { 01560 return TableExprNode::newFunctionNode (TableExprFuncNode::cdateFUNC, node); 01561 } 01562 inline TableExprNode ctime (const TableExprNode& node) 01563 { 01564 return TableExprNode::newFunctionNode (TableExprFuncNode::ctimeFUNC, node); 01565 } 01566 inline TableExprNode hms (const TableExprNode& node) 01567 { 01568 return TableExprNode::newFunctionNode (TableExprFuncNode::hmsFUNC, node); 01569 } 01570 inline TableExprNode dms (const TableExprNode& node) 01571 { 01572 return TableExprNode::newFunctionNode (TableExprFuncNode::dmsFUNC, node); 01573 } 01574 inline TableExprNode hdms (const TableExprNode& node) 01575 { 01576 return TableExprNode::newFunctionNode (TableExprFuncNode::hdmsFUNC, node); 01577 } 01578 inline TableExprNode week (const TableExprNode& node) 01579 { 01580 return TableExprNode::newFunctionNode (TableExprFuncNode::weekFUNC, node); 01581 } 01582 inline TableExprNode time (const TableExprNode& node) 01583 { 01584 return TableExprNode::newFunctionNode (TableExprFuncNode::timeFUNC, node); 01585 } 01586 inline TableExprNode trim (const TableExprNode& node) 01587 { 01588 return TableExprNode::newFunctionNode (TableExprFuncNode::trimFUNC, node); 01589 } 01590 inline TableExprNode ltrim (const TableExprNode& node) 01591 { 01592 return TableExprNode::newFunctionNode (TableExprFuncNode::ltrimFUNC, node); 01593 } 01594 inline TableExprNode rtrim (const TableExprNode& node) 01595 { 01596 return TableExprNode::newFunctionNode (TableExprFuncNode::rtrimFUNC, node); 01597 } 01598 inline TableExprNode substr (const TableExprNode& node, 01599 const TableExprNode& pos) 01600 { 01601 return TableExprNode::newFunctionNode (TableExprFuncNode::substrFUNC, 01602 node, pos); 01603 } 01604 inline TableExprNode substr (const TableExprNode& node, 01605 const TableExprNode& pos, 01606 const TableExprNode& npos) 01607 { 01608 return TableExprNode::newFunctionNode (TableExprFuncNode::substrFUNC, 01609 node, pos, npos); 01610 } 01611 inline TableExprNode replace (const TableExprNode& node, 01612 const TableExprNode& patt) 01613 { 01614 return TableExprNode::newFunctionNode (TableExprFuncNode::replaceFUNC, 01615 node, patt); 01616 } 01617 inline TableExprNode replace (const TableExprNode& node, 01618 const TableExprNode& patt, 01619 const TableExprNode& repl) 01620 { 01621 return TableExprNode::newFunctionNode (TableExprFuncNode::replaceFUNC, 01622 node, patt, repl); 01623 } 01624 inline TableExprNode isNaN (const TableExprNode& node) 01625 { 01626 return TableExprNode::newFunctionNode (TableExprFuncNode::isnanFUNC, node); 01627 } 01628 inline TableExprNode isInf (const TableExprNode& node) 01629 { 01630 return TableExprNode::newFunctionNode (TableExprFuncNode::isinfFUNC, node); 01631 } 01632 inline TableExprNode isFinite (const TableExprNode& node) 01633 { 01634 return TableExprNode::newFunctionNode (TableExprFuncNode::isfiniteFUNC, 01635 node); 01636 } 01637 inline TableExprNode min (const TableExprNode& node) 01638 { 01639 return TableExprNode::newFunctionNode (TableExprFuncNode::arrminFUNC, 01640 node); 01641 } 01642 inline TableExprNode max (const TableExprNode& node) 01643 { 01644 return TableExprNode::newFunctionNode (TableExprFuncNode::arrmaxFUNC, 01645 node); 01646 } 01647 inline TableExprNode sum (const TableExprNode& node) 01648 { 01649 return TableExprNode::newFunctionNode (TableExprFuncNode::arrsumFUNC, 01650 node); 01651 } 01652 inline TableExprNode product (const TableExprNode& node) 01653 { 01654 return TableExprNode::newFunctionNode (TableExprFuncNode::arrproductFUNC, 01655 node); 01656 } 01657 inline TableExprNode sumSquare (const TableExprNode& node) 01658 { 01659 return TableExprNode::newFunctionNode (TableExprFuncNode::arrsumsqrFUNC, 01660 node); 01661 } 01662 inline TableExprNode mean (const TableExprNode& node) 01663 { 01664 return TableExprNode::newFunctionNode (TableExprFuncNode::arrmeanFUNC, 01665 node); 01666 } 01667 inline TableExprNode variance (const TableExprNode& node) 01668 { 01669 return TableExprNode::newFunctionNode (TableExprFuncNode::arrvarianceFUNC, 01670 node); 01671 } 01672 inline TableExprNode stddev (const TableExprNode& node) 01673 { 01674 return TableExprNode::newFunctionNode (TableExprFuncNode::arrstddevFUNC, 01675 node); 01676 } 01677 inline TableExprNode avdev (const TableExprNode& node) 01678 { 01679 return TableExprNode::newFunctionNode (TableExprFuncNode::arravdevFUNC, 01680 node); 01681 } 01682 inline TableExprNode rms (const TableExprNode& node) 01683 { 01684 return TableExprNode::newFunctionNode (TableExprFuncNode::arrrmsFUNC, 01685 node); 01686 } 01687 inline TableExprNode median (const TableExprNode& node) 01688 { 01689 return TableExprNode::newFunctionNode (TableExprFuncNode::arrmedianFUNC, 01690 node); 01691 } 01692 inline TableExprNode fractile (const TableExprNode& node, 01693 const TableExprNode& fraction) 01694 { 01695 return TableExprNode::newFunctionNode (TableExprFuncNode::arrfractileFUNC, 01696 node, fraction); 01697 } 01698 inline TableExprNode any (const TableExprNode& node) 01699 { 01700 return TableExprNode::newFunctionNode (TableExprFuncNode::anyFUNC, node); 01701 } 01702 inline TableExprNode all (const TableExprNode& node) 01703 { 01704 return TableExprNode::newFunctionNode (TableExprFuncNode::allFUNC, node); 01705 } 01706 inline TableExprNode ntrue (const TableExprNode& node) 01707 { 01708 return TableExprNode::newFunctionNode (TableExprFuncNode::ntrueFUNC, node); 01709 } 01710 inline TableExprNode nfalse (const TableExprNode& node) 01711 { 01712 return TableExprNode::newFunctionNode (TableExprFuncNode::nfalseFUNC, node); 01713 } 01714 inline TableExprNode sums (const TableExprNode& array, 01715 const TableExprNodeSet& axes) 01716 { 01717 return TableExprNode::newFunctionNode (TableExprFuncNode::arrsumsFUNC, 01718 array, axes); 01719 } 01720 inline TableExprNode products (const TableExprNode& array, 01721 const TableExprNodeSet& axes) 01722 { 01723 return TableExprNode::newFunctionNode (TableExprFuncNode::arrproductsFUNC, 01724 array, axes); 01725 } 01726 inline TableExprNode sumSquares (const TableExprNode& array, 01727 const TableExprNodeSet& axes) 01728 { 01729 return TableExprNode::newFunctionNode (TableExprFuncNode::arrsumsqrsFUNC, 01730 array, axes); 01731 } 01732 inline TableExprNode mins (const TableExprNode& array, 01733 const TableExprNodeSet& axes) 01734 { 01735 return TableExprNode::newFunctionNode (TableExprFuncNode::arrminsFUNC, 01736 array, axes); 01737 } 01738 inline TableExprNode maxs (const TableExprNode& array, 01739 const TableExprNodeSet& axes) 01740 { 01741 return TableExprNode::newFunctionNode (TableExprFuncNode::arrmaxsFUNC, 01742 array, axes); 01743 } 01744 inline TableExprNode means (const TableExprNode& array, 01745 const TableExprNodeSet& axes) 01746 { 01747 return TableExprNode::newFunctionNode (TableExprFuncNode::arrmeansFUNC, 01748 array, axes); 01749 } 01750 inline TableExprNode variances (const TableExprNode& array, 01751 const TableExprNodeSet& axes) 01752 { 01753 return TableExprNode::newFunctionNode (TableExprFuncNode::arrvariancesFUNC, 01754 array, axes); 01755 } 01756 inline TableExprNode stddevs (const TableExprNode& array, 01757 const TableExprNodeSet& axes) 01758 { 01759 return TableExprNode::newFunctionNode (TableExprFuncNode::arrstddevsFUNC, 01760 array, axes); 01761 } 01762 inline TableExprNode avdevs (const TableExprNode& array, 01763 const TableExprNodeSet& axes) 01764 { 01765 return TableExprNode::newFunctionNode (TableExprFuncNode::arravdevsFUNC, 01766 array, axes); 01767 } 01768 inline TableExprNode rmss (const TableExprNode& array, 01769 const TableExprNodeSet& axes) 01770 { 01771 return TableExprNode::newFunctionNode (TableExprFuncNode::arrrmssFUNC, 01772 array, axes); 01773 } 01774 inline TableExprNode medians (const TableExprNode& array, 01775 const TableExprNodeSet& axes) 01776 { 01777 return TableExprNode::newFunctionNode (TableExprFuncNode::arrmediansFUNC, 01778 array, axes); 01779 } 01780 inline TableExprNode fractiles (const TableExprNode& array, 01781 const TableExprNode& fraction, 01782 const TableExprNodeSet& axes) 01783 { 01784 return TableExprNode::newFunctionNode (TableExprFuncNode::arrfractilesFUNC, 01785 array, fraction, axes); 01786 } 01787 inline TableExprNode anys (const TableExprNode& array, 01788 const TableExprNodeSet& axes) 01789 { 01790 return TableExprNode::newFunctionNode (TableExprFuncNode::anysFUNC, 01791 array, axes); 01792 } 01793 inline TableExprNode alls (const TableExprNode& array, 01794 const TableExprNodeSet& axes) 01795 { 01796 return TableExprNode::newFunctionNode (TableExprFuncNode::allsFUNC, 01797 array, axes); 01798 } 01799 inline TableExprNode ntrues (const TableExprNode& array, 01800 const TableExprNodeSet& axes) 01801 { 01802 return TableExprNode::newFunctionNode (TableExprFuncNode::ntruesFUNC, 01803 array, axes); 01804 } 01805 inline TableExprNode nfalses (const TableExprNode& array, 01806 const TableExprNodeSet& axes) 01807 { 01808 return TableExprNode::newFunctionNode (TableExprFuncNode::nfalsesFUNC, 01809 array, axes); 01810 } 01811 inline TableExprNode runningMin (const TableExprNode& node, 01812 const TableExprNodeSet& halfBoxWidth) 01813 { 01814 return TableExprNode::newFunctionNode (TableExprFuncNode::runminFUNC, 01815 node, halfBoxWidth); 01816 } 01817 inline TableExprNode runningMax (const TableExprNode& node, 01818 const TableExprNodeSet& halfBoxWidth) 01819 { 01820 return TableExprNode::newFunctionNode (TableExprFuncNode::runmaxFUNC, 01821 node, halfBoxWidth); 01822 } 01823 inline TableExprNode runningMean (const TableExprNode& node, 01824 const TableExprNodeSet& halfBoxWidth) 01825 { 01826 return TableExprNode::newFunctionNode (TableExprFuncNode::runmeanFUNC, 01827 node, halfBoxWidth); 01828 } 01829 inline TableExprNode runningVariance (const TableExprNode& node, 01830 const TableExprNodeSet& halfBoxWidth) 01831 { 01832 return TableExprNode::newFunctionNode (TableExprFuncNode::runvarianceFUNC, 01833 node, halfBoxWidth); 01834 } 01835 inline TableExprNode runningStddev (const TableExprNode& node, 01836 const TableExprNodeSet& halfBoxWidth) 01837 { 01838 return TableExprNode::newFunctionNode (TableExprFuncNode::runstddevFUNC, 01839 node, halfBoxWidth); 01840 } 01841 inline TableExprNode runningAvdev (const TableExprNode& node, 01842 const TableExprNodeSet& halfBoxWidth) 01843 { 01844 return TableExprNode::newFunctionNode (TableExprFuncNode::runavdevFUNC, 01845 node, halfBoxWidth); 01846 } 01847 inline TableExprNode runningRms (const TableExprNode& node, 01848 const TableExprNodeSet& halfBoxWidth) 01849 { 01850 return TableExprNode::newFunctionNode (TableExprFuncNode::runrmsFUNC, 01851 node, halfBoxWidth); 01852 } 01853 inline TableExprNode runningMedian (const TableExprNode& node, 01854 const TableExprNodeSet& halfBoxWidth) 01855 { 01856 return TableExprNode::newFunctionNode (TableExprFuncNode::runmedianFUNC, 01857 node, halfBoxWidth); 01858 } 01859 inline TableExprNode runningAny (const TableExprNode& node, 01860 const TableExprNodeSet& halfBoxWidth) 01861 { 01862 return TableExprNode::newFunctionNode (TableExprFuncNode::runanyFUNC, 01863 node, halfBoxWidth); 01864 } 01865 inline TableExprNode runningAll (const TableExprNode& node, 01866 const TableExprNodeSet& halfBoxWidth) 01867 { 01868 return TableExprNode::newFunctionNode (TableExprFuncNode::runallFUNC, 01869 node, halfBoxWidth); 01870 } 01871 inline TableExprNode boxedMin (const TableExprNode& node, 01872 const TableExprNodeSet& halfBoxWidth) 01873 { 01874 return TableExprNode::newFunctionNode (TableExprFuncNode::boxminFUNC, 01875 node, halfBoxWidth); 01876 } 01877 inline TableExprNode boxedMax (const TableExprNode& node, 01878 const TableExprNodeSet& halfBoxWidth) 01879 { 01880 return TableExprNode::newFunctionNode (TableExprFuncNode::boxmaxFUNC, 01881 node, halfBoxWidth); 01882 } 01883 inline TableExprNode boxedMean (const TableExprNode& node, 01884 const TableExprNodeSet& halfBoxWidth) 01885 { 01886 return TableExprNode::newFunctionNode (TableExprFuncNode::boxmeanFUNC, 01887 node, halfBoxWidth); 01888 } 01889 inline TableExprNode boxedVariance (const TableExprNode& node, 01890 const TableExprNodeSet& halfBoxWidth) 01891 { 01892 return TableExprNode::newFunctionNode (TableExprFuncNode::boxvarianceFUNC, 01893 node, halfBoxWidth); 01894 } 01895 inline TableExprNode boxedStddev (const TableExprNode& node, 01896 const TableExprNodeSet& halfBoxWidth) 01897 { 01898 return TableExprNode::newFunctionNode (TableExprFuncNode::boxstddevFUNC, 01899 node, halfBoxWidth); 01900 } 01901 inline TableExprNode boxedAvdev (const TableExprNode& node, 01902 const TableExprNodeSet& halfBoxWidth) 01903 { 01904 return TableExprNode::newFunctionNode (TableExprFuncNode::boxavdevFUNC, 01905 node, halfBoxWidth); 01906 } 01907 inline TableExprNode boxedRms (const TableExprNode& node, 01908 const TableExprNodeSet& halfBoxWidth) 01909 { 01910 return TableExprNode::newFunctionNode (TableExprFuncNode::boxrmsFUNC, 01911 node, halfBoxWidth); 01912 } 01913 inline TableExprNode boxedMedian (const TableExprNode& node, 01914 const TableExprNodeSet& halfBoxWidth) 01915 { 01916 return TableExprNode::newFunctionNode (TableExprFuncNode::boxmedianFUNC, 01917 node, halfBoxWidth); 01918 } 01919 inline TableExprNode boxedAny (const TableExprNode& node, 01920 const TableExprNodeSet& halfBoxWidth) 01921 { 01922 return TableExprNode::newFunctionNode (TableExprFuncNode::boxanyFUNC, 01923 node, halfBoxWidth); 01924 } 01925 inline TableExprNode boxedAll (const TableExprNode& node, 01926 const TableExprNodeSet& halfBoxWidth) 01927 { 01928 return TableExprNode::newFunctionNode (TableExprFuncNode::boxallFUNC, 01929 node, halfBoxWidth); 01930 } 01931 inline TableExprNode array (const TableExprNode& values, 01932 const TableExprNodeSet& shape) 01933 { 01934 return TableExprNode::newFunctionNode (TableExprFuncNode::arrayFUNC, 01935 values, shape); 01936 } 01937 inline TableExprNode isdefined (const TableExprNode& node) 01938 { 01939 return TableExprNode::newFunctionNode (TableExprFuncNode::isdefFUNC, node); 01940 } 01941 inline TableExprNode nelements (const TableExprNode& node) 01942 { 01943 return TableExprNode::newFunctionNode (TableExprFuncNode::nelemFUNC, node); 01944 } 01945 inline TableExprNode ndim (const TableExprNode& node) 01946 { 01947 return TableExprNode::newFunctionNode (TableExprFuncNode::ndimFUNC, node); 01948 } 01949 inline TableExprNode shape (const TableExprNode& node) 01950 { 01951 return TableExprNode::newFunctionNode (TableExprFuncNode::shapeFUNC, node); 01952 } 01953 inline TableExprNode iif (const TableExprNode& condition, 01954 const TableExprNode& arg1, 01955 const TableExprNode& arg2) 01956 { 01957 return TableExprNode::newFunctionNode (TableExprFuncNode::iifFUNC, 01958 condition, arg1, arg2); 01959 } 01960 01961 01962 inline void TableExprNode::show (ostream& os) const 01963 { 01964 node_p->show (os, 0); 01965 } 01966 inline const TableExprNodeRep* TableExprNode::getNodeRep() const 01967 { 01968 return node_p; 01969 } 01970 inline TableExprNodeRep* TableExprNode::getRep() 01971 { 01972 return node_p; 01973 } 01974 01975 01976 01977 } //# NAMESPACE CASA - END 01978 01979 #endif