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
34
35namespace casacore { //# NAMESPACE CASACORE - BEGIN
36
37 //# Forward Declaration
39
40
41 // <summary>
42 // Aggregate class counting number of rows in a group
43 // </summary>
44 // <use visibility=local>
45 // <reviewed reviewer="" date="" tests="tExprGroup">
46 // </reviewed>
47 // <synopsis>
48 // Aggregate class counting number of rows in a group.
49 // </synopsis>
51 {
52 public:
55 virtual void apply (const TableExprId& id);
56 // Set result in case it is known directly.
57 void setResult (Int64 cnt)
58 { itsValue = cnt; }
59 };
60
61 // <summary>
62 // Aggregate class counting number of rows in a group containing a value
63 // </summary>
64 // <use visibility=local>
65 // <reviewed reviewer="" date="" tests="tExprGroup">
66 // </reviewed>
67 // <synopsis>
68 // Aggregate class counting number of rows in a group containing a value.
69 // </synopsis>
71 {
72 public:
75 virtual void apply (const TableExprId& id);
76 private:
78 };
79
80 // <summary>
81 // Aggregate class counting if any value in a group is true
82 // </summary>
83 // <use visibility=local>
84 // <reviewed reviewer="" date="" tests="tExprGroup">
85 // </reviewed>
86 // <synopsis>
87 // Aggregate class counting if any value in a group is true.
88 // </synopsis>
90 {
91 public:
94 virtual void apply (const TableExprId& id);
95 };
96
97 // <summary>
98 // Aggregate class counting if all values in a group are true
99 // </summary>
100 // <use visibility=local>
101 // <reviewed reviewer="" date="" tests="tExprGroup">
102 // </reviewed>
103 // <synopsis>
104 // Aggregate class counting if all values in a group are true.
105 // </synopsis>
107 {
108 public:
111 virtual void apply (const TableExprId& id);
112 };
113
114 // <summary>
115 // Aggregate class counting the number of true values in a group
116 // </summary>
117 // <use visibility=local>
118 // <reviewed reviewer="" date="" tests="tExprGroup">
119 // </reviewed>
120 // <synopsis>
121 // Aggregate class counting the number of true values in a group.
122 // </synopsis>
124 {
125 public:
128 virtual void apply (const TableExprId& id);
129 };
130
131 // <summary>
132 // Aggregate class counting the number of false values in a group
133 // </summary>
134 // <use visibility=local>
135 // <reviewed reviewer="" date="" tests="tExprGroup">
136 // </reviewed>
137 // <synopsis>
138 // Aggregate class counting the number of false values in a group.
139 // </synopsis>
141 {
142 public:
145 virtual void apply (const TableExprId& id);
146 };
147
148 // <summary>
149 // Aggregate class determining the minimum integer value in a group
150 // </summary>
151 // <use visibility=local>
152 // <reviewed reviewer="" date="" tests="tExprGroup">
153 // </reviewed>
154 // <synopsis>
155 // Aggregate class determining the minimum integer value in a group.
156 // </synopsis>
158 {
159 public:
162 virtual void apply (const TableExprId& id);
163 };
164
165 // <summary>
166 // Aggregate class determining the maximum integer value in a group
167 // </summary>
168 // <use visibility=local>
169 // <reviewed reviewer="" date="" tests="tExprGroup">
170 // </reviewed>
171 // <synopsis>
172 // Aggregate class determining the maximum integer value in a group.
173 // </synopsis>
175 {
176 public:
179 virtual void apply (const TableExprId& id);
180 };
181
182 // <summary>
183 // Aggregate class determining the sum of integer values in a group
184 // </summary>
185 // <use visibility=local>
186 // <reviewed reviewer="" date="" tests="tExprGroup">
187 // </reviewed>
188 // <synopsis>
189 // Aggregate class determining the sum of integer values in a group.
190 // </synopsis>
192 {
193 public:
196 virtual void apply (const TableExprId& id);
197 };
198
199 // <summary>
200 // Aggregate class determining the product of integer values in a group
201 // </summary>
202 // <use visibility=local>
203 // <reviewed reviewer="" date="" tests="tExprGroup">
204 // </reviewed>
205 // <synopsis>
206 // Aggregate class determining the product of integer values in a group.
207 // </synopsis>
209 {
210 public:
213 virtual void apply (const TableExprId& id);
214 };
215
216 // <summary>
217 // Aggregate class determining the sum of squares of integer values in a group
218 // </summary>
219 // <use visibility=local>
220 // <reviewed reviewer="" date="" tests="tExprGroup">
221 // </reviewed>
222 // <synopsis>
223 // Aggregate class determining the sum of squares of integer values in a group.
224 // </synopsis>
226 {
227 public:
230 virtual void apply (const TableExprId& id);
231 };
232
233
234 // <summary>
235 // Aggregate class determining the minimum double value in a group
236 // </summary>
237 // <use visibility=local>
238 // <reviewed reviewer="" date="" tests="tExprGroup">
239 // </reviewed>
240 // <synopsis>
241 // Aggregate class determining the minimum double value in a group.
242 // </synopsis>
244 {
245 public:
248 virtual void apply (const TableExprId& id);
249 };
250
251 // <summary>
252 // Aggregate class determining the maximum double value in a group
253 // </summary>
254 // <use visibility=local>
255 // <reviewed reviewer="" date="" tests="tExprGroup">
256 // </reviewed>
257 // <synopsis>
258 // Aggregate class determining the maximum double value in a group.
259 // </synopsis>
261 {
262 public:
265 virtual void apply (const TableExprId& id);
266 };
267
268 // <summary>
269 // Aggregate class determining the sum 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 sum of double values in a group.
276 // </synopsis>
278 {
279 public:
282 virtual void apply (const TableExprId& id);
283 };
284
285 // <summary>
286 // Aggregate class determining the product of double values in a group
287 // </summary>
288 // <use visibility=local>
289 // <reviewed reviewer="" date="" tests="tExprGroup">
290 // </reviewed>
291 // <synopsis>
292 // Aggregate class determining the product of double values in a group.
293 // </synopsis>
301
302 // <summary>
303 // Aggregate class determining the sum of squares of double values in a group
304 // </summary>
305 // <use visibility=local>
306 // <reviewed reviewer="" date="" tests="tExprGroup">
307 // </reviewed>
308 // <synopsis>
309 // Aggregate class determining the sum of squares of double values in a group.
310 // </synopsis>
312 {
313 public:
316 virtual void apply (const TableExprId& id);
317 };
318
319 // <summary>
320 // Aggregate class determining the mean of values in a group
321 // </summary>
322 // <use visibility=local>
323 // <reviewed reviewer="" date="" tests="tExprGroup">
324 // </reviewed>
325 // <synopsis>
326 // Aggregate class determining the mean of values in a group.
327 // </synopsis>
329 {
330 public:
333 virtual void apply (const TableExprId& id);
334 virtual void finish();
335 private:
337 };
338
339 // <summary>
340 // Aggregate class determining the variance of values in a group
341 // </summary>
342 // <use visibility=local>
343 // <reviewed reviewer="" date="" tests="tExprGroup">
344 // </reviewed>
345 // <synopsis>
346 // Aggregate class determining the variance of values in a group.
347 // It uses a running algorithm
348 // (see en.wikipedia.org/wiki/Algorithms_for_calculating_variance)
349 // </synopsis>
351 {
352 public:
355 virtual void apply (const TableExprId& id);
356 virtual void finish();
357 protected:
361 };
362
363 // <summary>
364 // Aggregate class determining the standard deviation of values in a group
365 // </summary>
366 // <use visibility=local>
367 // <reviewed reviewer="" date="" tests="tExprGroup">
368 // </reviewed>
369 // <synopsis>
370 // Aggregate class determining the standard deviation of values in a group.
371 // It uses a running algorithm
372 // (see en.wikipedia.org/wiki/Algorithms_for_calculating_variance)
373 // </synopsis>
381
382 // <summary>
383 // Aggregate class determining the RMS 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 RMS of values in a group.
390 // </synopsis>
392 {
393 public:
396 virtual void apply (const TableExprId& id);
397 virtual void finish();
398 private:
400 };
401
402 // <summary>
403 // Aggregate class determining the fractile of values in a group
404 // </summary>
405 // <use visibility=local>
406 // <reviewed reviewer="" date="" tests="tExprGroup">
407 // </reviewed>
408 // <synopsis>
409 // Aggregate class determining the fractile of values in a group.
410 // <br>It is a lazy aggregate class, thus <src>apply</src> does nothing.
411 // Instead, <src>getDouble</src> assembles the values and determines the
412 // fractile.
413 // </synopsis>
415 {
416 public:
420 virtual Bool isLazy() const;
421 virtual void apply (const TableExprId& id);
422 virtual Double getDouble (const vector<TableExprId>& ids);
423 private:
425 };
426
427
428 // <summary>
429 // Aggregate class determining the sum of complex values in a group
430 // </summary>
431 // <use visibility=local>
432 // <reviewed reviewer="" date="" tests="tExprGroup">
433 // </reviewed>
434 // <synopsis>
435 // Aggregate class determining the sum of complex values in a group.
436 // </synopsis>
438 {
439 public:
442 virtual void apply (const TableExprId& id);
443 };
444
445 // <summary>
446 // Aggregate class determining the product of complex values in a group
447 // </summary>
448 // <use visibility=local>
449 // <reviewed reviewer="" date="" tests="tExprGroup">
450 // </reviewed>
451 // <synopsis>
452 // Aggregate class determining the product of complex values in a group.
453 // </synopsis>
461
462 // <summary>
463 // Aggregate class determining the sum of squares of complex values in a group
464 // </summary>
465 // <use visibility=local>
466 // <reviewed reviewer="" date="" tests="tExprGroup">
467 // </reviewed>
468 // <synopsis>
469 // Aggregate class determining the sum of squares of complex values in a group.
470 // </synopsis>
478
479 // <summary>
480 // Aggregate class determining the mean of complex values in a group
481 // </summary>
482 // <use visibility=local>
483 // <reviewed reviewer="" date="" tests="tExprGroup">
484 // </reviewed>
485 // <synopsis>
486 // Aggregate class determining the mean of complex values in a group.
487 // </synopsis>
489 {
490 public:
493 virtual void apply (const TableExprId& id);
494 virtual void finish();
495 private:
497 };
498
499 // <summary>
500 // Aggregate class determining the variance 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 variance of values in a group.
507 // It uses a running algorithm
508 // (see en.wikipedia.org/wiki/Algorithms_for_calculating_variance)
509 // Note that the result is a Double value (not DComplex).
510 // </synopsis>
512 {
513 public:
516 virtual void apply (const TableExprId& id);
517 virtual void finish();
518 protected:
521 DComplex itsCurMean;
522 };
523
524 // <summary>
525 // Aggregate class determining the standard deviation of values in a group
526 // </summary>
527 // <use visibility=local>
528 // <reviewed reviewer="" date="" tests="tExprGroup">
529 // </reviewed>
530 // <synopsis>
531 // Aggregate class determining the standard deviation of values in a group.
532 // It uses a running algorithm
533 // (see en.wikipedia.org/wiki/Algorithms_for_calculating_variance)
534 // </synopsis>
542
543
544} //# NAMESPACE CASACORE - END
545
546#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:469
TableExprGroupFuncDComplex(TableExprNodeRep *node, const DComplex &initValue=DComplex())
Definition ExprGroup.h:552
TableExprGroupFuncDouble(TableExprNodeRep *node, Double initValue=0)
Definition ExprGroup.h:525
TableExprGroupFuncInt(TableExprNodeRep *node, Int64 initValue=0)
Definition ExprGroup.h:498
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.
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: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