casacore
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
ExprNode.h
Go to the documentation of this file.
1 //# ExprNode.h: Handle class for a table column expression tree
2 //# Copyright (C) 1994,1995,1996,1997,1998,2000,2001,2003
3 //# Associated Universities, Inc. Washington DC, USA.
4 //#
5 //# This library is free software; you can redistribute it and/or modify it
6 //# under the terms of the GNU Library General Public License as published by
7 //# the Free Software Foundation; either version 2 of the License, or (at your
8 //# option) any later version.
9 //#
10 //# This library is distributed in the hope that it will be useful, but WITHOUT
11 //# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 //# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
13 //# License for more details.
14 //#
15 //# You should have received a copy of the GNU Library General Public License
16 //# along with this library; if not, write to the Free Software Foundation,
17 //# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA.
18 //#
19 //# Correspondence concerning AIPS++ should be addressed as follows:
20 //# Internet email: aips2-request@nrao.edu.
21 //# Postal address: AIPS++ Project Office
22 //# National Radio Astronomy Observatory
23 //# 520 Edgemont Road
24 //# Charlottesville, VA 22903-2475 USA
25 //#
26 //# $Id: ExprNode.h 21277 2012-10-31 16:07:31Z gervandiepen $
27 
28 #ifndef TABLES_EXPRNODE_H
29 #define TABLES_EXPRNODE_H
30 
31 //# Includes
32 #include <casacore/casa/aips.h>
43 
44 namespace casacore { //# NAMESPACE CASACORE - BEGIN
45 
46 //# Forward Declarations
47 class Table;
48 class String;
49 class Regex;
50 class StringDistance;
51 class Unit;
52 class Record;
53 class TableRecord;
54 class TableExprNodeBinary;
55 class TableExprNodeSet;
56 template<class T> class Block;
57 template<class T> class MArray;
58 
59 
60 // <summary>
61 // Handle class for a table column expression tree
62 // </summary>
63 
64 // <use visibility=export>
65 
66 // <reviewed reviewer="UNKNOWN" date="before2004/08/25" tests="">
67 // </reviewed>
68 
69 // <prerequisite>
70 //# Classes you should understand before using this one.
71 // <li> <linkto class=Table>Table</linkto>
72 // <li> Note 199 describing
73 // <a href="../notes/199.html">
74 // TaQL</a>
75 // </prerequisite>
76 
77 // <etymology>
78 // TableExprNode represents a node in the tree reflecting a
79 // table select expression.
80 // </etymology>
81 
82 // <synopsis>
83 // TableExprNode is the class to store a table select expression,
84 // making it possible to select rows from the table. The selected
85 // rows form a table which is a view of the original table.
86 // <p>
87 // TableExprNode is a handle class for the counted referenced class
88 // TableExprNodeRep.
89 // Classes (like TableExprNodePlusXX) derived from TableExprNodeRep
90 // hold the individual
91 // nodes in the expression, i.e. the operators and operands. The nodes
92 // form a binary tree reflecting the expression.
93 // E.g. the expression 2*COLUMN results in the node TableExprNodeTimes
94 // with its children TableExprNodeConst and TableExprNodeColumn.
95 // Constant subexpressions (like 2*3) are evaluated immediately and
96 // only the result is stored as a node.
97 // <p>
98 // There are a few TableExprNode constructors taking a constant scalar or array.
99 // In this way constant value are automatically converted to the
100 // appropriate TableExprNodeConst object.
101 // <p>
102 // The derived classes also reflect the data type of the node.
103 // Data types Bool, Int64, Double, DComplex and String are used.
104 // Char, uChar, Short, uShort, Int and uInt are converted to Int64,
105 // float to Double, and Complex to DComplex.
106 // Binary operators +, -, *, /, %, &, }, ^, ==, >=, >, <, <= and != are
107 // recognized. Also &&, ||, parentheses and unary +, -, ~ and ! are recognized.
108 // For strings the binary operator + can also be used.
109 // The operators have the normal C++ precedence.
110 // Furthermore functions (such as sin, max, ceil) can be used in an expression.
111 // <br>Operator() can be used to take a slice from an array.
112 // <p>
113 // The Table function col has to be used to create a TableExprNode
114 // object for a column in the table. The Table
115 // <linkto file="Table.h#keycol">operator()</linkto> can be used
116 // the do the actual selection from the top TableExprNode object.
117 // </synopsis>
118 
119 // <example>
120 // <srcblock>
121 // // Select from table X all rows where column RA<5 and where column
122 // // SWITCH is true.
123 // Table table("X");
124 // Table subtable = table(table.col("RA") < 5 && table.col("SWITCH"));
125 //
126 // // Select from that result all rows where the concatenation of
127 // // the strings in columns STR1 and STR2 is equal to the string
128 // // in keyword STRKEY.
129 // Table subsub = subtable(subtable.col("STR1") + subtable.col("STR2")
130 // == subtable.key("STRKEY"));
131 // </srcblock>
132 // </example>
133 
134 // <motivation>
135 // Having TableExprNode as a handle class makes it possible to
136 // handle temporary objects created by the compiler in a smooth way.
137 // TableExprNode and its derivations allow to store an expression
138 // before actually evaluating it. This also allows the classes to
139 // be used by the table expression parser defined in TableParse and
140 // TableGram.
141 //
142 // For each operator a special derived class is implemented.
143 // Another approach could have been to store the operator as
144 // a flag and switch on that. However, that causes extra overhead
145 // and the C++ virtual function mechanism is the designed for
146 // these purposes.
147 // </motivation>
148 
149 // <todo asof="$DATE:$">
150 //# A List of bugs, limitations, extensions or planned refinements.
151 // <li> add operations on arrays
152 // <li> add selection by comparing with a set of values
153 // </todo>
154 
155 
157 {
158 public:
159  TableExprNode ();
160 
161  // Unary operators on numeric TableExprNode's.
162  // <group>
163  TableExprNode operator+ () const;
164  TableExprNode operator- () const;
165  // </group>
166  // Unary NOT-operator on boolean TableExprNode's.
167  TableExprNode operator! () const;
168  // Unary bitwise negate-operator on integer TableExprNode's.
169  TableExprNode operator~ () const;
170 
171  // Slicing in a node containing an array. It is possible to
172  // address a single pixel or an n-dimensional subarray.
173  // In case of a single pixel the result is a scalar node.
174  // Otherwise the result is an array node with the same dimensionality
175  // as the source.
176  // <br>Note that there exist TableExprNodeSet constructors to
177  // convert an <src>IPosition</src> or <src>Slicer</src> object
178  // automatically to a <src>TableExprNodeSet</src>.
179  // An <src>IPosition</src> addresses a single element and results in
180  // a scalar node, while a <src>Slicer</src> can address multiple
181  // elements and always results in an array node.
183 
184  // The IN operator to test if a value is contained in an array or set.
185  // The array can also be a scalar.
186  // <group>
188  const TaQLStyle& = TaQLStyle(0)) const;
189  TableExprNode in (const TableExprNodeSet& set,
190  const TaQLStyle& = TaQLStyle(0)) const;
191  // </group>
192 
193  // Use a unit for the given TableExprNode.
194  // Note that if a column has a unit, it is automatically set. In that case
195  // this can be used to convert units.
196  TableExprNode useUnit (const Unit& unit) const;
197 
198  // Constructors to convert a constant value to a TableExprNode.
199  // The constructor for char* is also supported to convert a
200  // character-array to a string, since a two step conversion
201  // is not done automatically.
202  // <group>
203  TableExprNode (const Bool& value);
204  TableExprNode (const Int& value);
205  TableExprNode (const uInt& value);
206  TableExprNode (const Int64& value);
207  TableExprNode (const uInt64& value);
208  TableExprNode (const Float& value);
209  TableExprNode (const Double& value);
210  TableExprNode (const Complex& value);
211  TableExprNode (const DComplex& value);
212  TableExprNode (const String& value);
213  TableExprNode (const std::string& value);
214  TableExprNode (const char*);
215  TableExprNode (const Regex& value);
216  TableExprNode (const StringDistance& value);
217  TableExprNode (const TaqlRegex& value);
218  TableExprNode (const MVTime& value);
219  TableExprNode (const Array<Bool>& value);
220  TableExprNode (const Array<uChar>& value);
221  TableExprNode (const Array<Short>& value);
222  TableExprNode (const Array<uShort>& value);
223  TableExprNode (const Array<Int>& value);
224  TableExprNode (const Array<uInt>& value);
225  TableExprNode (const Array<Int64>& value);
226  //# The following constructor has to be explicit, othwerwise
227  //# Table(Vector<rownr_t>)
228  //# gives an ambiguous error as the preferred class RowNumbers
229  //# has a similar constructor.
230  explicit TableExprNode (const Array<uInt64>& value);
231  TableExprNode (const Array<Float>& value);
232  TableExprNode (const Array<Double>& value);
233  TableExprNode (const Array<Complex>& value);
234  TableExprNode (const Array<DComplex>& value);
235  TableExprNode (const Array<String>& value);
236  TableExprNode (const Array<MVTime>& value);
237  TableExprNode (const MArray<Bool>& value);
238  TableExprNode (const MArray<uChar>& value);
239  TableExprNode (const MArray<Short>& value);
240  TableExprNode (const MArray<uShort>& value);
241  TableExprNode (const MArray<Int>& value);
242  TableExprNode (const MArray<uInt>& value);
243  TableExprNode (const MArray<Int64>& value);
244  TableExprNode (const MArray<uInt64>& value);
245  TableExprNode (const MArray<Float>& value);
246  TableExprNode (const MArray<Double>& value);
247  TableExprNode (const MArray<Complex>& value);
248  TableExprNode (const MArray<DComplex>& value);
249  TableExprNode (const MArray<String>& value);
250  TableExprNode (const MArray<MVTime>& value);
251  // </group>
252 
253  // Construct a node from a node representation shared pointer
254  // which increments the reference count.
255  TableExprNode (const TENShPtr&);
256 
257  // Construct from a node representation. It takes over the pointer, so the
258  // object gets deleted automatically.
260  : node_p(TENShPtr(rep)) {}
261 
262  // copy constructor (reference semantics).
263  TableExprNode (const TableExprNode&);
264 
265  // Assignment (reference semantics).
267 
268  // The destructor deletes all the underlying TableExprNode objects,
269  ~TableExprNode ();
270 
271  // Does the node contain no actual node?
272  Bool isNull() const
273  { return !node_p; }
274 
275  // Do not apply the selection.
278 
279  // Re-create the column object for a selection of rows.
280  // Nothing is done if the node does not represent a column object.
281  void applySelection (const Vector<rownr_t>& rownrs)
282  { node_p->applySelection (rownrs); }
283 
284  // Get the unit of the expression.
285  const Unit& unit() const
286  { return node_p->unit(); }
287 
288  // Get the attributes of the expression.
289  const Record& attributes() const
290  { return node_p->attributes(); }
291 
292  // Get the data type of the expression.
293  // Currently the only possible values are TpBool, TpInt, TpDouble,
294  // TpDComplex, TpString, and TpOther.
295  // The latter is returned for a date or regex.
296  DataType dataType() const;
297 
298  // Is the expression a scalar?
299  Bool isScalar() const
300  { return (node_p->valueType() == TableExprNodeRep::VTScalar); }
301 
302  // Get the number of rows in the table associated with this expression.
303  // One is returned if the expression is a constant.
304  // Zero is returned if no table is associated with it.
305  rownr_t nrow() const
306  { return node_p->nrow(); }
307 
308  // Get a value for this node in the given row.
309  // These functions are implemented in the derived classes and
310  // will usually invoke the get in their children and apply the
311  // operator on the resulting values.
312  // <group>
313  void get (const TableExprId& id, Bool& value) const;
314  void get (const TableExprId& id, Int64& value) const;
315  void get (const TableExprId& id, Double& value) const;
316  void get (const TableExprId& id, DComplex& value) const;
317  void get (const TableExprId& id, String& value) const;
318  void get (const TableExprId& id, TaqlRegex& value) const;
319  void get (const TableExprId& id, MVTime& value) const;
320  void get (const TableExprId& id, MArray<Bool>& value) const;
321  void get (const TableExprId& id, MArray<Int64>& value) const;
322  void get (const TableExprId& id, MArray<Double>& value) const;
323  void get (const TableExprId& id, MArray<DComplex>& value) const;
324  void get (const TableExprId& id, MArray<String>& value) const;
325  void get (const TableExprId& id, MArray<MVTime>& value) const;
326  void get (const TableExprId& id, Array<Bool>& value) const;
327  void get (const TableExprId& id, Array<Int64>& value) const;
328  void get (const TableExprId& id, Array<Double>& value) const;
329  void get (const TableExprId& id, Array<DComplex>& value) const;
330  void get (const TableExprId& id, Array<String>& value) const;
331  void get (const TableExprId& id, Array<MVTime>& value) const;
332  Bool getBool (const TableExprId& id) const;
333  Int64 getInt (const TableExprId& id) const;
334  Double getDouble (const TableExprId& id) const;
335  DComplex getDComplex (const TableExprId& id) const;
336  MVTime getDate (const TableExprId& id) const;
337  String getString (const TableExprId& id) const;
338  Array<Bool> getArrayBool (const TableExprId& id) const;
339  Array<Int64> getArrayInt (const TableExprId& id) const;
340  Array<Double> getArrayDouble (const TableExprId& id) const;
341  Array<DComplex> getArrayDComplex (const TableExprId& id) const;
342  Array<String> getArrayString (const TableExprId& id) const;
343  Array<MVTime> getArrayDate (const TableExprId& id) const;
344  // Get a value as an array, even it it is a scalar.
345  // This is useful in case one can give an argument as scalar or array.
346  // <group>
347  MArray<Bool> getBoolAS (const TableExprId& id) const;
348  MArray<Int64> getIntAS (const TableExprId& id) const;
349  MArray<Double> getDoubleAS (const TableExprId& id) const;
350  MArray<DComplex> getDComplexAS (const TableExprId& id) const;
351  MArray<String> getStringAS (const TableExprId& id) const;
352  MArray<MVTime> getDateAS (const TableExprId& id) const;
353  // </group>
354 
355  // </group>
356 
357  // Get the data type for doing a getColumn on the expression.
358  // This is the data type of the column if the expression
359  // consists of a single column only.
360  // Otherwise it is the expression data type as returned by
361  // function <src>dataType</src>.
362  DataType getColumnDataType() const;
363 
364  // Get the value of the expression evaluated for the entire column.
365  // The data of function called should match the data type as
366  // returned by function <src>getColumnDataType</src>.
367  // <group>
368  Array<Bool> getColumnBool (const RowNumbers& rownrs) const;
369  Array<uChar> getColumnuChar (const RowNumbers& rownrs) const;
370  Array<Short> getColumnShort (const RowNumbers& rownrs) const;
371  Array<uShort> getColumnuShort (const RowNumbers& rownrs) const;
372  Array<Int> getColumnInt (const RowNumbers& rownrs) const;
373  Array<uInt> getColumnuInt (const RowNumbers& rownrs) const;
374  Array<Int64> getColumnInt64 (const RowNumbers& rownrs) const;
375  Array<Float> getColumnFloat (const RowNumbers& rownrs) const;
376  Array<Double> getColumnDouble (const RowNumbers& rownrs) const;
377  Array<Complex> getColumnComplex (const RowNumbers& rownrs) const;
378  Array<DComplex> getColumnDComplex (const RowNumbers& rownrs) const;
379  Array<String> getColumnString (const RowNumbers& rownrs) const;
380  // </group>
381 
382  // The same functions as above for the old Vector<uInt>.
383  // They are primarily meant for CASA's SplatalogueTable class.
384  // Normally they should not be used, hence declared private
385  // unless told otherwise.
386 #ifndef IMPLICIT_CTDS_32BIT
387 private:
388 #endif
389  // <group>
390  Array<Bool> getColumnBool (const Vector<uInt>& rownrs) const
391  { return getColumnBool (RowNumbers(rownrs)); }
393  { return getColumnuChar (RowNumbers(rownrs)); }
395  { return getColumnShort (RowNumbers(rownrs)); }
397  { return getColumnuShort (RowNumbers(rownrs)); }
398  Array<Int> getColumnInt (const Vector<uInt>& rownrs) const
399  { return getColumnInt (RowNumbers(rownrs)); }
400  Array<uInt> getColumnuInt (const Vector<uInt>& rownrs) const
401  { return getColumnuInt (RowNumbers(rownrs)); }
402  Array<Int64> getColumnInt64 (const Vector<uInt>& rownrs) const
403  { return getColumnInt64 (RowNumbers(rownrs)); }
405  { return getColumnFloat (RowNumbers(rownrs)); }
407  { return getColumnDouble (RowNumbers(rownrs)); }
409  { return getColumnComplex (RowNumbers(rownrs)); }
411  { return getColumnDComplex (RowNumbers(rownrs)); }
413  { return getColumnString (RowNumbers(rownrs)); }
414  // </group>
415 public:
416 
417  // Show the tree.
418  void show (ostream&) const;
419 
420  // Convert the tree to a number of range vectors which at least
421  // select the same things.
422  // This function is very useful to convert the expression to
423  // some intervals covering the select expression. This can
424  // be used to do a rough fast selection via an index and do the
425  // the slower final selection on that much smaller subset.
426  // The function can only convert direct comparisons of columns
427  // with constants (via ==, !=, >, >=, < or <=) and their combinations
428  // using && or ||.
430 
431  // Check if tables used in expression have the same number of
432  // rows as the given table.
433  Bool checkTableSize (const Table& table, Bool canBeConst) const;
434 
435  // Get table. This gets the Table object to which a
436  // TableExprNode belongs. A TableExprNode belongs to the Table to
437  // which the column(s) used in an expression belong. Note that
438  // all columns in an expression have to belong to the same table.
439  const Table& table() const;
440 
441  // Create a column node on behalf of the Table class.
442  // For builtin data types another type of node is created than
443  // for other data types.
444  static TableExprNode newColumnNode (const Table& tab,
445  const String& name,
446  const Vector<String>& fieldNames);
447 
448  // Create a TableExprNodeConst for a table keyword
449  // (which is handled as a constant).
450  static TableExprNode newKeyConst (const TableRecord&,
451  const Vector<String>& fieldNames);
452 
453  // Handle all field names except the last one. ALl of them must
454  // be records. The last record is returned.
455  // fullName is filled with the full keyword name separated by dots.
456  static TableRecord* findLastKeyRec (const TableRecord& keyset,
457  const Vector<String>& fieldNames,
458  String& fullName);
459 
460  // Throw invalid data type exception.
461  static void throwInvDT (const String& message);
462 
463  // Create function node of the given type with the given arguments.
464  // <group>
466  const TableExprNodeSet& set,
467  const Table& table,
468  const TaQLStyle& = TaQLStyle(0));
470  const TableExprNode& node);
472  const TableExprNode& node1,
473  const TableExprNode& node2);
475  const TableExprNode& node1,
476  const TableExprNode& node2,
477  const TableExprNode& node3);
479  const TableExprNode& array,
480  const TableExprNodeSet& axes);
482  const TableExprNode& array,
483  const TableExprNode& node,
484  const TableExprNodeSet& axes);
485  // </group>
486 
487  // Create a user defined function node.
488  static TableExprNode newUDFNode (const String& name,
489  const TableExprNodeSet& set,
490  const Table& table,
491  const TaQLStyle& = TaQLStyle(0));
492 
493  // Create cone function node of the given type with the given arguments.
494  // <group>
496  const TableExprNodeSet& set,
497  uInt origin = 0);
499  const TableExprNode& node1,
500  const TableExprNode& node2);
502  const TableExprNode& node1,
503  const TableExprNode& node2,
504  const TableExprNode& node3);
505  // </group>
506 
507  // Create rownumber() function node.
508  // Origin indicates whether the first row should be zero (for C++ binding)
509  // or an other value (one for TaQL binding).
510  static TableExprNode newRownrNode (const Table& table, uInt origin);
511 
512  // Create rowid() function node.
513  // Origin is always 0.
514  static TableExprNode newRowidNode (const Table& table);
515 
516  // Create rand() function node.
517  static TableExprNode newRandomNode (const Table& table);
518 
519  // Create ArrayElement node for the given array with the given index.
520  // The origin is 0 for C++ and 1 for TaQL.
521  static TableExprNode newArrayPartNode (const TableExprNode& arrayNode,
522  const TableExprNodeSet& indices,
523  const TaQLStyle& = TaQLStyle(0));
524 
525  // returns const pointer to the underlying TableExprNodeRep object.
526  const TENShPtr& getRep() const;
527  const TableExprNodeRep* getNodeRep() const;
528 
529  // Adapt the unit of the expression to the given unit (if not empty).
530  void adaptUnit (const Unit&);
531 
532  // Construct a new node for the given operation.
533  // <group>
534  TENShPtr newPlus (const TENShPtr& right) const;
535  TENShPtr newMinus (const TENShPtr& right) const;
536  TENShPtr newTimes (const TENShPtr& right) const;
537  TENShPtr newDivide (const TENShPtr& right) const;
538  TENShPtr newModulo (const TENShPtr& right) const;
539  TENShPtr newBitAnd (const TENShPtr& right) const;
540  TENShPtr newBitOr (const TENShPtr& right) const;
541  TENShPtr newBitXor (const TENShPtr& right) const;
542  TENShPtr newEQ (const TENShPtr& right) const;
543  TENShPtr newNE (const TENShPtr& right) const;
544  TENShPtr newGE (const TENShPtr& right) const;
545  TENShPtr newGT (const TENShPtr& right) const;
546  TENShPtr newIN (const TENShPtr& right, const TaQLStyle&) const;
547  TENShPtr newOR (const TENShPtr& right) const;
548  TENShPtr newAND (const TENShPtr& right) const;
549  // </group>
550 
551 private:
552  // Put the new binary node object in a shared pointer.
553  // Set the node's info and adapt the children if needed.
554  // If the node is constant, it is evaluated and returned as result.
556  const TENShPtr& right=TENShPtr()) const;
557 
558  // convert Block of TableExprNode to vector of TENShPtr.
559  static std::vector<TENShPtr> convertBlockTEN (Block<TableExprNode>& nodes);
560 
561  // The actual (counted referenced) representation of a node.
563 };
564 
565 
566 
568  { node_p->ranges (blrange); }
569 
570 //# Get the table from which the node is derived.
571 inline const Table& TableExprNode::table() const
572  { return node_p->table(); }
573 
574 //# Get the value of an expression.
575 inline void TableExprNode::get (const TableExprId& id, Bool& value) const
576  { value = node_p->getBool (id); }
577 inline void TableExprNode::get (const TableExprId& id, Int64& value) const
578  { value = node_p->getInt (id); }
579 inline void TableExprNode::get (const TableExprId& id, Double& value) const
580  { value = node_p->getDouble (id); }
581 inline void TableExprNode::get (const TableExprId& id, DComplex& value) const
582  { value = node_p->getDComplex (id); }
583 inline void TableExprNode::get (const TableExprId& id, String& value) const
584  { value = node_p->getString (id); }
585 inline void TableExprNode::get (const TableExprId& id, TaqlRegex& value) const
586  { value = node_p->getRegex (id); }
587 inline void TableExprNode::get (const TableExprId& id, MVTime& value) const
588  { value = node_p->getDate (id); }
589 inline void TableExprNode::get (const TableExprId& id,
590  MArray<Bool>& value) const
591  { value = node_p->getArrayBool (id); }
592 inline void TableExprNode::get (const TableExprId& id,
593  MArray<Int64>& value) const
594  { value = node_p->getArrayInt (id); }
595 inline void TableExprNode::get (const TableExprId& id,
596  MArray<Double>& value) const
597  { value = node_p->getArrayDouble (id); }
598 inline void TableExprNode::get (const TableExprId& id,
599  MArray<DComplex>& value) const
600  { value = node_p->getArrayDComplex (id); }
601 inline void TableExprNode::get (const TableExprId& id,
602  MArray<String>& value) const
603  { value = node_p->getArrayString (id); }
604 inline void TableExprNode::get (const TableExprId& id,
605  MArray<MVTime>& value) const
606  { value = node_p->getArrayDate (id); }
607 inline void TableExprNode::get (const TableExprId& id,
608  Array<Bool>& value) const
609  { value = node_p->getArrayBool (id).array(); }
610 inline void TableExprNode::get (const TableExprId& id,
611  Array<Int64>& value) const
612  { value = node_p->getArrayInt (id).array(); }
613 inline void TableExprNode::get (const TableExprId& id,
614  Array<Double>& value) const
615  { value = node_p->getArrayDouble (id).array(); }
616 inline void TableExprNode::get (const TableExprId& id,
617  Array<DComplex>& value) const
618  { value = node_p->getArrayDComplex (id).array(); }
619 inline void TableExprNode::get (const TableExprId& id,
620  Array<String>& value) const
621  { value = node_p->getArrayString (id).array(); }
622 inline void TableExprNode::get (const TableExprId& id,
623  Array<MVTime>& value) const
624  { value = node_p->getArrayDate (id).array(); }
625 inline Bool TableExprNode::getBool (const TableExprId& id) const
626  { return node_p->getBool (id); }
627 inline Int64 TableExprNode::getInt (const TableExprId& id) const
628  { return node_p->getInt (id); }
630  { return node_p->getDouble (id); }
632  { return node_p->getDComplex (id); }
633 inline MVTime TableExprNode::getDate (const TableExprId& id) const
634  { return node_p->getDate (id); }
636  { return node_p->getString (id); }
638  { return node_p->getArrayBool (id).array(); }
640  { return node_p->getArrayInt (id).array(); }
642  { return node_p->getArrayDouble (id).array(); }
644  { return node_p->getArrayDComplex (id).array(); }
646  { return node_p->getArrayString (id).array(); }
648  { return node_p->getArrayDate (id).array(); }
650  { return node_p->getBoolAS (id); }
652  { return node_p->getIntAS (id); }
654  { return node_p->getDoubleAS (id); }
656  { return node_p->getDComplexAS (id); }
658  { return node_p->getStringAS (id); }
660  { return node_p->getDateAS (id); }
661 
663  { return node_p->getColumnBool (rownrs); }
665  { return node_p->getColumnuChar (rownrs); }
667  { return node_p->getColumnShort (rownrs); }
669  { return node_p->getColumnuShort (rownrs); }
671  { return node_p->getColumnInt (rownrs); }
673  { return node_p->getColumnuInt (rownrs); }
675  { return node_p->getColumnInt64 (rownrs); }
677  { return node_p->getColumnFloat (rownrs); }
679  { return node_p->getColumnDouble (rownrs); }
681  { return node_p->getColumnComplex (rownrs); }
683  { return node_p->getColumnDComplex (rownrs); }
685  { return node_p->getColumnString (rownrs); }
686 
687 inline void TableExprNode::show (ostream& os) const
688  { node_p->show (os, 0); }
689 inline const TENShPtr& TableExprNode::getRep() const
690  { return node_p; }
692  { return node_p.get(); }
693 
694 
695 
696 // Define all global functions operating on a TableExprNode.
697 // <group name=GlobalTableExprNode>
698 
699  //# Define the operations we allow.
700  //# Note that the arguments are defined as const. This is necessary
701  //# because the compiler generates temporaries when converting a constant
702  //# to a TableExprNode using the constructors. Temporaries has to be const.
703  //# However, we have to delete created nodes, so lnode_p and rnode_p
704  //# cannot be const. The const arguments are casted to a non-const in
705  //# the function fill which calls the non-const function simplify.
706 
707  // Arithmetic operators for numeric TableExprNode's.
708  // <group>
709  // + is also defined for strings (means concatenation).
711  const TableExprNode& right);
713  const TableExprNode& right);
715  const TableExprNode& right);
717  const TableExprNode& right);
719  const TableExprNode& right);
721  const TableExprNode& right);
723  const TableExprNode& right);
725  const TableExprNode& right);
726  // </group>
727 
728  // Comparison operators.
729  // <group>
731  const TableExprNode& right);
733  const TableExprNode& right);
734  // Not defined for Bool.
735  // <group>
737  const TableExprNode& right);
739  const TableExprNode& right);
741  const TableExprNode& right);
743  const TableExprNode& right);
744  // </group>
745  // </group>
746 
747  // Logical operators to combine boolean TableExprNode's.
748  // A null TableExprNode object is ignored, so it is possible to
749  // build up a full expression gradually.
750  // <group>
752  const TableExprNode& right);
754  const TableExprNode& right);
755  // </group>
756 
757  // Functions to return whether a value is "relatively" near another.
758  // Returns <src> tol > abs(val2 - val1)/max(abs(val1),(val2))</src>.
759  // If tol <= 0, returns val1 == val2. If either val is 0.0, takes
760  // care of area around the minimum number that can be represented.
761  // <br>The nearAbs functions return whether a value is "absolutely" near
762  // another. Returns <src> tol > abs(val2 - val1)</src>.
763  // Default tolerance is 1.0e-13.
764  // They operate on scalars and arrays.
765  // <group>
766  TableExprNode near (const TableExprNode& left,
767  const TableExprNode& right);
768  TableExprNode near (const TableExprNode& left,
769  const TableExprNode& right,
770  const TableExprNode& tolerance);
771  TableExprNode nearAbs (const TableExprNode& left,
772  const TableExprNode& right);
773  TableExprNode nearAbs (const TableExprNode& left,
774  const TableExprNode& right,
775  const TableExprNode& tolerance);
776  // </group>
777 
778  // Angular distance between positions.
779  // Both arguments have to be arrays. If both arrays contain 2 values
780  // (ra and dec), the result is a scalar.
781  // Otherwise the arrays have to contain a multiple of 2 values and the
782  // result is a 2-dim array giving the distance of each position in the
783  // first array to each position in the second array.
784  TableExprNode angdist (const TableExprNode& pos1,
785  const TableExprNode& pos2);
786 
787  // Angular distance as above, but only pair-wise enties are used if
788  // both arguments are arrays.
789  TableExprNode angdistx (const TableExprNode& pos1,
790  const TableExprNode& pos2);
791 
792  // Cone search; test if the position of a source is inside a cone.
793  // <br>Argument <src>sourcePos</src> must be a double array
794  // containing two values (ra and dec of source) in radians.
795  // <br>Argument <src>cones</src> must be a double array
796  // specifying the position of the cone centers and radii in radians.
797  // So the array must contain three values (ra,dec,radius)
798  // or a multiple of it.
799  // <group>
800  // The result is a bool array telling for each cone if it contains the
801  // source. If there is only one cone, the result is a scalar.
802  TableExprNode cones (const TableExprNode& sourcePos,
803  const TableExprNode& cones);
804  // The result is always a Bool scalar telling if any cone contains
805  // the source.
806  TableExprNode anyCone (const TableExprNode& sourcePos,
807  const TableExprNode& cones);
808  // The sourcePos can contain multiple sources.
809  // The result is a double array giving the index of the first
810  // cone containing the corresponding source.
811  // If there is one source, the result is a double scalar.
812  TableExprNode findCone (const TableExprNode& sourcePos,
813  const TableExprNode& cones);
814  // </group>
815 
816  // Cone search as above.
817  // However, the cone positions and radii are specified separately
818  // and (virtually) a larger array containing every combination of
819  // position/radius is formed.
820  // <group>
821  TableExprNode cones (const TableExprNode& sourcePos,
822  const TableExprNode& conePos,
823  const TableExprNode& radii);
824  TableExprNode anyCone (const TableExprNode& sourcePos,
825  const TableExprNode& conePos,
826  const TableExprNode& radii);
827  TableExprNode findCone (const TableExprNode& sourcePos,
828  const TableExprNode& conePos,
829  const TableExprNode& radii);
830  // </group>
831 
832  // Transcendental functions that can be applied to essentially all numeric
833  // nodes containing scalars or arrays.
834  // <group>
835  TableExprNode sin (const TableExprNode& node);
836  TableExprNode sinh (const TableExprNode& node);
837  TableExprNode cos (const TableExprNode& node);
838  TableExprNode cosh (const TableExprNode& node);
839  TableExprNode exp (const TableExprNode& node);
840  TableExprNode log (const TableExprNode& node);
841  TableExprNode log10 (const TableExprNode& node);
842  TableExprNode pow (const TableExprNode& x, const TableExprNode& exp);
843  TableExprNode square (const TableExprNode& node);
844  TableExprNode cube (const TableExprNode& node);
845  TableExprNode sqrt (const TableExprNode& node);
846  TableExprNode norm (const TableExprNode& node);
847  // </group>
848 
849  // Transcendental functions applied to to nodes containing scalars or
850  // arrays with double values.
851  // They are invalid for Complex nodes.
852  // <group>
853  TableExprNode asin (const TableExprNode& node);
854  TableExprNode acos (const TableExprNode& node);
855  TableExprNode atan (const TableExprNode& node);
857  const TableExprNode& x);
858  TableExprNode tan (const TableExprNode& node);
859  TableExprNode tanh (const TableExprNode& node);
860  TableExprNode sign (const TableExprNode& node);
861  TableExprNode round (const TableExprNode& node);
862  TableExprNode ceil (const TableExprNode& node);
863  TableExprNode abs (const TableExprNode& node);
864  TableExprNode floor (const TableExprNode& node);
865  TableExprNode fmod (const TableExprNode& x,
866  const TableExprNode& y);
867  // </group>
868 
869  // String functions on scalars or arrays.
870  // <group>
871  TableExprNode strlength (const TableExprNode& node);
872  TableExprNode upcase (const TableExprNode& node);
873  TableExprNode downcase (const TableExprNode& node);
875  TableExprNode trim (const TableExprNode& node);
876  TableExprNode ltrim (const TableExprNode& node);
877  TableExprNode rtrim (const TableExprNode& node);
878  TableExprNode substr (const TableExprNode& str,
879  const TableExprNode& pos);
880  TableExprNode substr (const TableExprNode& str,
881  const TableExprNode& pos,
882  const TableExprNode& npos);
883  TableExprNode replace (const TableExprNode& str,
884  const TableExprNode& patt);
885  TableExprNode replace (const TableExprNode& str,
886  const TableExprNode& patt,
887  const TableExprNode& repl);
888  // </group>
889 
890  // Functions for regular expression matching and
891  // pattern matching. Defined for scalars and arrays.
892  // <br><src>pattern</src> is for a file name like pattern.
893  // <br><src>sqlpattern</src> is for an SQL like pattern.
894  // <group>
895  TableExprNode regex (const TableExprNode& node);
896  TableExprNode pattern (const TableExprNode& node);
897  TableExprNode sqlpattern (const TableExprNode& node);
898  // </group>
899 
900  // Functions for date-values. Defined for scalars and arrays.
901  //# Note, ctod is called ctodt, because Mac OS-X defines a macro
902  //# ctod in param.h
903  // <group>
904  TableExprNode datetime (const TableExprNode& node);
905  TableExprNode mjdtodate (const TableExprNode& node);
906  TableExprNode mjd (const TableExprNode& node);
907  TableExprNode date (const TableExprNode& node);
908  TableExprNode year (const TableExprNode& node);
909  TableExprNode month (const TableExprNode& node);
910  TableExprNode day (const TableExprNode& node);
911  TableExprNode cmonth (const TableExprNode& node);
912  TableExprNode weekday (const TableExprNode& node);
913  TableExprNode cdow (const TableExprNode& node);
914  TableExprNode ctodt (const TableExprNode& node);
915  TableExprNode cdate (const TableExprNode& node);
916  TableExprNode ctime (const TableExprNode& node);
917  TableExprNode week (const TableExprNode& node);
918  TableExprNode time (const TableExprNode& node);
919  // </group>
920 
921  // Functions for angle-values. Defined for scalars and arrays.
922  // dhms converts pairs of values to hms and dms and only works for arrays.
923  // <group>
924  TableExprNode hms (const TableExprNode& node);
925  TableExprNode dms (const TableExprNode& node);
926  TableExprNode hdms (const TableExprNode& node);
927  // </group>
928 
929  // Function to convert any value to a string.
930  // See TaQL note 199 for possible format values.
931  // <group>
932  TableExprNode toString (const TableExprNode& node);
933  TableExprNode toString (const TableExprNode& node,
934  const TableExprNode& format);
935  // </group>
936 
937  // Function to test if a scalar or array is NaN (not-a-number).
938  // It results in a Bool scalar or array.
939  TableExprNode isNaN (const TableExprNode& node);
940 
941  // Function to test if a scalar or array is finite.
942  // It results in a Bool scalar or array.
943  TableExprNode isFinite (const TableExprNode& node);
944 
945  // Minimum or maximum of 2 nodes.
946  // Makes sense for numeric and String values. For Complex values
947  // the norm is compared.
948  // One or both arguments can be scalar or array.
949  // <group>
950  TableExprNode min (const TableExprNode& a, const TableExprNode& b);
951  TableExprNode max (const TableExprNode& a, const TableExprNode& b);
952  // </group>
953 
954  // The complex conjugate of a complex node.
955  // Defined for scalars and arrays.
956  TableExprNode conj (const TableExprNode& node);
957 
958  // The real part of a complex node.
959  // Defined for scalars and arrays.
960  TableExprNode real (const TableExprNode& node);
961 
962  // The imaginary part of a complex node.
963  // Defined for scalars and arrays.
964  TableExprNode imag (const TableExprNode& node);
965 
966  // Convert double, bool, or string to int (using floor).
967  TableExprNode integer (const TableExprNode& node);
968 
969  // Convert numeric or string value to bool (0, no, false, - means false)
970  TableExprNode boolean (const TableExprNode& node);
971 
972  // The amplitude (i.e. sqrt(re*re + im*im)) of a complex node.
973  // This is a synonym for function abs.
974  // Defined for scalars and arrays.
975  TableExprNode amplitude (const TableExprNode& node);
976 
977  // The phase (i.e. atan2(im, re)) of a complex node.
978  // This is a synonym for function arg.
979  // Defined for scalars and arrays.
980  TableExprNode phase (const TableExprNode& node);
981 
982  // The arg (i.e. atan2(im, re)) of a complex node.
983  // Defined for scalars and arrays.
984  TableExprNode arg (const TableExprNode& node);
985 
986  // Form a complex number from two Doubles.
987  // One or both arguments can be scalar or array.
989  const TableExprNode& imag);
990  // Form a complex number from a string.
991  // Defined for scalars and arrays.
993 
994  // Functions operating on a Double or Complex scalar or array resulting in
995  // a scalar with the same data type.
996  // <group>
997  TableExprNode sum (const TableExprNode& array);
998  TableExprNode product (const TableExprNode& array);
999  TableExprNode sumSquare (const TableExprNode& array);
1000  // </group>
1001 
1002  // Functions operating on a Double scalar or array resulting in
1003  // a Double scalar.
1004  // <group>
1005  TableExprNode min (const TableExprNode& array);
1006  TableExprNode max (const TableExprNode& array);
1007  TableExprNode mean (const TableExprNode& array);
1008  TableExprNode variance (const TableExprNode& array);
1009  TableExprNode stddev (const TableExprNode& array);
1010  TableExprNode avdev (const TableExprNode& array);
1011  TableExprNode rms (const TableExprNode& array);
1012  TableExprNode median (const TableExprNode& array);
1013  TableExprNode fractile (const TableExprNode& array,
1014  const TableExprNode& fraction);
1015  // </group>
1016 
1017  // <group>
1018  TableExprNode any (const TableExprNode& array);
1019  TableExprNode all (const TableExprNode& array);
1020  TableExprNode ntrue (const TableExprNode& array);
1021  TableExprNode nfalse (const TableExprNode& array);
1022  // </group>
1023 
1024  // The partial version of the functions above.
1025  // They are applied to the array subsets defined by the axes in the set
1026  // using the partialXXX functions in ArrayMath.
1027  // The axes must be 0-relative.
1028  // <group>
1029  TableExprNode sums (const TableExprNode& array,
1030  const TableExprNodeSet& collapseAxes);
1031  TableExprNode products (const TableExprNode& array,
1032  const TableExprNodeSet& collapseAxes);
1033  TableExprNode sumSquares (const TableExprNode& array,
1034  const TableExprNodeSet& collapseAxes);
1035  TableExprNode mins (const TableExprNode& array,
1036  const TableExprNodeSet& collapseAxes);
1037  TableExprNode maxs (const TableExprNode& array,
1038  const TableExprNodeSet& collapseAxes);
1039  TableExprNode means (const TableExprNode& array,
1040  const TableExprNodeSet& collapseAxes);
1041  TableExprNode variances (const TableExprNode& array,
1042  const TableExprNodeSet& collapseAxes);
1043  TableExprNode stddevs (const TableExprNode& array,
1044  const TableExprNodeSet& collapseAxes);
1045  TableExprNode avdevs (const TableExprNode& array,
1046  const TableExprNodeSet& collapseAxes);
1047  TableExprNode rmss (const TableExprNode& array,
1048  const TableExprNodeSet& collapseAxes);
1049  TableExprNode medians (const TableExprNode& array,
1050  const TableExprNodeSet& collapseAxes);
1051  TableExprNode fractiles (const TableExprNode& array,
1052  const TableExprNode& fraction,
1053  const TableExprNodeSet& collapseAxes);
1054  TableExprNode anys (const TableExprNode& array,
1055  const TableExprNodeSet& collapseAxes);
1056  TableExprNode alls (const TableExprNode& array,
1057  const TableExprNodeSet& collapseAxes);
1058  TableExprNode ntrues (const TableExprNode& array,
1059  const TableExprNodeSet& collapseAxes);
1060  TableExprNode nfalses (const TableExprNode& array,
1061  const TableExprNodeSet& collapseAxes);
1062  // </group>
1063 
1064  // Functions operating for each element on a box around that element.
1065  // The elements at the edges (where no full box can be made) are set to 0.
1066  // <group>
1067  TableExprNode runningMin (const TableExprNode& array,
1068  const TableExprNodeSet& halfBoxWidth);
1069  TableExprNode runningMax (const TableExprNode& array,
1070  const TableExprNodeSet& halfBoxWidth);
1071  TableExprNode runningMean (const TableExprNode& array,
1072  const TableExprNodeSet& halfBoxWidth);
1074  const TableExprNodeSet& halfBoxWidth);
1076  const TableExprNodeSet& halfBoxWidth);
1078  const TableExprNodeSet& halfBoxWidth);
1079  TableExprNode runningRms (const TableExprNode& array,
1080  const TableExprNodeSet& halfBoxWidth);
1082  const TableExprNodeSet& halfBoxWidth);
1083  TableExprNode runningAny (const TableExprNode& array,
1084  const TableExprNodeSet& halfBoxWidth);
1085  TableExprNode runningAll (const TableExprNode& array,
1086  const TableExprNodeSet& halfBoxWidth);
1087  // </group>
1088 
1089  // Create an array of the given shape and fill it with the values.
1090  // The <src>values</src> array is rewound as needed.
1091  TableExprNode array (const TableExprNode& values,
1092  const TableExprNodeSet& shape);
1093 
1094  // Form a masked array.
1095  TableExprNode marray (const TableExprNode& array,
1096  const TableExprNode& mask);
1097 
1098  // Get the data array of a masked array.
1099  TableExprNode arrayData (const TableExprNode& array);
1100 
1101  // Flatten a masked array (get unmasked elements).
1102  TableExprNode arrayFlatten (const TableExprNode& array);
1103 
1104  // Get the mask of a masked array.
1105  // If the array has no mask, it return an array with all False values.
1106  TableExprNode arrayMask (const TableExprNode& array);
1107 
1108  // Get the diagonal of a (masked) array;
1109  // If the array is not a Matrix, it will take the diagonals of the
1110  // subarrays given by the two axes in the axes argument. Those
1111  // axes have to have the same length (thus each subarray is a Matrix).
1112  // If no axes are given, they default to the first two axes.
1113  // <br>The <src>diag</src> argument tells which diagonal to take.
1114  // 0 is the main diagonal, >0 is above main diagonal, <0 is below.
1115  TableExprNode diagonal (const TableExprNode& array);
1116  TableExprNode diagonal (const TableExprNode& array,
1117  const TableExprNode& firstAxis);
1118  TableExprNode diagonal (const TableExprNode& array,
1119  const TableExprNode& firstAxis,
1120  const TableExprNode& diag);
1121 
1122  // Transpose all axes of a (masked) array.
1123  TableExprNode transpose (const TableExprNode& array);
1124  // Transpose a (masked) array by making the given axes the first axes.
1125  TableExprNode transpose (const TableExprNode& array,
1126  const TableExprNode& axes);
1127 
1128  // Function operating on a field resulting in a bool scalar.
1129  // It can be used to test if a column has an array in the current row.
1130  // It can also be used to test if a record contains a field.
1131  TableExprNode isdefined (const TableExprNode& array);
1132 
1133  // Functions operating on any scalar or array resulting in a Double scalar.
1134  // A scalar has 1 element and dimensionality 0.
1135  // <group>
1136  TableExprNode nelements (const TableExprNode& array);
1137  TableExprNode ndim (const TableExprNode& array);
1138  // </group>
1139 
1140  // Function operating on any scalar or array resulting in a Double array
1141  // containing the shape. A scalar has shape [1].
1142  TableExprNode shape (const TableExprNode& array);
1143 
1144  // Function resembling the ternary <src>?:</src> construct in C++.
1145  // The argument "condition" has to be a Bool value.
1146  // If an element in "condition" is True, the corresponding element from
1147  // "arg1" is taken, otherwise it is taken from "arg2".
1148  // The arguments can be scalars or array or any combination.
1149  TableExprNode iif (const TableExprNode& condition,
1150  const TableExprNode& arg1,
1151  const TableExprNode& arg2);
1152 // </group>
1153 
1154 
1155 
1156 inline TableExprNode operator+ (const TableExprNode& left,
1157  const TableExprNode& right)
1158 {
1159  return left.newPlus (right.getRep());
1160 }
1162  const TableExprNode& right)
1163 {
1164  return left.newMinus (right.getRep());
1165 }
1167  const TableExprNode& right)
1168 {
1169  return left.newTimes (right.getRep());
1170 }
1172  const TableExprNode& right)
1173 {
1174  return left.newDivide (right.getRep());
1175 }
1177  const TableExprNode& right)
1178 {
1179  return left.newModulo (right.getRep());
1180 }
1182  const TableExprNode& right)
1183 {
1184  return left.newBitAnd (right.getRep());
1185 }
1187  const TableExprNode& right)
1188 {
1189  return left.newBitOr (right.getRep());
1190 }
1192  const TableExprNode& right)
1193 {
1194  return left.newBitXor (right.getRep());
1195 }
1197  const TableExprNode& right)
1198 {
1199  return left.newEQ (right.getRep());
1200 }
1202  const TableExprNode& right)
1203 {
1204  return left.newNE (right.getRep());
1205 }
1207  const TableExprNode& right)
1208 {
1209  return left.newGT (right.getRep());
1210 }
1212  const TableExprNode& right)
1213 {
1214  return left.newGE (right.getRep());
1215 }
1217  const TableExprNode& right)
1218 {
1219  return right.newGE (left.getRep());
1220 }
1222  const TableExprNode& right)
1223 {
1224  return right.newGT (left.getRep());
1225 }
1227  const TaQLStyle& style) const
1228 {
1229  return newIN (right.getRep(), style);
1230 }
1232 {
1233  // C++ indexing is 0-based.
1234  return newArrayPartNode (*this, indices, TaQLStyle(0));
1235 }
1236 
1237 inline TableExprNode near (const TableExprNode& left,
1238  const TableExprNode& right)
1239 {
1241  left, right);
1242 }
1243 inline TableExprNode near (const TableExprNode& left,
1244  const TableExprNode& right,
1245  const TableExprNode& tolerance)
1246 {
1248  left, right, tolerance);
1249 }
1251  const TableExprNode& right)
1252 {
1254  left, right);
1255 }
1257  const TableExprNode& right,
1258  const TableExprNode& tolerance)
1259 {
1261  left, right, tolerance);
1262 }
1264  const TableExprNode& pos2)
1265 {
1267  pos1, pos2);
1268 }
1270  const TableExprNode& pos2)
1271 {
1273  pos1, pos2);
1274 }
1275 inline TableExprNode cones (const TableExprNode& sourcePos,
1276  const TableExprNode& cones)
1277 {
1279  sourcePos, cones);
1280 }
1281 inline TableExprNode anyCone (const TableExprNode& sourcePos,
1282  const TableExprNode& cones)
1283 {
1285  sourcePos, cones);
1286 }
1287 inline TableExprNode findCone (const TableExprNode& sourcePos,
1288  const TableExprNode& cones)
1289 {
1291  sourcePos, cones);
1292 }
1293 inline TableExprNode cones (const TableExprNode& sourcePos,
1294  const TableExprNode& conePos,
1295  const TableExprNode& radii)
1296 {
1298  sourcePos, conePos, radii);
1299 }
1300 inline TableExprNode anyCone (const TableExprNode& sourcePos,
1301  const TableExprNode& conePos,
1302  const TableExprNode& radii)
1303 {
1305  sourcePos, conePos, radii);
1306 }
1307 inline TableExprNode findCone (const TableExprNode& sourcePos,
1308  const TableExprNode& conePos,
1309  const TableExprNode& radii)
1310 {
1312  sourcePos, conePos, radii);
1313 }
1314 inline TableExprNode cos (const TableExprNode& node)
1315 {
1317 }
1318 inline TableExprNode cosh (const TableExprNode& node)
1319 {
1321 }
1322 inline TableExprNode exp (const TableExprNode& node)
1323 {
1325 }
1326 inline TableExprNode log (const TableExprNode& node)
1327 {
1329 }
1330 inline TableExprNode log10 (const TableExprNode& node)
1331 {
1333 }
1334 inline TableExprNode pow (const TableExprNode& x, const TableExprNode& y)
1335 {
1337 }
1338 inline TableExprNode sin (const TableExprNode& node)
1339 {
1341 }
1342 inline TableExprNode sinh (const TableExprNode& node)
1343 {
1345 }
1346 inline TableExprNode square (const TableExprNode& node)
1347 {
1349  node);
1350 }
1351 inline TableExprNode cube (const TableExprNode& node)
1352 {
1354  node);
1355 }
1356 inline TableExprNode sqrt (const TableExprNode& node)
1357 {
1359 }
1360 inline TableExprNode norm (const TableExprNode& node)
1361 {
1363 }
1364 inline TableExprNode acos (const TableExprNode& node)
1365 {
1367 }
1368 inline TableExprNode asin (const TableExprNode& node)
1369 {
1371 }
1372 inline TableExprNode atan (const TableExprNode& node)
1373 {
1375 }
1376 inline TableExprNode atan2 (const TableExprNode& y, const TableExprNode& x)
1377 {
1379 }
1380 inline TableExprNode sign (const TableExprNode& node)
1381 {
1383 }
1384 inline TableExprNode round (const TableExprNode& node)
1385 {
1387 }
1388 inline TableExprNode ceil (const TableExprNode& node)
1389 {
1391 }
1392 inline TableExprNode abs (const TableExprNode& node)
1393 {
1395 }
1396 inline TableExprNode floor (const TableExprNode& node)
1397 {
1399 }
1400 inline TableExprNode fmod (const TableExprNode& x, const TableExprNode& y)
1401 {
1403 }
1404 inline TableExprNode tan (const TableExprNode& node)
1405 {
1407 }
1408 inline TableExprNode tanh (const TableExprNode& node)
1409 {
1411 }
1412 inline TableExprNode min (const TableExprNode& a, const TableExprNode& b)
1413 {
1415 }
1416 inline TableExprNode max (const TableExprNode& a, const TableExprNode& b)
1417 {
1419 }
1420 inline TableExprNode real (const TableExprNode& node)
1421 {
1423 }
1424 inline TableExprNode imag (const TableExprNode& node)
1425 {
1427 }
1429 {
1431 }
1433 {
1435 }
1436 inline TableExprNode conj (const TableExprNode& node)
1437 {
1439 }
1441 {
1443 }
1444 inline TableExprNode arg (const TableExprNode& node)
1445 {
1447 }
1448 inline TableExprNode phase (const TableExprNode& node)
1449 {
1451 }
1453  const TableExprNode& imag)
1454 {
1456  real, imag);
1457 }
1459 {
1461  node);
1462 }
1464 {
1466  node);
1467 }
1468 inline TableExprNode upcase (const TableExprNode& node)
1469 {
1471  node);
1472 }
1474 {
1476  node);
1477 }
1479 {
1481  node);
1482 }
1483 inline TableExprNode regex (const TableExprNode& node)
1484 {
1486 }
1488 {
1490  node);
1491 }
1493 {
1495  node);
1496 }
1498 {
1500  node);
1501 }
1503 {
1505  node);
1506 }
1507 inline TableExprNode mjd (const TableExprNode& node)
1508 {
1510 }
1511 inline TableExprNode date (const TableExprNode& node)
1512 {
1514 }
1515 inline TableExprNode year (const TableExprNode& node)
1516 {
1518 }
1519 inline TableExprNode month (const TableExprNode& node)
1520 {
1522 }
1523 inline TableExprNode day (const TableExprNode& node)
1524 {
1526 }
1527 inline TableExprNode cmonth (const TableExprNode& node)
1528 {
1530  node);
1531 }
1533 {
1535  node);
1536 }
1537 inline TableExprNode cdow (const TableExprNode& node)
1538 {
1540 }
1541 inline TableExprNode ctodt (const TableExprNode& node)
1542 {
1544 }
1545 inline TableExprNode cdate (const TableExprNode& node)
1546 {
1548 }
1549 inline TableExprNode ctime (const TableExprNode& node)
1550 {
1552 }
1553 inline TableExprNode hms (const TableExprNode& node)
1554 {
1556 }
1557 inline TableExprNode dms (const TableExprNode& node)
1558 {
1560 }
1561 inline TableExprNode hdms (const TableExprNode& node)
1562 {
1564 }
1566 {
1568  node);
1569 }
1571  const TableExprNode& format)
1572 {
1574  node, format);
1575 }
1576 inline TableExprNode week (const TableExprNode& node)
1577 {
1579 }
1580 inline TableExprNode time (const TableExprNode& node)
1581 {
1583 }
1584 inline TableExprNode trim (const TableExprNode& node)
1585 {
1587 }
1588 inline TableExprNode ltrim (const TableExprNode& node)
1589 {
1591 }
1592 inline TableExprNode rtrim (const TableExprNode& node)
1593 {
1595 }
1596 inline TableExprNode substr (const TableExprNode& node,
1597  const TableExprNode& pos)
1598 {
1600  node, pos);
1601 }
1602 inline TableExprNode substr (const TableExprNode& node,
1603  const TableExprNode& pos,
1604  const TableExprNode& npos)
1605 {
1607  node, pos, npos);
1608 }
1610  const TableExprNode& patt)
1611 {
1613  node, patt);
1614 }
1616  const TableExprNode& patt,
1617  const TableExprNode& repl)
1618 {
1620  node, patt, repl);
1621 }
1622 inline TableExprNode isNaN (const TableExprNode& node)
1623 {
1625 }
1626 inline TableExprNode isInf (const TableExprNode& node)
1627 {
1629 }
1631 {
1633  node);
1634 }
1635 inline TableExprNode min (const TableExprNode& node)
1636 {
1638  node);
1639 }
1640 inline TableExprNode max (const TableExprNode& node)
1641 {
1643  node);
1644 }
1645 inline TableExprNode sum (const TableExprNode& node)
1646 {
1648  node);
1649 }
1651 {
1653  node);
1654 }
1656 {
1658  node);
1659 }
1660 inline TableExprNode mean (const TableExprNode& node)
1661 {
1663  node);
1664 }
1666 {
1668  node);
1669 }
1670 inline TableExprNode stddev (const TableExprNode& node)
1671 {
1673  node);
1674 }
1675 inline TableExprNode avdev (const TableExprNode& node)
1676 {
1678  node);
1679 }
1680 inline TableExprNode rms (const TableExprNode& node)
1681 {
1683  node);
1684 }
1685 inline TableExprNode median (const TableExprNode& node)
1686 {
1688  node);
1689 }
1691  const TableExprNode& fraction)
1692 {
1694  node, fraction);
1695 }
1696 inline TableExprNode any (const TableExprNode& node)
1697 {
1699 }
1700 inline TableExprNode all (const TableExprNode& node)
1701 {
1703 }
1704 inline TableExprNode ntrue (const TableExprNode& node)
1705 {
1707 }
1708 inline TableExprNode nfalse (const TableExprNode& node)
1709 {
1711 }
1712 inline TableExprNode sums (const TableExprNode& array,
1713  const TableExprNodeSet& axes)
1714 {
1716  array, axes);
1717 }
1718 inline TableExprNode products (const TableExprNode& array,
1719  const TableExprNodeSet& axes)
1720 {
1722  array, axes);
1723 }
1725  const TableExprNodeSet& axes)
1726 {
1728  array, axes);
1729 }
1730 inline TableExprNode mins (const TableExprNode& array,
1731  const TableExprNodeSet& axes)
1732 {
1734  array, axes);
1735 }
1736 inline TableExprNode maxs (const TableExprNode& array,
1737  const TableExprNodeSet& axes)
1738 {
1740  array, axes);
1741 }
1742 inline TableExprNode means (const TableExprNode& array,
1743  const TableExprNodeSet& axes)
1744 {
1746  array, axes);
1747 }
1749  const TableExprNodeSet& axes)
1750 {
1752  array, axes);
1753 }
1754 inline TableExprNode stddevs (const TableExprNode& array,
1755  const TableExprNodeSet& axes)
1756 {
1758  array, axes);
1759 }
1760 inline TableExprNode avdevs (const TableExprNode& array,
1761  const TableExprNodeSet& axes)
1762 {
1764  array, axes);
1765 }
1766 inline TableExprNode rmss (const TableExprNode& array,
1767  const TableExprNodeSet& axes)
1768 {
1770  array, axes);
1771 }
1772 inline TableExprNode medians (const TableExprNode& array,
1773  const TableExprNodeSet& axes)
1774 {
1776  array, axes);
1777 }
1779  const TableExprNode& fraction,
1780  const TableExprNodeSet& axes)
1781 {
1783  array, fraction, axes);
1784 }
1785 inline TableExprNode anys (const TableExprNode& array,
1786  const TableExprNodeSet& axes)
1787 {
1789  array, axes);
1790 }
1791 inline TableExprNode alls (const TableExprNode& array,
1792  const TableExprNodeSet& axes)
1793 {
1795  array, axes);
1796 }
1797 inline TableExprNode ntrues (const TableExprNode& array,
1798  const TableExprNodeSet& axes)
1799 {
1801  array, axes);
1802 }
1803 inline TableExprNode nfalses (const TableExprNode& array,
1804  const TableExprNodeSet& axes)
1805 {
1807  array, axes);
1808 }
1810  const TableExprNodeSet& halfBoxWidth)
1811 {
1813  node, halfBoxWidth);
1814 }
1816  const TableExprNodeSet& halfBoxWidth)
1817 {
1819  node, halfBoxWidth);
1820 }
1822  const TableExprNodeSet& halfBoxWidth)
1823 {
1825  node, halfBoxWidth);
1826 }
1828  const TableExprNodeSet& halfBoxWidth)
1829 {
1831  node, halfBoxWidth);
1832 }
1834  const TableExprNodeSet& halfBoxWidth)
1835 {
1837  node, halfBoxWidth);
1838 }
1840  const TableExprNodeSet& halfBoxWidth)
1841 {
1843  node, halfBoxWidth);
1844 }
1846  const TableExprNodeSet& halfBoxWidth)
1847 {
1849  node, halfBoxWidth);
1850 }
1852  const TableExprNodeSet& halfBoxWidth)
1853 {
1855  node, halfBoxWidth);
1856 }
1858  const TableExprNodeSet& halfBoxWidth)
1859 {
1861  node, halfBoxWidth);
1862 }
1864  const TableExprNodeSet& halfBoxWidth)
1865 {
1867  node, halfBoxWidth);
1868 }
1870  const TableExprNodeSet& halfBoxWidth)
1871 {
1873  node, halfBoxWidth);
1874 }
1876  const TableExprNodeSet& halfBoxWidth)
1877 {
1879  node, halfBoxWidth);
1880 }
1882  const TableExprNodeSet& halfBoxWidth)
1883 {
1885  node, halfBoxWidth);
1886 }
1888  const TableExprNodeSet& halfBoxWidth)
1889 {
1891  node, halfBoxWidth);
1892 }
1894  const TableExprNodeSet& halfBoxWidth)
1895 {
1897  node, halfBoxWidth);
1898 }
1900  const TableExprNodeSet& halfBoxWidth)
1901 {
1903  node, halfBoxWidth);
1904 }
1906  const TableExprNodeSet& halfBoxWidth)
1907 {
1909  node, halfBoxWidth);
1910 }
1912  const TableExprNodeSet& halfBoxWidth)
1913 {
1915  node, halfBoxWidth);
1916 }
1918  const TableExprNodeSet& halfBoxWidth)
1919 {
1921  node, halfBoxWidth);
1922 }
1924  const TableExprNodeSet& halfBoxWidth)
1925 {
1927  node, halfBoxWidth);
1928 }
1929 inline TableExprNode array (const TableExprNode& values,
1930  const TableExprNodeSet& shape)
1931 {
1933  values, shape);
1934 }
1935 inline TableExprNode marray (const TableExprNode& array,
1936  const TableExprNode& mask)
1937 {
1939  array, mask);
1940 }
1942 {
1944  array);
1945 }
1947 {
1949  array);
1950 }
1952 {
1954  array);
1955 }
1957 {
1958  // Needs an empty axes argument.
1960  array,
1962 }
1964  const TableExprNodeSet& axes)
1965 {
1967  array, axes);
1968 }
1969 inline TableExprNode diagonal (const TableExprNode& array)
1970 {
1972  array,
1974 }
1976 {
1978 }
1980 {
1982 }
1983 inline TableExprNode ndim (const TableExprNode& node)
1984 {
1986 }
1987 inline TableExprNode shape (const TableExprNode& node)
1988 {
1990 }
1991 inline TableExprNode iif (const TableExprNode& condition,
1992  const TableExprNode& arg1,
1993  const TableExprNode& arg2)
1994 {
1996  condition, arg1, arg2);
1997 }
1998 
1999 
2000 
2001 } //# NAMESPACE CASACORE - END
2002 
2003 #endif
Array< uShort > getColumnuShort(const RowNumbers &rownrs) const
Definition: ExprNode.h:668
LatticeExprNode log10(const LatticeExprNode &expr)
CountedPtr< TableExprNodeRep > TENShPtr
Definition: ExprNodeRep.h:56
long long Int64
Define the extra non-standard types used by Casacore (like proposed uSize, Size)
Definition: aipsxtype.h:38
TableExprNode dms(const TableExprNode &node)
Definition: ExprNode.h:1557
Class to handle an Array with an optional mask.
Definition: ExprNode.h:57
MArray< Double > getDoubleAS(const TableExprId &id)
TableExprNode boxedStddev(const TableExprNode &node, const TableExprNodeSet &halfBoxWidth)
Definition: ExprNode.h:1893
TableExprNode anyCone(const TableExprNode &sourcePos, const TableExprNode &cones)
The result is always a Bool scalar telling if any cone contains the source.
Definition: ExprNode.h:1281
int Int
Definition: aipstype.h:50
Array< Int > getColumnInt(const Vector< uInt > &rownrs) const
Definition: ExprNode.h:398
TableExprNode transpose(const TableExprNode &array)
Transpose all axes of a (masked) array.
Definition: ExprNode.h:1956
return angles as dms strings
Definition: ExprFuncNode.h:265
TableExprNode alls(const TableExprNode &array, const TableExprNodeSet &collapseAxes)
Definition: ExprNode.h:1791
LatticeExprNode log(const LatticeExprNode &expr)
Array< MVTime > getArrayDate(const TableExprId &id) const
Definition: ExprNode.h:647
TableExprNode useUnit(const Unit &unit) const
Use a unit for the given TableExprNode.
TENShPtr newIN(const TENShPtr &right, const TaQLStyle &) const
TENShPtr newTimes(const TENShPtr &right) const
LatticeExprNode arg(const LatticeExprNode &expr)
TableExprNode means(const TableExprNode &array, const TableExprNodeSet &collapseAxes)
Definition: ExprNode.h:1742
TableExprNode runningRms(const TableExprNode &array, const TableExprNodeSet &halfBoxWidth)
Definition: ExprNode.h:1845
Array< Short > getColumnShort(const RowNumbers &rownrs) const
Definition: ExprNode.h:666
TableExprNode downcase(const TableExprNode &node)
Definition: ExprNode.h:1473
LatticeExprNode median(const LatticeExprNode &expr)
MArray< Double > getDoubleAS(const TableExprId &id) const
Definition: ExprNode.h:653
for Int, Double or Complex returning Double or Complex
Definition: ExprFuncNode.h:119
String getString(const TableExprId &id) const
Definition: ExprNode.h:635
TableExprNode time(const TableExprNode &node)
Definition: ExprNode.h:1580
for any array returning Bool scalar
Definition: ExprFuncNode.h:221
TENShPtr newModulo(const TENShPtr &right) const
virtual Array< Int > getColumnInt(const Vector< rownr_t > &rownrs)
Main interface class to a read/write table.
Definition: Table.h:157
LatticeExprNode operator/(const LatticeExprNode &left, const LatticeExprNode &right)
TableExprNode runningVariance(const TableExprNode &array, const TableExprNodeSet &halfBoxWidth)
Definition: ExprNode.h:1827
LatticeExprNode mask(const LatticeExprNode &expr)
This function returns the mask of the given expression.
DComplex getDComplex(const TableExprId &id) const
Definition: ExprNode.h:631
cone search functions, implemented in derived class
Definition: ExprFuncNode.h:280
T product(const TableVector< T > &tv)
Definition: TabVecMath.h:385
LatticeExprNode imag(const LatticeExprNode &expr)
TableExprNode variances(const TableExprNode &array, const TableExprNodeSet &collapseAxes)
Definition: ExprNode.h:1748
const Record & attributes() const
Get the attributes.
Definition: ExprNodeRep.h:734
virtual Array< Bool > getColumnBool(const Vector< rownr_t > &rownrs)
Get the value of the expression evaluated for the entire column.
for Bool array returning Int scalar
Definition: ExprFuncNode.h:202
MArray< String > getStringAS(const TableExprId &id)
virtual Array< Short > getColumnShort(const Vector< rownr_t > &rownrs)
virtual MArray< Bool > getArrayBool(const TableExprId &id)
Get an array value for this node in the given row.
TableExprNode array(const TableExprNode &values, const TableExprNodeSet &shape)
Create an array of the given shape and fill it with the values.
Definition: ExprNode.h:1929
Class to hold multiple table expression nodes.
Definition: ExprNodeSet.h:310
LatticeExprNode sum(const LatticeExprNode &expr)
TableExprNode(TableExprNodeRep *rep)
Construct from a node representation.
Definition: ExprNode.h:259
LatticeExprNode max(const LatticeExprNode &left, const LatticeExprNode &right)
TableExprNode weekday(const TableExprNode &node)
Definition: ExprNode.h:1532
Handle class for a table column expression tree.
Definition: ExprNode.h:156
LatticeExprNode operator%(const LatticeExprNode &left, const LatticeExprNode &right)
virtual Array< DComplex > getColumnDComplex(const Vector< rownr_t > &rownrs)
Double getDouble(const TableExprId &id) const
Definition: ExprNode.h:629
virtual MArray< MVTime > getArrayDate(const TableExprId &id)
TableExprNode runningAll(const TableExprNode &array, const TableExprNodeSet &halfBoxWidth)
Definition: ExprNode.h:1863
unsigned long long uInt64
Definition: aipsxtype.h:39
TableExprNode phase(const TableExprNode &node)
The phase (i.e.
Definition: ExprNode.h:1448
TENShPtr newMinus(const TENShPtr &right) const
virtual MVTime getDate(const TableExprId &id)
TableExprNode operator+() const
Unary operators on numeric TableExprNode&#39;s.
virtual void show(ostream &, uInt indent) const
Show the expression tree.
TableExprNode ltrim(const TableExprNode &node)
Definition: ExprNode.h:1588
static TableExprNode newRandomNode(const Table &table)
Create rand() function node.
Bool near(const GaussianBeam &left, const GaussianBeam &other, const Double relWidthTol, const Quantity &absPaTol)
virtual Array< Float > getColumnFloat(const Vector< rownr_t > &rownrs)
Array< Int64 > getColumnInt64(const RowNumbers &rownrs) const
Definition: ExprNode.h:674
for Int, Double, Complex or String returning Bool
Definition: ExprFuncNode.h:289
LatticeExprNode ntrue(const LatticeExprNode &expr)
virtual Int64 getInt(const TableExprId &id)
for Int, Double or DComplex returning Double
Definition: ExprFuncNode.h:111
Bool getBool(const TableExprId &id) const
Definition: ExprNode.h:625
DataType dataType() const
Get the data type of the expression.
const Table & table() const
Get table.
Definition: ExprNode.h:571
virtual void applySelection(const Vector< rownr_t > &rownrs)
Re-create the column object for a selection of rows.
TableExprNode mins(const TableExprNode &array, const TableExprNodeSet &collapseAxes)
Definition: ExprNode.h:1730
LatticeExprNode fractile(const LatticeExprNode &expr, const LatticeExprNode &fraction)
Determine the value of the element at the part fraction from the beginning of the given lattice...
void adaptUnit(const Unit &)
Adapt the unit of the expression to the given unit (if not empty).
TableExprNode maxs(const TableExprNode &array, const TableExprNodeSet &collapseAxes)
Definition: ExprNode.h:1736
angular distance returning radians
Definition: ExprFuncNode.h:277
TableExprNode year(const TableExprNode &node)
Definition: ExprNode.h:1515
MArray< Int64 > getIntAS(const TableExprId &id)
TableExprNode operator&(const TableExprNode &left, const TableExprNode &right)
Definition: ExprNode.h:1181
static TableExprNode newFunctionNode(TableExprFuncNode::FunctionType, const TableExprNodeSet &set, const Table &table, const TaQLStyle &=TaQLStyle(0))
Create function node of the given type with the given arguments.
LatticeExprNode exp(const LatticeExprNode &expr)
TableExprNode mjd(const TableExprNode &node)
Definition: ExprNode.h:1507
TENShPtr newAND(const TENShPtr &right) const
bool operator==(const casacore_allocator< T, ALIGNMENT > &, const casacore_allocator< T, ALIGNMENT > &)
Definition: Allocator.h:129
TENShPtr newOR(const TENShPtr &right) const
TableExprNode month(const TableExprNode &node)
Definition: ExprNode.h:1519
Abstract base class for a node in a table column expression tree.
Definition: ExprNodeRep.h:157
Array< Double > getArrayDouble(const TableExprId &id) const
Definition: ExprNode.h:641
MArray< MVTime > getDateAS(const TableExprId &id)
static TableExprNode newKeyConst(const TableRecord &, const Vector< String > &fieldNames)
Create a TableExprNodeConst for a table keyword (which is handled as a constant). ...
TableExprNode boxedAvdev(const TableExprNode &node, const TableExprNodeSet &halfBoxWidth)
Definition: ExprNode.h:1899
TableExprNode marray(const TableExprNode &array, const TableExprNode &mask)
Form a masked array.
Definition: ExprNode.h:1935
MArray< MVTime > getDateAS(const TableExprId &id) const
Definition: ExprNode.h:659
TableExprNode runningMax(const TableExprNode &array, const TableExprNodeSet &halfBoxWidth)
Definition: ExprNode.h:1815
TableExprNode strlength(const TableExprNode &node)
String functions on scalars or arrays.
Definition: ExprNode.h:1463
LatticeExprNode any(const LatticeExprNode &expr)
Functions operating on a logical expression resulting in a scalar; Functions &quot;any&quot; (are any pixels &quot;T...
TableExprNode boxedMedian(const TableExprNode &node, const TableExprNodeSet &halfBoxWidth)
Definition: ExprNode.h:1911
LatticeExprNode floor(const LatticeExprNode &expr)
TableExprNode arrayMask(const TableExprNode &array)
Get the mask of a masked array.
Definition: ExprNode.h:1946
TableExprNode cones(const TableExprNode &sourcePos, const TableExprNode &cones)
Cone search; test if the position of a source is inside a cone.
Definition: ExprNode.h:1275
TableExprNode boolean(const TableExprNode &node)
Convert numeric or string value to bool (0, no, false, - means false)
Definition: ExprNode.h:1432
static TableExprNode newRowidNode(const Table &table)
Create rowid() function node.
LatticeExprNode cos(const LatticeExprNode &expr)
DataType getColumnDataType() const
Get the data type for doing a getColumn on the expression.
void get(const TableExprId &id, Bool &value) const
Get a value for this node in the given row.
Definition: ExprNode.h:575
for any array returning Int scalar
Definition: ExprFuncNode.h:226
for any array returning Int array
Definition: ExprFuncNode.h:229
for Int, Double, Bool or String returning Int (using floor)
Definition: ExprFuncNode.h:117
TableExprNode rtrim(const TableExprNode &node)
Definition: ExprNode.h:1592
TableExprNode pattern(const TableExprNode &node)
Definition: ExprNode.h:1487
Array< Complex > getColumnComplex(const RowNumbers &rownrs) const
Definition: ExprNode.h:680
LatticeExprNode operator>=(const LatticeExprNode &left, const LatticeExprNode &right)
Array< DComplex > getColumnDComplex(const Vector< uInt > &rownrs) const
Definition: ExprNode.h:410
void ranges(Block< TableExprRange > &)
Convert the tree to a number of range vectors which at least select the same things.
Definition: ExprNode.h:567
TENShPtr node_p
The actual (counted referenced) representation of a node.
Definition: ExprNode.h:562
virtual Array< Complex > getColumnComplex(const Vector< rownr_t > &rownrs)
const TableExprNodeRep * getNodeRep() const
Definition: ExprNode.h:691
defines physical units
Definition: Unit.h:189
LatticeExprNode conj(const LatticeExprNode &expr)
virtual MArray< Double > getArrayDouble(const TableExprId &id)
void show(ostream &) const
Show the tree.
Definition: ExprNode.h:687
Array< Int64 > getArrayInt(const TableExprId &id) const
Definition: ExprNode.h:639
virtual Double getDouble(const TableExprId &id)
~TableExprNode()
The destructor deletes all the underlying TableExprNode objects,.
for any type returning array of that type
Definition: ExprFuncNode.h:211
for Int, Double or DComplex returning Int, Double or Complex
Definition: ExprFuncNode.h:103
TableExprNode & operator=(const TableExprNode &)
Assignment (reference semantics).
LatticeExprNode nfalse(const LatticeExprNode &expr)
Array< Bool > getColumnBool(const Vector< uInt > &rownrs) const
The same functions as above for the old Vector&lt;uInt&gt;.
Definition: ExprNode.h:390
MVTime getDate(const TableExprId &id) const
Definition: ExprNode.h:633
void disableApplySelection()
Do not apply the selection.
Definition: ExprNode.h:276
Array< String > getArrayString(const TableExprId &id) const
Definition: ExprNode.h:645
special function resembling if statement
Definition: ExprFuncNode.h:275
for Double or DComplex returning Double
Definition: ExprFuncNode.h:115
TableExprNode medians(const TableExprNode &array, const TableExprNodeSet &collapseAxes)
Definition: ExprNode.h:1772
TableExprNode sumSquares(const TableExprNode &array, const TableExprNodeSet &collapseAxes)
Definition: ExprNode.h:1724
TableExprNode operator~() const
Unary bitwise negate-operator on integer TableExprNode&#39;s.
TENShPtr newBitOr(const TENShPtr &right) const
LatticeExprNode tanh(const LatticeExprNode &expr)
TableExprNode ntrues(const TableExprNode &array, const TableExprNodeSet &collapseAxes)
Definition: ExprNode.h:1797
virtual Array< String > getColumnString(const Vector< rownr_t > &rownrs)
for Int, Double or DComplex array returning Bool
Definition: ExprFuncNode.h:217
virtual MArray< DComplex > getArrayDComplex(const TableExprId &id)
TableExprNode fractiles(const TableExprNode &array, const TableExprNode &fraction, const TableExprNodeSet &collapseAxes)
Definition: ExprNode.h:1778
LatticeExprNode min(const LatticeExprNode &left, const LatticeExprNode &right)
TableExprNode boxedAny(const TableExprNode &node, const TableExprNodeSet &halfBoxWidth)
Definition: ExprNode.h:1917
LatticeExprNode avdev(const LatticeExprNode &expr)
const Unit & unit() const
Get the unit of the expression.
Definition: ExprNode.h:285
TableExprNode isInf(const TableExprNode &node)
Definition: ExprNode.h:1626
Array< Short > getColumnShort(const Vector< uInt > &rownrs) const
Definition: ExprNode.h:394
TableExprNode arrayFlatten(const TableExprNode &array)
Flatten a masked array (get unmasked elements).
Definition: ExprNode.h:1951
TENShPtr newDivide(const TENShPtr &right) const
for Int, Double or DComplex returning Double or Complex
Definition: ExprFuncNode.h:92
LatticeExprNode replace(const LatticeExprNode &arg1, const LatticeExprNode &arg2)
This function replaces every masked-off element in the first argument with the corresponding element ...
for Int, or Double or Complex returning Bool (2 is with default tolerance)
Definition: ExprFuncNode.h:87
t * get() const
Get the underlying pointer.
Definition: CountedPtr.h:183
TableExprNode operator!() const
Unary NOT-operator on boolean TableExprNode&#39;s.
static TableExprNode newRownrNode(const Table &table, uInt origin)
Create rownumber() function node.
TENShPtr newGT(const TENShPtr &right) const
double Double
Definition: aipstype.h:55
TableExprNode cdate(const TableExprNode &node)
Definition: ExprNode.h:1545
Array< String > getColumnString(const Vector< uInt > &rownrs) const
Definition: ExprNode.h:412
LatticeExprNode abs(const LatticeExprNode &expr)
Numerical 1-argument functions which result in a real number regardless of input expression type...
Regular expression class (based on std::regex)
Definition: Regex.h:206
return angles as hms/dms strings
Definition: ExprFuncNode.h:267
TableExprNode in(const TableExprNode &array, const TaQLStyle &=TaQLStyle(0)) const
The IN operator to test if a value is contained in an array or set.
Definition: ExprNode.h:1226
TableExprNode arrayData(const TableExprNode &array)
Get the data array of a masked array.
Definition: ExprNode.h:1941
virtual Array< Double > getColumnDouble(const Vector< rownr_t > &rownrs)
TableExprNode trim(const TableExprNode &node)
Definition: ExprNode.h:1584
Class with static members defining the TaQL style.
Definition: TaQLStyle.h:64
LatticeExprNode ndim(const LatticeExprNode &expr)
1-argument function to get the dimensionality of a lattice.
LatticeExprNode operator<=(const LatticeExprNode &left, const LatticeExprNode &right)
Array< DComplex > getArrayDComplex(const TableExprId &id) const
Definition: ExprNode.h:643
String toString(const SubScanKey &subScanKey)
MArray< String > getStringAS(const TableExprId &id) const
Definition: ExprNode.h:657
for Int, Double or Complex array returning the same
Definition: ExprFuncNode.h:134
LatticeExprNode formComplex(const LatticeExprNode &left, const LatticeExprNode &right)
Form a complex number from two real numbers.
TableExprNode boxedAll(const TableExprNode &node, const TableExprNodeSet &halfBoxWidth)
Definition: ExprNode.h:1923
LatticeExprNode iif(const LatticeExprNode &condition, const LatticeExprNode &arg1, const LatticeExprNode &arg2)
Function resembling the ternary ?: construct in C++.
LatticeExprNode nelements(const LatticeExprNode &expr)
1-argument function to get the number of elements in a lattice.
TableExprNode anys(const TableExprNode &array, const TableExprNodeSet &collapseAxes)
Definition: ExprNode.h:1785
TableExprNode boxedMax(const TableExprNode &node, const TableExprNodeSet &halfBoxWidth)
Definition: ExprNode.h:1875
LatticeExprNode sign(const LatticeExprNode &expr)
LatticeExprNode sqrt(const LatticeExprNode &expr)
Array< uChar > getColumnuChar(const Vector< uInt > &rownrs) const
Definition: ExprNode.h:392
ValueType valueType() const
Get the value type.
Definition: ExprNodeRep.h:711
rownr_t nrow() const
Get the number of rows in the table associated with this expression.
Definition: ExprNode.h:305
TableExprNode products(const TableExprNode &array, const TableExprNodeSet &collapseAxes)
Definition: ExprNode.h:1718
virtual Array< Int64 > getColumnInt64(const Vector< rownr_t > &rownrs)
LatticeExprNode tan(const LatticeExprNode &expr)
for Int or Double returning Int or Double
Definition: ExprFuncNode.h:126
TableExprNode isFinite(const TableExprNode &node)
Function to test if a scalar or array is finite.
Definition: ExprNode.h:1630
TableExprNode runningAny(const TableExprNode &array, const TableExprNodeSet &halfBoxWidth)
Definition: ExprNode.h:1857
LatticeExprNode atan(const LatticeExprNode &expr)
MArray< Int64 > getIntAS(const TableExprId &id) const
Definition: ExprNode.h:651
TENShPtr setBinaryNodeInfo(TableExprNodeBinary *tsnptr, const TENShPtr &right=TENShPtr()) const
Put the new binary node object in a shared pointer.
A hierarchical collection of named fields of various types.
Definition: Record.h:180
bool Bool
Define the standard types used by Casacore.
Definition: aipstype.h:42
TENShPtr newGE(const TENShPtr &right) const
TableExprNode upcase(const TableExprNode &node)
Definition: ExprNode.h:1468
TableExprNode cube(const TableExprNode &node)
Definition: ExprNode.h:1351
virtual Array< uChar > getColumnuChar(const Vector< rownr_t > &rownrs)
LatticeExprNode stddev(const LatticeExprNode &expr)
Array< Bool > getColumnBool(const RowNumbers &rownrs) const
Get the value of the expression evaluated for the entire column.
Definition: ExprNode.h:662
TableExprNode runningMedian(const TableExprNode &array, const TableExprNodeSet &halfBoxWidth)
Definition: ExprNode.h:1851
TableExprNode angdistx(const TableExprNode &pos1, const TableExprNode &pos2)
Angular distance as above, but only pair-wise enties are used if both arguments are arrays...
Definition: ExprNode.h:1269
virtual void ranges(Block< TableExprRange > &)
Convert the tree to a number of range vectors which at least select the same things.
static std::vector< TENShPtr > convertBlockTEN(Block< TableExprNode > &nodes)
convert Block of TableExprNode to vector of TENShPtr.
for DComplex or String returning DComplex
Definition: ExprFuncNode.h:132
LatticeExprNode round(const LatticeExprNode &expr)
Array< Bool > getArrayBool(const TableExprId &id) const
Definition: ExprNode.h:637
Array< Float > getColumnFloat(const RowNumbers &rownrs) const
Definition: ExprNode.h:676
float Float
Definition: aipstype.h:54
TableExprNode runningStddev(const TableExprNode &array, const TableExprNodeSet &halfBoxWidth)
Definition: ExprNode.h:1833
return angles as hms strings
Definition: ExprFuncNode.h:263
TableExprNode substr(const TableExprNode &str, const TableExprNode &pos)
Definition: ExprNode.h:1596
TableExprNode operator-() const
virtual MArray< Int64 > getArrayInt(const TableExprId &id)
virtual Bool getBool(const TableExprId &id)
Get a scalar value for this node in the given row.
Array< uChar > getColumnuChar(const RowNumbers &rownrs) const
Definition: ExprNode.h:664
TableExprNode sqlpattern(const TableExprNode &node)
Definition: ExprNode.h:1492
TableExprNode shape(const TableExprNode &array)
Function operating on any scalar or array resulting in a Double array containing the shape...
Definition: ExprNode.h:1987
A hierarchical collection of named fields of various types.
Definition: TableRecord.h:185
LatticeExprNode operator>(const LatticeExprNode &left, const LatticeExprNode &right)
static TableExprNode newColumnNode(const Table &tab, const String &name, const Vector< String > &fieldNames)
Create a column node on behalf of the Table class.
Array< Complex > getColumnComplex(const Vector< uInt > &rownrs) const
Definition: ExprNode.h:408
Array< String > getColumnString(const RowNumbers &rownrs) const
Definition: ExprNode.h:684
TableExprNode cmonth(const TableExprNode &node)
Definition: ExprNode.h:1527
TableExprNode operator|(const TableExprNode &left, const TableExprNode &right)
Definition: ExprNode.h:1186
LatticeExprNode atan2(const LatticeExprNode &left, const LatticeExprNode &right)
Numerical 2-argument functions.
TableExprNode integer(const TableExprNode &node)
Convert double, bool, or string to int (using floor).
Definition: ExprNode.h:1428
TableExprNode runningMean(const TableExprNode &array, const TableExprNodeSet &halfBoxWidth)
Definition: ExprNode.h:1821
TableExprNode findCone(const TableExprNode &sourcePos, const TableExprNode &cones)
The sourcePos can contain multiple sources.
Definition: ExprNode.h:1287
virtual void disableApplySelection()
Do not apply the selection.
TableExprNode boxedMean(const TableExprNode &node, const TableExprNodeSet &halfBoxWidth)
Definition: ExprNode.h:1881
const Unit & unit() const
Get the unit.
Definition: ExprNodeRep.h:731
simple 1-D array
Definition: Allocator.h:210
TENShPtr newBitXor(const TENShPtr &right) const
TableExprNode nfalses(const TableExprNode &array, const TableExprNodeSet &collapseAxes)
Definition: ExprNode.h:1803
TableExprNode boxedVariance(const TableExprNode &node, const TableExprNodeSet &halfBoxWidth)
Definition: ExprNode.h:1887
uInt64 rownr_t
Define the type of a row number in a table.
Definition: aipsxtype.h:46
TableExprNode angdist(const TableExprNode &pos1, const TableExprNode &pos2)
Angular distance between positions.
Definition: ExprNode.h:1263
for Int or Double array returning Int or Double
Definition: ExprFuncNode.h:147
MArray< Bool > getBoolAS(const TableExprId &id)
Get a value as an array, even it it is a scalar.
TableExprNode isdefined(const TableExprNode &array)
Function operating on a field resulting in a bool scalar.
Definition: ExprNode.h:1975
TableExprNode boxedRms(const TableExprNode &node, const TableExprNodeSet &halfBoxWidth)
Definition: ExprNode.h:1905
const Array< T > & array() const
Get access to the array.
Definition: MArray.h:153
const Record & attributes() const
Get the attributes of the expression.
Definition: ExprNode.h:289
LatticeExprNode operator+(const LatticeExprNode &expr)
Global functions operating on a LatticeExprNode.
Array< DComplex > getColumnDComplex(const RowNumbers &rownrs) const
Definition: ExprNode.h:682
TableExprNode regex(const TableExprNode &node)
Functions for regular expression matching and pattern matching.
Definition: ExprNode.h:1483
LatticeExprNode fmod(const LatticeExprNode &left, const LatticeExprNode &right)
TableExprNode day(const TableExprNode &node)
Definition: ExprNode.h:1523
The identification of a TaQL selection subject.
Definition: TableExprId.h:97
MArray< Bool > getBoolAS(const TableExprId &id) const
Get a value as an array, even it it is a scalar.
Definition: ExprNode.h:649
Array< uInt > getColumnuInt(const Vector< uInt > &rownrs) const
Definition: ExprNode.h:400
LatticeExprNode asin(const LatticeExprNode &expr)
Array< Double > getColumnDouble(const Vector< uInt > &rownrs) const
Definition: ExprNode.h:406
TableExprNode cdow(const TableExprNode &node)
Definition: ExprNode.h:1537
TableExprNode boxedMin(const TableExprNode &node, const TableExprNodeSet &halfBoxWidth)
Definition: ExprNode.h:1869
LatticeExprNode mean(const LatticeExprNode &expr)
TENShPtr newEQ(const TENShPtr &right) const
virtual String getString(const TableExprId &id)
Table & table()
Get table.
Definition: ExprNodeRep.h:749
TableExprNode rms(const TableExprNode &array)
Definition: ExprNode.h:1680
TableExprNode runningAvdev(const TableExprNode &array, const TableExprNodeSet &halfBoxWidth)
Definition: ExprNode.h:1839
Bool checkTableSize(const Table &table, Bool canBeConst) const
Check if tables used in expression have the same number of rows as the given table.
LatticeExprNode sinh(const LatticeExprNode &expr)
for Int, Double or DComplex returning Int or Double
Definition: ExprFuncNode.h:108
Class to handle a Regex or StringDistance.
Definition: ExprNodeRep.h:81
LatticeExprNode acos(const LatticeExprNode &expr)
TableExprNode square(const TableExprNode &node)
Definition: ExprNode.h:1346
Array< uShort > getColumnuShort(const Vector< uInt > &rownrs) const
Definition: ExprNode.h:396
virtual TaqlRegex getRegex(const TableExprId &id)
TableExprNode runningMin(const TableExprNode &array, const TableExprNodeSet &halfBoxWidth)
Functions operating for each element on a box around that element.
Definition: ExprNode.h:1809
virtual MArray< String > getArrayString(const TableExprId &id)
MArray< DComplex > getDComplexAS(const TableExprId &id) const
Definition: ExprNode.h:655
for Bool array returning Bool
Definition: ExprFuncNode.h:193
static TableExprNode newUDFNode(const String &name, const TableExprNodeSet &set, const Table &table, const TaQLStyle &=TaQLStyle(0))
Create a user defined function node.
TableExprNode sumSquare(const TableExprNode &array)
Definition: ExprNode.h:1655
TableExprNode capitalize(const TableExprNode &node)
Definition: ExprNode.h:1478
LatticeExprNode operator-(const LatticeExprNode &expr)
String: the storage and methods of handling collections of characters.
Definition: String.h:225
static TableRecord * findLastKeyRec(const TableRecord &keyset, const Vector< String > &fieldNames, String &fullName)
Handle all field names except the last one.
TableExprNode nearAbs(const TableExprNode &left, const TableExprNode &right)
Definition: ExprNode.h:1250
static TableExprNode newArrayPartNode(const TableExprNode &arrayNode, const TableExprNodeSet &indices, const TaQLStyle &=TaQLStyle(0))
Create ArrayElement node for the given array with the given index.
TableExprNode stddevs(const TableExprNode &array, const TableExprNodeSet &collapseAxes)
Definition: ExprNode.h:1754
TENShPtr newPlus(const TENShPtr &right) const
Construct a new node for the given operation.
TableExprNode datetime(const TableExprNode &node)
Functions for date-values.
Definition: ExprNode.h:1497
T norm(const TableVector< T > &tv)
Definition: TabVecMath.h:414
LatticeExprNode operator^(const LatticeExprNode &left, const LatticeExprNode &right)
LatticeExprNode operator<(const LatticeExprNode &left, const LatticeExprNode &right)
LatticeExprNode isNaN(const LatticeExprNode &expr)
Test if a value is a NaN.
Array< Int64 > getColumnInt64(const Vector< uInt > &rownrs) const
Definition: ExprNode.h:402
TableExprNode avdevs(const TableExprNode &array, const TableExprNodeSet &collapseAxes)
Definition: ExprNode.h:1760
Class to deal with Levensthein distance of strings.
MArray< DComplex > getDComplexAS(const TableExprId &id)
TableExprNode mjdtodate(const TableExprNode &node)
Definition: ExprNode.h:1502
Bool isNull() const
Does the node contain no actual node?
Definition: ExprNode.h:272
rownr_t nrow() const
Get the number of rows in the table associated with this expression.
Array< Double > getColumnDouble(const RowNumbers &rownrs) const
Definition: ExprNode.h:678
TableExprNode ctodt(const TableExprNode &node)
Definition: ExprNode.h:1541
static void throwInvDT(const String &message)
Throw invalid data type exception.
virtual Array< uShort > getColumnuShort(const Vector< rownr_t > &rownrs)
virtual DComplex getDComplex(const TableExprId &id)
LatticeExprNode variance(const LatticeExprNode &expr)
LatticeExprNode ceil(const LatticeExprNode &expr)
TENShPtr newNE(const TENShPtr &right) const
LatticeExprNode pow(const LatticeExprNode &left, const LatticeExprNode &right)
for Int or Double array returning Double
Definition: ExprFuncNode.h:156
void applySelection(const Vector< rownr_t > &rownrs)
Re-create the column object for a selection of rows.
Definition: ExprNode.h:281
Class to handle date/time type conversions and I/O.
Definition: MVTime.h:270
TableExprNode rmss(const TableExprNode &array, const TableExprNodeSet &collapseAxes)
Definition: ExprNode.h:1766
bool operator!=(const casacore_allocator< T, ALIGNMENT > &, const casacore_allocator< T, ALIGNMENT > &)
Definition: Allocator.h:135
TableExprNode ctime(const TableExprNode &node)
Definition: ExprNode.h:1549
TableExprNode hms(const TableExprNode &node)
Functions for angle-values.
Definition: ExprNode.h:1553
LatticeExprNode all(const LatticeExprNode &expr)
Bool isScalar() const
Is the expression a scalar?
Definition: ExprNode.h:299
TableExprNode diagonal(const TableExprNode &array)
Get the diagonal of a (masked) array; If the array is not a Matrix, it will take the diagonals of the...
Definition: ExprNode.h:1969
Array< Float > getColumnFloat(const Vector< uInt > &rownrs) const
Definition: ExprNode.h:404
Array< Int > getColumnInt(const RowNumbers &rownrs) const
Definition: ExprNode.h:670
Abstract base class for a node having 0, 1, or 2 child nodes.
Definition: ExprNodeRep.h:558
TableExprNode operator()(const TableExprNodeSet &indices)
Slicing in a node containing an array.
Definition: ExprNode.h:1231
TableExprNode sums(const TableExprNode &array, const TableExprNodeSet &collapseAxes)
The partial version of the functions above.
Definition: ExprNode.h:1712
LatticeExprNode operator||(const LatticeExprNode &left, const LatticeExprNode &right)
TENShPtr newBitAnd(const TENShPtr &right) const
MVBaseline operator*(const RotMatrix &left, const MVBaseline &right)
Rotate a Baseline vector with rotation matrix and other multiplications.
LatticeExprNode cosh(const LatticeExprNode &expr)
TableExprNode week(const TableExprNode &node)
Definition: ExprNode.h:1576
TableExprNode hdms(const TableExprNode &node)
Definition: ExprNode.h:1561
LatticeExprNode real(const LatticeExprNode &expr)
Int64 getInt(const TableExprId &id) const
Definition: ExprNode.h:627
virtual Array< uInt > getColumnuInt(const Vector< rownr_t > &rownrs)
const TENShPtr & getRep() const
returns const pointer to the underlying TableExprNodeRep object.
Definition: ExprNode.h:689
LatticeExprNode value(const LatticeExprNode &expr)
This function returns the value of the expression without a mask.
LatticeExprNode sin(const LatticeExprNode &expr)
Numerical 1-argument functions.
for Int, Double, DComplex, Bool or String returning Double
Definition: ExprFuncNode.h:113
static TableExprNode newConeNode(TableExprFuncNode::FunctionType, const TableExprNodeSet &set, uInt origin=0)
Create cone function node of the given type with the given arguments.
LatticeExprNode operator&&(const LatticeExprNode &left, const LatticeExprNode &right)
Logical binary operators.
unsigned int uInt
Definition: aipstype.h:51
Array< uInt > getColumnuInt(const RowNumbers &rownrs) const
Definition: ExprNode.h:672
TableExprNode date(const TableExprNode &node)
Definition: ExprNode.h:1511
TableExprNode amplitude(const TableExprNode &node)
The amplitude (i.e.
Definition: ExprNode.h:1440