casa  $Rev:20696$
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
LattStatsSpecialize.h
Go to the documentation of this file.
00001 //# LattStatsSpecialize.h: specialized functions for LatticeStatistics
00002 //# Copyright (C) 1996,1997,1998,1999,2000,2001,2002,2003
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: LattStatsSpecialize.h 18093 2004-11-30 17:51:10Z ddebonis $
00027 
00028 #ifndef LATTICES_LATTSTATSSPECIALIZE_H
00029 #define LATTICES_LATTSTATSSPECIALIZE_H
00030 
00031 
00032 //# Includes
00033 #include <casa/aips.h>
00034 #include <casa/BasicSL/Complex.h>
00035 namespace casa { //# NAMESPACE CASA - BEGIN
00036 
00037 template <class T> class Vector;
00038 template <class T> class Array;
00039 template <class T> class Lattice;
00040 template <class T> class MaskedLattice;
00041 class LatticeExprNode;
00042 class String;
00043 class IPosition;
00044 
00045 
00046 
00047 // <summary>  </summary>
00048 // <use visibility=export>
00049 //
00050 // <reviewed reviewer="" date="yyyy/mm/dd" tests="" demos="">
00051 // </reviewed>
00052 //
00053 // <prerequisite>
00054 // </prerequisite>
00055 //
00056 // <etymology>
00057 // </etymology>
00058 //
00059 // <synopsis>
00060 // </synopsis>
00061 // 
00062 // <motivation>
00063 // </motivation>
00064 // 
00065 // <todo asof="1998/01/10">
00066 // </todo>
00067  
00068 
00069 class LattStatsSpecialize
00070 {
00071 public:
00072 
00073    // in this version we maintain a running mean and variance to avoid catastrophic round-off
00074    // issues that can happen in some cases, CAS-2226. Removing old versions in which these
00075         // quantities were not accumulated - dmehring 2011mar01
00076    static void accumulate (
00077                 Double& nPts, Double& sum,
00078                 Double& mean, Double& nvariance, Double& variance,
00079                 Double& sumSq, Float& dataMin,
00080                 Float& dataMax, Int& minPos,
00081                 Int& maxPos, Bool& minMaxInit,
00082                 const Bool fixedMinMax, const Float datum,
00083                 const uInt& pos, const Float useIt
00084         );
00085 
00086    static void accumulate (DComplex& nPts, DComplex& sum,
00087                                                    DComplex& mean, DComplex& nvariance,DComplex& variance,
00088                            DComplex& sumSq, Complex& dataMin,
00089                            Complex& dataMax, const Int& minPos,
00090                            const Int& maxPos, Bool& minMaxInit,
00091                            const Bool fixedMinMax, const Complex datum,
00092                            const uInt& pos, const Complex useIt);
00093 
00094    static Bool hasSomePoints (Double npts);
00095    static Bool hasSomePoints (DComplex npts);
00096 //
00097    static void setUseItTrue (Float& useIt);
00098    static void setUseItTrue (Complex& useIt);
00099 //
00100    static Float usePixelInc (Float dMin, Float dMax, Float datum);
00101    static Complex usePixelInc (Complex dMin, Complex dMax, Complex datum);
00102 //
00103    static Float usePixelExc (Float dMin, Float dMax, Float datum);
00104    static Complex usePixelExc (Complex dMin, Complex dMax, Complex datum);
00105 //
00106    static Double getMean (Double sum, Double n);
00107    static DComplex getMean (DComplex sum, DComplex n);
00108 //
00109    static Double getVariance (Double sum, Double sumsq, Double n);
00110    static DComplex getVariance (DComplex sum, DComplex sumsq, DComplex n);
00111 //
00112    static Double getSigma (Double sum, Double sumsq, Double n);
00113    static DComplex getSigma (DComplex sum, DComplex sumsq, DComplex n);
00114 //
00115    static Double getSigma (Double var);
00116    static DComplex getSigma (DComplex var);
00117 //
00118    static Double getRms (Double sumsq, Double n);
00119    static DComplex getRms (DComplex sumsq, DComplex n);
00120 //
00121    static Float min(Float v1, Float v2);
00122    static Complex min(Complex v1, Complex v2);
00123 //
00124    static Float max(Float v1, Float v2);
00125    static Complex max(Complex v1, Complex v2);
00126 //
00127    static Float getNodeScalarValue(const LatticeExprNode& node, Float);
00128    static Complex getNodeScalarValue(const LatticeExprNode& node, Complex);
00129 //
00130    static Bool setIncludeExclude (String& errorMessage,
00131                                   Vector<Float>& range,
00132                                   Bool& noInclude, Bool& noExclude,
00133                                   const Vector<Float>& include,  
00134                                   const Vector<Float>& exclude);
00135    static Bool setIncludeExclude (String& errorMessage,
00136                                   Vector<Complex>& range,
00137                                   Bool& noInclude, Bool& noExclude,
00138                                   const Vector<Complex>& include,  
00139                                   const Vector<Complex>& exclude);
00140 //
00141    static Bool minMax (Float& dataMin, Float& dataMax, const MaskedLattice<Float>* pLattice,
00142                        const Vector<Float>& range, Bool noInclude, Bool noExclude);
00143    static Bool minMax (Complex& dataMin, Complex& dataMax, const MaskedLattice<Complex>* pLattice,
00144                        const Vector<Complex>& range, Bool noInclude, Bool noExclude);
00145 };
00146 
00147 
00148 } //# NAMESPACE CASA - END
00149 
00150 #endif
00151