ExprGroupAggrFunc.h

Go to the documentation of this file.
00001 //# ExprGroupAggrFunc.h: The various scalar aggregation functions
00002 //# Copyright (C) 2013
00003 //# Associated Universities, Inc. Washington DC, USA.
00004 //#
00005 //# This library is free software; you can redistribute it and/or modify it
00006 //# under the terms of the GNU Library General Public License as published by
00007 //# the Free Software Foundation; either version 2 of the License, or (at your
00008 //# option) any later version.
00009 //#
00010 //# This library is distributed in the hope that it will be useful, but WITHOUT
00011 //# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00012 //# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library General Public
00013 //# License for more details.
00014 //#
00015 //# You should have received a copy of the GNU Library General Public License
00016 //# along with this library; if not, write to the Free Software Foundation,
00017 //# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA.
00018 //#
00019 //# Correspondence concerning AIPS++ should be addressed as follows:
00020 //#        Internet email: aips2-request@nrao.edu.
00021 //#        Postal address: AIPS++ Project Office
00022 //#                        National Radio Astronomy Observatory
00023 //#                        520 Edgemont Road
00024 //#                        Charlottesville, VA 22903-2475 USA
00025 //#
00026 //# $Id: TaQLNode.h 21051 2011-04-20 11:46:29Z gervandiepen $
00027 
00028 #ifndef TABLES_EXPRGROUPAGGRFUNC_H
00029 #define TABLES_EXPRGROUPAGGRFUNC_H
00030 
00031 //# Includes
00032 #include <casacore/casa/aips.h>
00033 #include <casacore/tables/TaQL/ExprGroup.h>
00034 #include <vector>
00035 
00036 
00037 namespace casacore { //# NAMESPACE CASACORE - BEGIN
00038 
00039   //# Forward Declaration
00040   class TableExprNodeArrayColumn;
00041 
00042 
00043   // <summary>
00044   // Aggregate class counting number of rows in a group
00045   // </summary>
00046   // <use visibility=local>
00047   // <reviewed reviewer="" date="" tests="tExprGroup">
00048   // </reviewed>
00049   // <synopsis>
00050   // Aggregate class counting number of rows in a group.
00051   // </synopsis>
00052   class TableExprGroupCountAll: public TableExprGroupFuncInt
00053   {
00054   public:
00055     explicit TableExprGroupCountAll (TableExprNodeRep* node);
00056     virtual ~TableExprGroupCountAll();
00057     virtual void apply (const TableExprId& id);
00058     // Set result in case it is known directly.
00059     void setResult (Int64 cnt)
00060       { itsValue = cnt; }
00061   };
00062 
00063   // <summary>
00064   // Aggregate class counting number of rows in a group containing a value
00065   // </summary>
00066   // <use visibility=local>
00067   // <reviewed reviewer="" date="" tests="tExprGroup">
00068   // </reviewed>
00069   // <synopsis>
00070   // Aggregate class counting number of rows in a group containing a value.
00071   // </synopsis>
00072   class TableExprGroupCount: public TableExprGroupFuncInt
00073   {
00074   public:
00075     explicit TableExprGroupCount (TableExprNodeRep* node);
00076     virtual ~TableExprGroupCount();
00077     virtual void apply (const TableExprId& id);
00078   private:
00079     TableExprNodeArrayColumn* itsColumn;
00080   };
00081 
00082   // <summary>
00083   // Aggregate class counting if any value in a group is true
00084   // </summary>
00085   // <use visibility=local>
00086   // <reviewed reviewer="" date="" tests="tExprGroup">
00087   // </reviewed>
00088   // <synopsis>
00089   // Aggregate class counting if any value in a group is true.
00090   // </synopsis>
00091   class TableExprGroupAny: public TableExprGroupFuncBool
00092   {
00093   public:
00094     explicit TableExprGroupAny (TableExprNodeRep* node);
00095     virtual ~TableExprGroupAny();
00096     virtual void apply (const TableExprId& id);
00097   };
00098 
00099   // <summary>
00100   // Aggregate class counting if all values in a group are true
00101   // </summary>
00102   // <use visibility=local>
00103   // <reviewed reviewer="" date="" tests="tExprGroup">
00104   // </reviewed>
00105   // <synopsis>
00106   // Aggregate class counting if all values in a group are true.
00107   // </synopsis>
00108   class TableExprGroupAll: public TableExprGroupFuncBool
00109   {
00110   public:
00111     explicit TableExprGroupAll (TableExprNodeRep* node);
00112     virtual ~TableExprGroupAll();
00113     virtual void apply (const TableExprId& id);
00114   };
00115 
00116   // <summary>
00117   // Aggregate class counting the number of true values in a group
00118   // </summary>
00119   // <use visibility=local>
00120   // <reviewed reviewer="" date="" tests="tExprGroup">
00121   // </reviewed>
00122   // <synopsis>
00123   // Aggregate class counting the number of true values in a group.
00124   // </synopsis>
00125   class TableExprGroupNTrue: public TableExprGroupFuncInt
00126   {
00127   public:
00128     explicit TableExprGroupNTrue (TableExprNodeRep* node);
00129     virtual ~TableExprGroupNTrue();
00130     virtual void apply (const TableExprId& id);
00131   };
00132 
00133   // <summary>
00134   // Aggregate class counting the number of false values in a group
00135   // </summary>
00136   // <use visibility=local>
00137   // <reviewed reviewer="" date="" tests="tExprGroup">
00138   // </reviewed>
00139   // <synopsis>
00140   // Aggregate class counting the number of false values in a group.
00141   // </synopsis>
00142   class TableExprGroupNFalse: public TableExprGroupFuncInt
00143   {
00144   public:
00145     explicit TableExprGroupNFalse (TableExprNodeRep* node);
00146     virtual ~TableExprGroupNFalse();
00147     virtual void apply (const TableExprId& id);
00148   };
00149 
00150   // <summary>
00151   // Aggregate class determining the minimum integer value in a group
00152   // </summary>
00153   // <use visibility=local>
00154   // <reviewed reviewer="" date="" tests="tExprGroup">
00155   // </reviewed>
00156   // <synopsis>
00157   // Aggregate class determining the minimum integer value in a group.
00158   // </synopsis>
00159   class TableExprGroupMinInt: public TableExprGroupFuncInt
00160   {
00161   public:
00162     explicit TableExprGroupMinInt (TableExprNodeRep* node);
00163     virtual ~TableExprGroupMinInt();
00164     virtual void apply (const TableExprId& id);
00165   };
00166 
00167   // <summary>
00168   // Aggregate class determining the maximum integer value in a group
00169   // </summary>
00170   // <use visibility=local>
00171   // <reviewed reviewer="" date="" tests="tExprGroup">
00172   // </reviewed>
00173   // <synopsis>
00174   // Aggregate class determining the maximum integer value in a group.
00175   // </synopsis>
00176   class TableExprGroupMaxInt: public TableExprGroupFuncInt
00177   {
00178   public:
00179     explicit TableExprGroupMaxInt (TableExprNodeRep* node);
00180     virtual ~TableExprGroupMaxInt();
00181     virtual void apply (const TableExprId& id);
00182   };
00183 
00184   // <summary>
00185   // Aggregate class determining the sum of integer values in a group
00186   // </summary>
00187   // <use visibility=local>
00188   // <reviewed reviewer="" date="" tests="tExprGroup">
00189   // </reviewed>
00190   // <synopsis>
00191   // Aggregate class determining the sum of integer values in a group.
00192   // </synopsis>
00193   class TableExprGroupSumInt: public TableExprGroupFuncInt
00194   {
00195   public:
00196     explicit TableExprGroupSumInt (TableExprNodeRep* node);
00197     virtual ~TableExprGroupSumInt();
00198     virtual void apply (const TableExprId& id);
00199   };
00200 
00201   // <summary>
00202   // Aggregate class determining the product of integer values in a group
00203   // </summary>
00204   // <use visibility=local>
00205   // <reviewed reviewer="" date="" tests="tExprGroup">
00206   // </reviewed>
00207   // <synopsis>
00208   // Aggregate class determining the product of integer values in a group.
00209   // </synopsis>
00210   class TableExprGroupProductInt: public TableExprGroupFuncInt
00211   {
00212   public:
00213     explicit TableExprGroupProductInt (TableExprNodeRep* node);
00214     virtual ~TableExprGroupProductInt();
00215     virtual void apply (const TableExprId& id);
00216   };
00217 
00218   // <summary>
00219   // Aggregate class determining the sum of squares of integer values in a group
00220   // </summary>
00221   // <use visibility=local>
00222   // <reviewed reviewer="" date="" tests="tExprGroup">
00223   // </reviewed>
00224   // <synopsis>
00225   // Aggregate class determining the sum of squares of integer values in a group.
00226   // </synopsis>
00227   class TableExprGroupSumSqrInt: public TableExprGroupFuncInt
00228   {
00229   public:
00230     explicit TableExprGroupSumSqrInt (TableExprNodeRep* node);
00231     virtual ~TableExprGroupSumSqrInt();
00232     virtual void apply (const TableExprId& id);
00233   };
00234 
00235 
00236   // <summary>
00237   // Aggregate class determining the minimum double value in a group
00238   // </summary>
00239   // <use visibility=local>
00240   // <reviewed reviewer="" date="" tests="tExprGroup">
00241   // </reviewed>
00242   // <synopsis>
00243   // Aggregate class determining the minimum double value in a group.
00244   // </synopsis>
00245   class TableExprGroupMinDouble: public TableExprGroupFuncDouble
00246   {
00247   public:
00248     explicit TableExprGroupMinDouble (TableExprNodeRep* node);
00249     virtual ~TableExprGroupMinDouble();
00250     virtual void apply (const TableExprId& id);
00251   };
00252 
00253   // <summary>
00254   // Aggregate class determining the maximum double value in a group
00255   // </summary>
00256   // <use visibility=local>
00257   // <reviewed reviewer="" date="" tests="tExprGroup">
00258   // </reviewed>
00259   // <synopsis>
00260   // Aggregate class determining the maximum double value in a group.
00261   // </synopsis>
00262   class TableExprGroupMaxDouble: public TableExprGroupFuncDouble
00263   {
00264   public:
00265     explicit TableExprGroupMaxDouble (TableExprNodeRep* node);
00266     virtual ~TableExprGroupMaxDouble();
00267     virtual void apply (const TableExprId& id);
00268   };
00269 
00270   // <summary>
00271   // Aggregate class determining the sum of double values in a group
00272   // </summary>
00273   // <use visibility=local>
00274   // <reviewed reviewer="" date="" tests="tExprGroup">
00275   // </reviewed>
00276   // <synopsis>
00277   // Aggregate class determining the sum of double values in a group.
00278   // </synopsis>
00279   class TableExprGroupSumDouble: public TableExprGroupFuncDouble
00280   {
00281   public:
00282     explicit TableExprGroupSumDouble (TableExprNodeRep* node);
00283     virtual ~TableExprGroupSumDouble();
00284     virtual void apply (const TableExprId& id);
00285   };
00286 
00287   // <summary>
00288   // Aggregate class determining the product of double values in a group
00289   // </summary>
00290   // <use visibility=local>
00291   // <reviewed reviewer="" date="" tests="tExprGroup">
00292   // </reviewed>
00293   // <synopsis>
00294   // Aggregate class determining the product of double values in a group.
00295   // </synopsis>
00296   class TableExprGroupProductDouble: public TableExprGroupFuncDouble
00297   {
00298   public:
00299     explicit TableExprGroupProductDouble (TableExprNodeRep* node);
00300     virtual ~TableExprGroupProductDouble();
00301     virtual void apply (const TableExprId& id);
00302   };
00303 
00304   // <summary>
00305   // Aggregate class determining the sum of squares of double values in a group
00306   // </summary>
00307   // <use visibility=local>
00308   // <reviewed reviewer="" date="" tests="tExprGroup">
00309   // </reviewed>
00310   // <synopsis>
00311   // Aggregate class determining the sum of squares of double values in a group.
00312   // </synopsis>
00313   class TableExprGroupSumSqrDouble: public TableExprGroupFuncDouble
00314   {
00315   public:
00316     explicit TableExprGroupSumSqrDouble (TableExprNodeRep* node);
00317     virtual ~TableExprGroupSumSqrDouble();
00318     virtual void apply (const TableExprId& id);
00319   };
00320 
00321   // <summary>
00322   // Aggregate class determining the mean of values in a group
00323   // </summary>
00324   // <use visibility=local>
00325   // <reviewed reviewer="" date="" tests="tExprGroup">
00326   // </reviewed>
00327   // <synopsis>
00328   // Aggregate class determining the mean of values in a group.
00329   // </synopsis>
00330   class TableExprGroupMeanDouble: public TableExprGroupFuncDouble
00331   {
00332   public:
00333     explicit TableExprGroupMeanDouble (TableExprNodeRep* node);
00334     virtual ~TableExprGroupMeanDouble();
00335     virtual void apply (const TableExprId& id);
00336     virtual void finish();
00337   private:
00338     Int64 itsNr;
00339   };
00340 
00341   // <summary>
00342   // Aggregate class determining the variance of values in a group
00343   // </summary>
00344   // <use visibility=local>
00345   // <reviewed reviewer="" date="" tests="tExprGroup">
00346   // </reviewed>
00347   // <synopsis>
00348   // Aggregate class determining the variance of values in a group.
00349   // It uses a running algorithm
00350   // (see en.wikipedia.org/wiki/Algorithms_for_calculating_variance)
00351   // </synopsis>
00352   class TableExprGroupVarianceDouble: public TableExprGroupFuncDouble
00353   {
00354   public:
00355     explicit TableExprGroupVarianceDouble (TableExprNodeRep* node);
00356     virtual ~TableExprGroupVarianceDouble();
00357     virtual void apply (const TableExprId& id);
00358     virtual void finish();
00359   protected:
00360     Int64  itsNr;
00361     Double itsM2;
00362   };
00363 
00364   // <summary>
00365   // Aggregate class determining the standard deviation of values in a group
00366   // </summary>
00367   // <use visibility=local>
00368   // <reviewed reviewer="" date="" tests="tExprGroup">
00369   // </reviewed>
00370   // <synopsis>
00371   // Aggregate class determining the standard deviation of values in a group.
00372   // It uses a running algorithm
00373   // (see en.wikipedia.org/wiki/Algorithms_for_calculating_variance)
00374   // </synopsis>
00375   class TableExprGroupStdDevDouble: public TableExprGroupVarianceDouble
00376   {
00377   public:
00378     explicit TableExprGroupStdDevDouble (TableExprNodeRep* node);
00379     virtual ~TableExprGroupStdDevDouble();
00380     virtual void finish();
00381   };
00382 
00383   // <summary>
00384   // Aggregate class determining the RMS of values in a group
00385   // </summary>
00386   // <use visibility=local>
00387   // <reviewed reviewer="" date="" tests="tExprGroup">
00388   // </reviewed>
00389   // <synopsis>
00390   // Aggregate class determining the RMS of values in a group.
00391   // </synopsis>
00392   class TableExprGroupRmsDouble: public TableExprGroupFuncDouble
00393   {
00394   public:
00395     explicit TableExprGroupRmsDouble (TableExprNodeRep* node);
00396     virtual ~TableExprGroupRmsDouble();
00397     virtual void apply (const TableExprId& id);
00398     virtual void finish();
00399   private:
00400     Int64 itsNr;
00401   };
00402 
00403   // <summary>
00404   // Aggregate class determining the fractile of values in a group
00405   // </summary>
00406   // <use visibility=local>
00407   // <reviewed reviewer="" date="" tests="tExprGroup">
00408   // </reviewed>
00409   // <synopsis>
00410   // Aggregate class determining the fractile of values in a group.
00411   // <br>It is a lazy aggregate class, thus <src>apply</src> does nothing.
00412   // Instead, <src>getDouble</src> assembles the values and determines the
00413   // fractile.
00414   // </synopsis>
00415   class TableExprGroupFractileDouble: public TableExprGroupFuncDouble
00416   {
00417   public:
00418     explicit TableExprGroupFractileDouble (TableExprNodeRep* node,
00419                                            Double fractile);
00420     virtual ~TableExprGroupFractileDouble();
00421     virtual Bool isLazy() const;
00422     virtual void apply (const TableExprId& id);
00423     virtual Double getDouble (const vector<TableExprId>& ids);
00424   private:
00425     Double itsFrac;
00426   };
00427 
00428 
00429   // <summary>
00430   // Aggregate class determining the sum of complex values in a group
00431   // </summary>
00432   // <use visibility=local>
00433   // <reviewed reviewer="" date="" tests="tExprGroup">
00434   // </reviewed>
00435   // <synopsis>
00436   // Aggregate class determining the sum of complex values in a group.
00437   // </synopsis>
00438   class TableExprGroupSumDComplex: public TableExprGroupFuncDComplex
00439   {
00440   public:
00441     explicit TableExprGroupSumDComplex (TableExprNodeRep* node);
00442     virtual ~TableExprGroupSumDComplex();
00443     virtual void apply (const TableExprId& id);
00444   };
00445 
00446   // <summary>
00447   // Aggregate class determining the product of complex values in a group
00448   // </summary>
00449   // <use visibility=local>
00450   // <reviewed reviewer="" date="" tests="tExprGroup">
00451   // </reviewed>
00452   // <synopsis>
00453   // Aggregate class determining the product of complex values in a group.
00454   // </synopsis>
00455   class TableExprGroupProductDComplex: public TableExprGroupFuncDComplex
00456   {
00457   public:
00458     explicit TableExprGroupProductDComplex (TableExprNodeRep* node);
00459     virtual ~TableExprGroupProductDComplex();
00460     virtual void apply (const TableExprId& id);
00461   };
00462 
00463   // <summary>
00464   // Aggregate class determining the sum of squares of complex values in a group
00465   // </summary>
00466   // <use visibility=local>
00467   // <reviewed reviewer="" date="" tests="tExprGroup">
00468   // </reviewed>
00469   // <synopsis>
00470   // Aggregate class determining the sum of squares of complex values in a group.
00471   // </synopsis>
00472   class TableExprGroupSumSqrDComplex: public TableExprGroupFuncDComplex
00473   {
00474   public:
00475     explicit TableExprGroupSumSqrDComplex (TableExprNodeRep* node);
00476     virtual ~TableExprGroupSumSqrDComplex();
00477     virtual void apply (const TableExprId& id);
00478   };
00479 
00480   // <summary>
00481   // Aggregate class determining the mean of complex values in a group
00482   // </summary>
00483   // <use visibility=local>
00484   // <reviewed reviewer="" date="" tests="tExprGroup">
00485   // </reviewed>
00486   // <synopsis>
00487   // Aggregate class determining the mean of complex values in a group.
00488   // </synopsis>
00489   class TableExprGroupMeanDComplex: public TableExprGroupFuncDComplex
00490   {
00491   public:
00492     explicit TableExprGroupMeanDComplex (TableExprNodeRep* node);
00493     virtual ~TableExprGroupMeanDComplex();
00494     virtual void apply (const TableExprId& id);
00495     virtual void finish();
00496   private:
00497     Int64 itsNr;
00498   };
00499 
00500 
00501 } //# NAMESPACE CASACORE - END
00502 
00503 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

Generated on 31 Aug 2016 for casa by  doxygen 1.6.1