casacore
Loading...
Searching...
No Matches
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: casa-feedback@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#ifndef TABLES_EXPRGROUPAGGRFUNC_H
27#define TABLES_EXPRGROUPAGGRFUNC_H
28
29// # Includes
30#include <casacore/casa/aips.h>
31#include <casacore/tables/TaQL/ExprGroup.h>
32#include <vector>
33
34namespace casacore { // # NAMESPACE CASACORE - BEGIN
35
36// # Forward Declaration
38
39// <summary>
40// Aggregate class counting number of rows in a group
41// </summary>
42// <use visibility=local>
43// <reviewed reviewer="" date="" tests="tExprGroup">
44// </reviewed>
45// <synopsis>
46// Aggregate class counting number of rows in a group.
47// </synopsis>
49 public:
52 virtual void apply(const TableExprId& id);
53 // Set result in case it is known directly.
54 void setResult(Int64 cnt) { itsValue = cnt; }
55};
56
57// <summary>
58// Aggregate class counting number of rows in a group containing a value
59// </summary>
60// <use visibility=local>
61// <reviewed reviewer="" date="" tests="tExprGroup">
62// </reviewed>
63// <synopsis>
64// Aggregate class counting number of rows in a group containing a value.
65// </synopsis>
67 public:
70 virtual void apply(const TableExprId& id);
71
72 private:
74};
75
76// <summary>
77// Aggregate class counting if any value in a group is true
78// </summary>
79// <use visibility=local>
80// <reviewed reviewer="" date="" tests="tExprGroup">
81// </reviewed>
82// <synopsis>
83// Aggregate class counting if any value in a group is true.
84// </synopsis>
86 public:
89 virtual void apply(const TableExprId& id);
90};
91
92// <summary>
93// Aggregate class counting if all values in a group are true
94// </summary>
95// <use visibility=local>
96// <reviewed reviewer="" date="" tests="tExprGroup">
97// </reviewed>
98// <synopsis>
99// Aggregate class counting if all values in a group are true.
100// </synopsis>
102 public:
105 virtual void apply(const TableExprId& id);
106};
107
108// <summary>
109// Aggregate class counting the number of true values in a group
110// </summary>
111// <use visibility=local>
112// <reviewed reviewer="" date="" tests="tExprGroup">
113// </reviewed>
114// <synopsis>
115// Aggregate class counting the number of true values in a group.
116// </synopsis>
118 public:
121 virtual void apply(const TableExprId& id);
122};
123
124// <summary>
125// Aggregate class counting the number of false values in a group
126// </summary>
127// <use visibility=local>
128// <reviewed reviewer="" date="" tests="tExprGroup">
129// </reviewed>
130// <synopsis>
131// Aggregate class counting the number of false values in a group.
132// </synopsis>
134 public:
137 virtual void apply(const TableExprId& id);
138};
139
140// <summary>
141// Aggregate class determining the minimum integer value in a group
142// </summary>
143// <use visibility=local>
144// <reviewed reviewer="" date="" tests="tExprGroup">
145// </reviewed>
146// <synopsis>
147// Aggregate class determining the minimum integer value in a group.
148// </synopsis>
150 public:
153 virtual void apply(const TableExprId& id);
154};
155
156// <summary>
157// Aggregate class determining the maximum integer value in a group
158// </summary>
159// <use visibility=local>
160// <reviewed reviewer="" date="" tests="tExprGroup">
161// </reviewed>
162// <synopsis>
163// Aggregate class determining the maximum integer value in a group.
164// </synopsis>
166 public:
169 virtual void apply(const TableExprId& id);
170};
171
172// <summary>
173// Aggregate class determining the sum of integer values in a group
174// </summary>
175// <use visibility=local>
176// <reviewed reviewer="" date="" tests="tExprGroup">
177// </reviewed>
178// <synopsis>
179// Aggregate class determining the sum of integer values in a group.
180// </synopsis>
182 public:
185 virtual void apply(const TableExprId& id);
186};
187
188// <summary>
189// Aggregate class determining the product of integer values in a group
190// </summary>
191// <use visibility=local>
192// <reviewed reviewer="" date="" tests="tExprGroup">
193// </reviewed>
194// <synopsis>
195// Aggregate class determining the product of integer values in a group.
196// </synopsis>
198 public:
201 virtual void apply(const TableExprId& id);
202};
203
204// <summary>
205// Aggregate class determining the sum of squares of integer values in a group
206// </summary>
207// <use visibility=local>
208// <reviewed reviewer="" date="" tests="tExprGroup">
209// </reviewed>
210// <synopsis>
211// Aggregate class determining the sum of squares of integer values in a group.
212// </synopsis>
214 public:
217 virtual void apply(const TableExprId& id);
218};
219
220// <summary>
221// Aggregate class determining the minimum double value in a group
222// </summary>
223// <use visibility=local>
224// <reviewed reviewer="" date="" tests="tExprGroup">
225// </reviewed>
226// <synopsis>
227// Aggregate class determining the minimum double value in a group.
228// </synopsis>
230 public:
233 virtual void apply(const TableExprId& id);
234};
235
236// <summary>
237// Aggregate class determining the maximum 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 maximum double value in a group.
244// </synopsis>
246 public:
249 virtual void apply(const TableExprId& id);
250};
251
252// <summary>
253// Aggregate class determining the sum of double values in a group
254// </summary>
255// <use visibility=local>
256// <reviewed reviewer="" date="" tests="tExprGroup">
257// </reviewed>
258// <synopsis>
259// Aggregate class determining the sum of double values in a group.
260// </synopsis>
262 public:
265 virtual void apply(const TableExprId& id);
266};
267
268// <summary>
269// Aggregate class determining the product of double values in a group
270// </summary>
271// <use visibility=local>
272// <reviewed reviewer="" date="" tests="tExprGroup">
273// </reviewed>
274// <synopsis>
275// Aggregate class determining the product of double values in a group.
276// </synopsis>
283
284// <summary>
285// Aggregate class determining the sum of squares of double values in a group
286// </summary>
287// <use visibility=local>
288// <reviewed reviewer="" date="" tests="tExprGroup">
289// </reviewed>
290// <synopsis>
291// Aggregate class determining the sum of squares of double values in a group.
292// </synopsis>
299
300// <summary>
301// Aggregate class determining the mean of values in a group
302// </summary>
303// <use visibility=local>
304// <reviewed reviewer="" date="" tests="tExprGroup">
305// </reviewed>
306// <synopsis>
307// Aggregate class determining the mean of values in a group.
308// </synopsis>
310 public:
313 virtual void apply(const TableExprId& id);
314 virtual void finish();
315
316 private:
318};
319
320// <summary>
321// Aggregate class determining the variance of values in a group
322// </summary>
323// <use visibility=local>
324// <reviewed reviewer="" date="" tests="tExprGroup">
325// </reviewed>
326// <synopsis>
327// Aggregate class determining the variance of values in a group.
328// It uses a running algorithm
329// (see en.wikipedia.org/wiki/Algorithms_for_calculating_variance)
330// </synopsis>
332 public:
335 virtual void apply(const TableExprId& id);
336 virtual void finish();
337
338 protected:
342};
343
344// <summary>
345// Aggregate class determining the standard deviation of values in a group
346// </summary>
347// <use visibility=local>
348// <reviewed reviewer="" date="" tests="tExprGroup">
349// </reviewed>
350// <synopsis>
351// Aggregate class determining the standard deviation of values in a group.
352// It uses a running algorithm
353// (see en.wikipedia.org/wiki/Algorithms_for_calculating_variance)
354// </synopsis>
361
362// <summary>
363// Aggregate class determining the RMS of values in a group
364// </summary>
365// <use visibility=local>
366// <reviewed reviewer="" date="" tests="tExprGroup">
367// </reviewed>
368// <synopsis>
369// Aggregate class determining the RMS of values in a group.
370// </synopsis>
372 public:
375 virtual void apply(const TableExprId& id);
376 virtual void finish();
377
378 private:
380};
381
382// <summary>
383// Aggregate class determining the fractile of values in a group
384// </summary>
385// <use visibility=local>
386// <reviewed reviewer="" date="" tests="tExprGroup">
387// </reviewed>
388// <synopsis>
389// Aggregate class determining the fractile of values in a group.
390// <br>It is a lazy aggregate class, thus <src>apply</src> does nothing.
391// Instead, <src>getDouble</src> assembles the values and determines the
392// fractile.
393// </synopsis>
395 public:
398 virtual Bool isLazy() const;
399 virtual void apply(const TableExprId& id);
400 virtual Double getDouble(const vector<TableExprId>& ids);
401
402 private:
404};
405
406// <summary>
407// Aggregate class determining the sum of complex values in a group
408// </summary>
409// <use visibility=local>
410// <reviewed reviewer="" date="" tests="tExprGroup">
411// </reviewed>
412// <synopsis>
413// Aggregate class determining the sum of complex values in a group.
414// </synopsis>
421
422// <summary>
423// Aggregate class determining the product of complex values in a group
424// </summary>
425// <use visibility=local>
426// <reviewed reviewer="" date="" tests="tExprGroup">
427// </reviewed>
428// <synopsis>
429// Aggregate class determining the product of complex values in a group.
430// </synopsis>
437
438// <summary>
439// Aggregate class determining the sum of squares of complex values in a group
440// </summary>
441// <use visibility=local>
442// <reviewed reviewer="" date="" tests="tExprGroup">
443// </reviewed>
444// <synopsis>
445// Aggregate class determining the sum of squares of complex values in a group.
446// </synopsis>
453
454// <summary>
455// Aggregate class determining the mean of complex values in a group
456// </summary>
457// <use visibility=local>
458// <reviewed reviewer="" date="" tests="tExprGroup">
459// </reviewed>
460// <synopsis>
461// Aggregate class determining the mean of complex values in a group.
462// </synopsis>
464 public:
467 virtual void apply(const TableExprId& id);
468 virtual void finish();
469
470 private:
472};
473
474// <summary>
475// Aggregate class determining the variance of values in a group
476// </summary>
477// <use visibility=local>
478// <reviewed reviewer="" date="" tests="tExprGroup">
479// </reviewed>
480// <synopsis>
481// Aggregate class determining the variance of values in a group.
482// It uses a running algorithm
483// (see en.wikipedia.org/wiki/Algorithms_for_calculating_variance)
484// Note that the result is a Double value (not DComplex).
485// </synopsis>
487 public:
490 virtual void apply(const TableExprId& id);
491 virtual void finish();
492
493 protected:
496 DComplex itsCurMean;
497};
498
499// <summary>
500// Aggregate class determining the standard deviation of values in a group
501// </summary>
502// <use visibility=local>
503// <reviewed reviewer="" date="" tests="tExprGroup">
504// </reviewed>
505// <synopsis>
506// Aggregate class determining the standard deviation of values in a group.
507// It uses a running algorithm
508// (see en.wikipedia.org/wiki/Algorithms_for_calculating_variance)
509// </synopsis>
516
517} // namespace casacore
518
519#endif
TableExprGroupAll(TableExprNodeRep *node)
virtual void apply(const TableExprId &id)
Get the operand's value for the given row and apply it to the aggregation.
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.
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.
virtual Bool isLazy() const
Does the aggregate function use lazy semantics?
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)
TableExprGroupFuncBool(TableExprNodeRep *node)
Definition ExprGroup.h:440
TableExprGroupFuncDComplex(TableExprNodeRep *node, const DComplex &initValue=DComplex())
Definition ExprGroup.h:514
TableExprGroupFuncDouble(TableExprNodeRep *node, Double initValue=0)
Definition ExprGroup.h:490
TableExprGroupFuncInt(TableExprNodeRep *node, Int64 initValue=0)
Definition ExprGroup.h:465
TableExprGroupMaxDouble(TableExprNodeRep *node)
virtual void apply(const TableExprId &id)
Get the operand's value for the given row and apply it to the aggregation.
TableExprGroupMaxInt(TableExprNodeRep *node)
virtual void apply(const TableExprId &id)
Get the operand's value for the given row and apply it to the aggregation.
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.
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.
virtual void apply(const TableExprId &id)
Get the operand's value for the given row and apply it to the aggregation.
TableExprGroupMinDouble(TableExprNodeRep *node)
virtual void apply(const TableExprId &id)
Get the operand's value for the given row and apply it to the aggregation.
TableExprGroupMinInt(TableExprNodeRep *node)
virtual void apply(const TableExprId &id)
Get the operand's value for the given row and apply it to the aggregation.
TableExprGroupNFalse(TableExprNodeRep *node)
TableExprGroupNTrue(TableExprNodeRep *node)
virtual void apply(const TableExprId &id)
Get the operand's value for the given row and apply it to the aggregation.
virtual void apply(const TableExprId &id)
Get the operand's value for the given row and apply it to the aggregation.
TableExprGroupProductDComplex(TableExprNodeRep *node)
virtual void apply(const TableExprId &id)
Get the operand's value for the given row and apply it to the aggregation.
TableExprGroupProductDouble(TableExprNodeRep *node)
TableExprGroupProductInt(TableExprNodeRep *node)
virtual void apply(const TableExprId &id)
Get the operand's value for the given row and apply it to the aggregation.
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.
virtual void finish()
If needed, finish the aggregation.
TableExprGroupStdDevDComplex(TableExprNodeRep *node, uInt ddof)
virtual void finish()
If needed, finish the aggregation.
TableExprGroupStdDevDouble(TableExprNodeRep *node, uInt ddof)
TableExprGroupSumDComplex(TableExprNodeRep *node)
virtual void apply(const TableExprId &id)
Get the operand's value for the given row and apply it to the aggregation.
virtual void apply(const TableExprId &id)
Get the operand's value for the given row and apply it to the aggregation.
TableExprGroupSumDouble(TableExprNodeRep *node)
TableExprGroupSumInt(TableExprNodeRep *node)
virtual void apply(const TableExprId &id)
Get the operand's value for the given row and apply it to the aggregation.
TableExprGroupSumSqrDComplex(TableExprNodeRep *node)
virtual void apply(const TableExprId &id)
Get the operand's value for the given row and apply it to the aggregation.
virtual void apply(const TableExprId &id)
Get the operand's value for the given row and apply it to the aggregation.
TableExprGroupSumSqrDouble(TableExprNodeRep *node)
TableExprGroupSumSqrInt(TableExprNodeRep *node)
virtual void apply(const TableExprId &id)
Get the operand's value for the given row and apply it to the aggregation.
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.
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.
For temporary backward namespace compatibility, use casa as alias for casacore.
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:49
long long Int64
Define the extra non-standard types used by Casacore (like proposed uSize, Size).
Definition aipsxtype.h:36
bool Bool
Define the standard types used by Casacore.
Definition aipstype.h:40
double Double
Definition aipstype.h:53