casacore
ExprGroupAggrFunc.h
Go to the documentation of this file.
1 //# ExprGroupAggrFunc.h: The various scalar aggregation functions
2 //# Copyright (C) 2013
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: TaQLNode.h 21051 2011-04-20 11:46:29Z gervandiepen $
27 
28 #ifndef TABLES_EXPRGROUPAGGRFUNC_H
29 #define TABLES_EXPRGROUPAGGRFUNC_H
30 
31 //# Includes
32 #include <casacore/casa/aips.h>
33 #include <casacore/tables/TaQL/ExprGroup.h>
34 #include <vector>
35 
36 
37 namespace casacore { //# NAMESPACE CASACORE - BEGIN
38 
39  //# Forward Declaration
40  class TableExprNodeArrayColumn;
41 
42 
43  // <summary>
44  // Aggregate class counting number of rows in a group
45  // </summary>
46  // <use visibility=local>
47  // <reviewed reviewer="" date="" tests="tExprGroup">
48  // </reviewed>
49  // <synopsis>
50  // Aggregate class counting number of rows in a group.
51  // </synopsis>
53  {
54  public:
57  virtual void apply (const TableExprId& id);
58  // Set result in case it is known directly.
59  void setResult (Int64 cnt)
60  { itsValue = cnt; }
61  };
62 
63  // <summary>
64  // Aggregate class counting number of rows in a group containing a value
65  // </summary>
66  // <use visibility=local>
67  // <reviewed reviewer="" date="" tests="tExprGroup">
68  // </reviewed>
69  // <synopsis>
70  // Aggregate class counting number of rows in a group containing a value.
71  // </synopsis>
73  {
74  public:
77  virtual void apply (const TableExprId& id);
78  private:
80  };
81 
82  // <summary>
83  // Aggregate class counting if any value in a group is true
84  // </summary>
85  // <use visibility=local>
86  // <reviewed reviewer="" date="" tests="tExprGroup">
87  // </reviewed>
88  // <synopsis>
89  // Aggregate class counting if any value in a group is true.
90  // </synopsis>
92  {
93  public:
95  virtual ~TableExprGroupAny();
96  virtual void apply (const TableExprId& id);
97  };
98 
99  // <summary>
100  // Aggregate class counting if all values in a group are true
101  // </summary>
102  // <use visibility=local>
103  // <reviewed reviewer="" date="" tests="tExprGroup">
104  // </reviewed>
105  // <synopsis>
106  // Aggregate class counting if all values in a group are true.
107  // </synopsis>
109  {
110  public:
113  virtual void apply (const TableExprId& id);
114  };
115 
116  // <summary>
117  // Aggregate class counting the number of true values in a group
118  // </summary>
119  // <use visibility=local>
120  // <reviewed reviewer="" date="" tests="tExprGroup">
121  // </reviewed>
122  // <synopsis>
123  // Aggregate class counting the number of true values in a group.
124  // </synopsis>
126  {
127  public:
130  virtual void apply (const TableExprId& id);
131  };
132 
133  // <summary>
134  // Aggregate class counting the number of false values in a group
135  // </summary>
136  // <use visibility=local>
137  // <reviewed reviewer="" date="" tests="tExprGroup">
138  // </reviewed>
139  // <synopsis>
140  // Aggregate class counting the number of false values in a group.
141  // </synopsis>
143  {
144  public:
147  virtual void apply (const TableExprId& id);
148  };
149 
150  // <summary>
151  // Aggregate class determining the minimum integer value in a group
152  // </summary>
153  // <use visibility=local>
154  // <reviewed reviewer="" date="" tests="tExprGroup">
155  // </reviewed>
156  // <synopsis>
157  // Aggregate class determining the minimum integer value in a group.
158  // </synopsis>
160  {
161  public:
164  virtual void apply (const TableExprId& id);
165  };
166 
167  // <summary>
168  // Aggregate class determining the maximum integer value in a group
169  // </summary>
170  // <use visibility=local>
171  // <reviewed reviewer="" date="" tests="tExprGroup">
172  // </reviewed>
173  // <synopsis>
174  // Aggregate class determining the maximum integer value in a group.
175  // </synopsis>
177  {
178  public:
181  virtual void apply (const TableExprId& id);
182  };
183 
184  // <summary>
185  // Aggregate class determining the sum of integer values in a group
186  // </summary>
187  // <use visibility=local>
188  // <reviewed reviewer="" date="" tests="tExprGroup">
189  // </reviewed>
190  // <synopsis>
191  // Aggregate class determining the sum of integer values in a group.
192  // </synopsis>
194  {
195  public:
198  virtual void apply (const TableExprId& id);
199  };
200 
201  // <summary>
202  // Aggregate class determining the product of integer values in a group
203  // </summary>
204  // <use visibility=local>
205  // <reviewed reviewer="" date="" tests="tExprGroup">
206  // </reviewed>
207  // <synopsis>
208  // Aggregate class determining the product of integer values in a group.
209  // </synopsis>
211  {
212  public:
215  virtual void apply (const TableExprId& id);
216  };
217 
218  // <summary>
219  // Aggregate class determining the sum of squares of integer values in a group
220  // </summary>
221  // <use visibility=local>
222  // <reviewed reviewer="" date="" tests="tExprGroup">
223  // </reviewed>
224  // <synopsis>
225  // Aggregate class determining the sum of squares of integer values in a group.
226  // </synopsis>
228  {
229  public:
232  virtual void apply (const TableExprId& id);
233  };
234 
235 
236  // <summary>
237  // Aggregate class determining the minimum double value in a group
238  // </summary>
239  // <use visibility=local>
240  // <reviewed reviewer="" date="" tests="tExprGroup">
241  // </reviewed>
242  // <synopsis>
243  // Aggregate class determining the minimum double value in a group.
244  // </synopsis>
246  {
247  public:
250  virtual void apply (const TableExprId& id);
251  };
252 
253  // <summary>
254  // Aggregate class determining the maximum double value in a group
255  // </summary>
256  // <use visibility=local>
257  // <reviewed reviewer="" date="" tests="tExprGroup">
258  // </reviewed>
259  // <synopsis>
260  // Aggregate class determining the maximum double value in a group.
261  // </synopsis>
263  {
264  public:
267  virtual void apply (const TableExprId& id);
268  };
269 
270  // <summary>
271  // Aggregate class determining the sum of double values in a group
272  // </summary>
273  // <use visibility=local>
274  // <reviewed reviewer="" date="" tests="tExprGroup">
275  // </reviewed>
276  // <synopsis>
277  // Aggregate class determining the sum of double values in a group.
278  // </synopsis>
280  {
281  public:
284  virtual void apply (const TableExprId& id);
285  };
286 
287  // <summary>
288  // Aggregate class determining the product of double values in a group
289  // </summary>
290  // <use visibility=local>
291  // <reviewed reviewer="" date="" tests="tExprGroup">
292  // </reviewed>
293  // <synopsis>
294  // Aggregate class determining the product of double values in a group.
295  // </synopsis>
297  {
298  public:
301  virtual void apply (const TableExprId& id);
302  };
303 
304  // <summary>
305  // Aggregate class determining the sum of squares of double values in a group
306  // </summary>
307  // <use visibility=local>
308  // <reviewed reviewer="" date="" tests="tExprGroup">
309  // </reviewed>
310  // <synopsis>
311  // Aggregate class determining the sum of squares of double values in a group.
312  // </synopsis>
314  {
315  public:
318  virtual void apply (const TableExprId& id);
319  };
320 
321  // <summary>
322  // Aggregate class determining the mean of values in a group
323  // </summary>
324  // <use visibility=local>
325  // <reviewed reviewer="" date="" tests="tExprGroup">
326  // </reviewed>
327  // <synopsis>
328  // Aggregate class determining the mean of values in a group.
329  // </synopsis>
331  {
332  public:
335  virtual void apply (const TableExprId& id);
336  virtual void finish();
337  private:
339  };
340 
341  // <summary>
342  // Aggregate class determining the variance of values in a group
343  // </summary>
344  // <use visibility=local>
345  // <reviewed reviewer="" date="" tests="tExprGroup">
346  // </reviewed>
347  // <synopsis>
348  // Aggregate class determining the variance of values in a group.
349  // It uses a running algorithm
350  // (see en.wikipedia.org/wiki/Algorithms_for_calculating_variance)
351  // </synopsis>
353  {
354  public:
357  virtual void apply (const TableExprId& id);
358  virtual void finish();
359  protected:
363  };
364 
365  // <summary>
366  // Aggregate class determining the standard deviation of values in a group
367  // </summary>
368  // <use visibility=local>
369  // <reviewed reviewer="" date="" tests="tExprGroup">
370  // </reviewed>
371  // <synopsis>
372  // Aggregate class determining the standard deviation of values in a group.
373  // It uses a running algorithm
374  // (see en.wikipedia.org/wiki/Algorithms_for_calculating_variance)
375  // </synopsis>
377  {
378  public:
381  virtual void finish();
382  };
383 
384  // <summary>
385  // Aggregate class determining the RMS of values in a group
386  // </summary>
387  // <use visibility=local>
388  // <reviewed reviewer="" date="" tests="tExprGroup">
389  // </reviewed>
390  // <synopsis>
391  // Aggregate class determining the RMS of values in a group.
392  // </synopsis>
394  {
395  public:
398  virtual void apply (const TableExprId& id);
399  virtual void finish();
400  private:
402  };
403 
404  // <summary>
405  // Aggregate class determining the fractile of values in a group
406  // </summary>
407  // <use visibility=local>
408  // <reviewed reviewer="" date="" tests="tExprGroup">
409  // </reviewed>
410  // <synopsis>
411  // Aggregate class determining the fractile of values in a group.
412  // <br>It is a lazy aggregate class, thus <src>apply</src> does nothing.
413  // Instead, <src>getDouble</src> assembles the values and determines the
414  // fractile.
415  // </synopsis>
417  {
418  public:
420  Double fractile);
422  virtual Bool isLazy() const;
423  virtual void apply (const TableExprId& id);
424  virtual Double getDouble (const vector<TableExprId>& ids);
425  private:
427  };
428 
429 
430  // <summary>
431  // Aggregate class determining the sum of complex values in a group
432  // </summary>
433  // <use visibility=local>
434  // <reviewed reviewer="" date="" tests="tExprGroup">
435  // </reviewed>
436  // <synopsis>
437  // Aggregate class determining the sum of complex values in a group.
438  // </synopsis>
440  {
441  public:
444  virtual void apply (const TableExprId& id);
445  };
446 
447  // <summary>
448  // Aggregate class determining the product of complex values in a group
449  // </summary>
450  // <use visibility=local>
451  // <reviewed reviewer="" date="" tests="tExprGroup">
452  // </reviewed>
453  // <synopsis>
454  // Aggregate class determining the product of complex values in a group.
455  // </synopsis>
457  {
458  public:
461  virtual void apply (const TableExprId& id);
462  };
463 
464  // <summary>
465  // Aggregate class determining the sum of squares of complex values in a group
466  // </summary>
467  // <use visibility=local>
468  // <reviewed reviewer="" date="" tests="tExprGroup">
469  // </reviewed>
470  // <synopsis>
471  // Aggregate class determining the sum of squares of complex values in a group.
472  // </synopsis>
474  {
475  public:
478  virtual void apply (const TableExprId& id);
479  };
480 
481  // <summary>
482  // Aggregate class determining the mean of complex values in a group
483  // </summary>
484  // <use visibility=local>
485  // <reviewed reviewer="" date="" tests="tExprGroup">
486  // </reviewed>
487  // <synopsis>
488  // Aggregate class determining the mean of complex values in a group.
489  // </synopsis>
491  {
492  public:
495  virtual void apply (const TableExprId& id);
496  virtual void finish();
497  private:
499  };
500 
501  // <summary>
502  // Aggregate class determining the variance of values in a group
503  // </summary>
504  // <use visibility=local>
505  // <reviewed reviewer="" date="" tests="tExprGroup">
506  // </reviewed>
507  // <synopsis>
508  // Aggregate class determining the variance of values in a group.
509  // It uses a running algorithm
510  // (see en.wikipedia.org/wiki/Algorithms_for_calculating_variance)
511  // Note that the result is a Double value (not DComplex).
512  // </synopsis>
514  {
515  public:
518  virtual void apply (const TableExprId& id);
519  virtual void finish();
520  protected:
524  };
525 
526  // <summary>
527  // Aggregate class determining the standard deviation of values in a group
528  // </summary>
529  // <use visibility=local>
530  // <reviewed reviewer="" date="" tests="tExprGroup">
531  // </reviewed>
532  // <synopsis>
533  // Aggregate class determining the standard deviation of values in a group.
534  // It uses a running algorithm
535  // (see en.wikipedia.org/wiki/Algorithms_for_calculating_variance)
536  // </synopsis>
538  {
539  public:
542  virtual void finish();
543  };
544 
545 
546 } //# NAMESPACE CASACORE - END
547 
548 #endif
Aggregate class counting if all values in a group are true.
TableExprGroupAll(TableExprNodeRep *node)
virtual void apply(const TableExprId &id)
Get the operand's value for the given row and apply it to the aggregation.
Aggregate class counting if any value in a group is true.
TableExprGroupAny(TableExprNodeRep *node)
virtual void apply(const TableExprId &id)
Get the operand's value for the given row and apply it to the aggregation.
void setResult(Int64 cnt)
Set result in case it is known directly.
TableExprGroupCountAll(TableExprNodeRep *node)
virtual void apply(const TableExprId &id)
Get the operand's value for the given row and apply it to the aggregation.
Aggregate class counting number of rows in a group containing a value.
TableExprGroupCount(TableExprNodeRep *node)
TableExprNodeArrayColumn * itsColumn
virtual void apply(const TableExprId &id)
Get the operand's value for the given row and apply it to the aggregation.
Aggregate class determining the fractile of values in a group.
virtual Bool isLazy() const
Does the aggregate function use lazy semantics? The default implementation returns False.
virtual void apply(const TableExprId &id)
Get the operand's value for the given row and apply it to the aggregation.
virtual Double getDouble(const vector< TableExprId > &ids)
TableExprGroupFractileDouble(TableExprNodeRep *node, Double fractile)
Abstract base class for aggregate functions giving a bool scalar.
Definition: ExprGroup.h:470
Abstract base class for aggregate functions giving a dcomplex scalar.
Definition: ExprGroup.h:553
Abstract base class for aggregate functions giving a double scalar.
Definition: ExprGroup.h:526
Abstract base class for aggregate functions giving an integer scalar.
Definition: ExprGroup.h:499
Aggregate class determining the maximum double value in a group.
TableExprGroupMaxDouble(TableExprNodeRep *node)
virtual void apply(const TableExprId &id)
Get the operand's value for the given row and apply it to the aggregation.
Aggregate class determining the maximum integer value in a group.
TableExprGroupMaxInt(TableExprNodeRep *node)
virtual void apply(const TableExprId &id)
Get the operand's value for the given row and apply it to the aggregation.
Aggregate class determining the mean of complex values in a group.
TableExprGroupMeanDComplex(TableExprNodeRep *node)
virtual void finish()
If needed, finish the aggregation.
virtual void apply(const TableExprId &id)
Get the operand's value for the given row and apply it to the aggregation.
Aggregate class determining the mean of values in a group.
virtual void apply(const TableExprId &id)
Get the operand's value for the given row and apply it to the aggregation.
TableExprGroupMeanDouble(TableExprNodeRep *node)
virtual void finish()
If needed, finish the aggregation.
Aggregate class determining the minimum double value in a group.
virtual void apply(const TableExprId &id)
Get the operand's value for the given row and apply it to the aggregation.
TableExprGroupMinDouble(TableExprNodeRep *node)
Aggregate class determining the minimum integer value in a group.
virtual void apply(const TableExprId &id)
Get the operand's value for the given row and apply it to the aggregation.
TableExprGroupMinInt(TableExprNodeRep *node)
Aggregate class counting the number of false values in a group.
virtual void apply(const TableExprId &id)
Get the operand's value for the given row and apply it to the aggregation.
TableExprGroupNFalse(TableExprNodeRep *node)
Aggregate class counting the number of true values in a group.
TableExprGroupNTrue(TableExprNodeRep *node)
virtual void apply(const TableExprId &id)
Get the operand's value for the given row and apply it to the aggregation.
Aggregate class determining the product of complex values in a group.
virtual void apply(const TableExprId &id)
Get the operand's value for the given row and apply it to the aggregation.
TableExprGroupProductDComplex(TableExprNodeRep *node)
Aggregate class determining the product of double values in a group.
virtual void apply(const TableExprId &id)
Get the operand's value for the given row and apply it to the aggregation.
TableExprGroupProductDouble(TableExprNodeRep *node)
Aggregate class determining the product of integer values in a group.
TableExprGroupProductInt(TableExprNodeRep *node)
virtual void apply(const TableExprId &id)
Get the operand's value for the given row and apply it to the aggregation.
Aggregate class determining the RMS of values in a group.
TableExprGroupRmsDouble(TableExprNodeRep *node)
virtual void finish()
If needed, finish the aggregation.
virtual void apply(const TableExprId &id)
Get the operand's value for the given row and apply it to the aggregation.
Aggregate class determining the standard deviation of values in a group.
virtual void finish()
If needed, finish the aggregation.
TableExprGroupStdDevDComplex(TableExprNodeRep *node, uInt ddof)
Aggregate class determining the standard deviation of values in a group.
virtual void finish()
If needed, finish the aggregation.
TableExprGroupStdDevDouble(TableExprNodeRep *node, uInt ddof)
Aggregate class determining the sum of complex values in a group.
TableExprGroupSumDComplex(TableExprNodeRep *node)
virtual void apply(const TableExprId &id)
Get the operand's value for the given row and apply it to the aggregation.
Aggregate class determining the sum of double values in a group.
virtual void apply(const TableExprId &id)
Get the operand's value for the given row and apply it to the aggregation.
TableExprGroupSumDouble(TableExprNodeRep *node)
Aggregate class determining the sum of integer values in a group.
TableExprGroupSumInt(TableExprNodeRep *node)
virtual void apply(const TableExprId &id)
Get the operand's value for the given row and apply it to the aggregation.
Aggregate class determining the sum of squares of complex values in a group.
TableExprGroupSumSqrDComplex(TableExprNodeRep *node)
virtual void apply(const TableExprId &id)
Get the operand's value for the given row and apply it to the aggregation.
Aggregate class determining the sum of squares of double values in a group.
virtual void apply(const TableExprId &id)
Get the operand's value for the given row and apply it to the aggregation.
TableExprGroupSumSqrDouble(TableExprNodeRep *node)
Aggregate class determining the sum of squares of integer values in a group.
TableExprGroupSumSqrInt(TableExprNodeRep *node)
virtual void apply(const TableExprId &id)
Get the operand's value for the given row and apply it to the aggregation.
Aggregate class determining the variance of values in a group.
TableExprGroupVarianceDComplex(TableExprNodeRep *node, uInt ddof)
virtual void apply(const TableExprId &id)
Get the operand's value for the given row and apply it to the aggregation.
virtual void finish()
If needed, finish the aggregation.
Aggregate class determining the variance of values in a group.
virtual void finish()
If needed, finish the aggregation.
TableExprGroupVarianceDouble(TableExprNodeRep *node, uInt ddof)
virtual void apply(const TableExprId &id)
Get the operand's value for the given row and apply it to the aggregation.
Base class for Array column in table select expression.
Abstract base class for a node in a table column expression tree.
Definition: ExprNodeRep.h:158
this file contains all the compiler specific defines
Definition: mainpage.dox:28
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.
unsigned int uInt
Definition: aipstype.h:51
long long Int64
Define the extra non-standard types used by Casacore (like proposed uSize, Size)
Definition: aipsxtype.h:38
bool Bool
Define the standard types used by Casacore.
Definition: aipstype.h:42
double Double
Definition: aipstype.h:55