00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027 #ifndef SCIMATH_CLASSICALSTATS_H
00028 #define SCIMATH_CLASSICALSTATS_H
00029
00030 #include <casacore/casa/aips.h>
00031
00032 #include <casacore/scimath/Mathematics/StatisticsAlgorithm.h>
00033
00034 #include <casacore/scimath/Mathematics/StatisticsTypes.h>
00035 #include <casacore/scimath/Mathematics/StatisticsUtilities.h>
00036
00037 #include <set>
00038 #include <vector>
00039 #include <utility>
00040
00041 namespace casacore {
00042
00043 template <class T> class PtrHolder;
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059 template <class AccumType, class DataIterator, class MaskIterator=const Bool*, class WeightsIterator=DataIterator>
00060 class ClassicalStatistics
00061 : public StatisticsAlgorithm<AccumType, DataIterator, MaskIterator, WeightsIterator> {
00062 public:
00063
00064 ClassicalStatistics();
00065
00066
00067 ClassicalStatistics(const ClassicalStatistics<AccumType, DataIterator, MaskIterator, WeightsIterator>& cs);
00068
00069 virtual ~ClassicalStatistics();
00070
00071
00072 ClassicalStatistics<AccumType, DataIterator, MaskIterator, WeightsIterator>& operator=(
00073 const ClassicalStatistics<AccumType, DataIterator, MaskIterator, WeightsIterator>& other
00074 );
00075
00076
00077 virtual StatisticsData::ALGORITHM algorithm() const {
00078 return StatisticsData::CLASSICAL;
00079 };
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099
00100
00101
00102
00103
00104
00105
00106
00107
00108
00109
00110
00111
00112
00113
00114
00115
00116
00117
00118
00119
00120
00121
00122
00123
00124
00125
00126 virtual AccumType getMedian(
00127 CountedPtr<uInt64> knownNpts=NULL, CountedPtr<AccumType> knownMin=NULL,
00128 CountedPtr<AccumType> knownMax=NULL, uInt binningThreshholdSizeBytes=4096*4096,
00129 Bool persistSortedArray=False, uInt64 nBins=10000
00130 );
00131
00132
00133
00134
00135
00136
00137
00138 virtual AccumType getMedianAndQuantiles(
00139 std::map<Double, AccumType>& quantiles, const std::set<Double>& fractions,
00140 CountedPtr<uInt64> knownNpts=NULL, CountedPtr<AccumType> knownMin=NULL,
00141 CountedPtr<AccumType> knownMax=NULL,
00142 uInt binningThreshholdSizeBytes=4096*4096, Bool persistSortedArray=False,
00143 uInt64 nBins=10000
00144 );
00145
00146
00147 virtual AccumType getMedianAbsDevMed(
00148 CountedPtr<uInt64> knownNpts=NULL,
00149 CountedPtr<AccumType> knownMin=NULL, CountedPtr<AccumType> knownMax=NULL,
00150 uInt binningThreshholdSizeBytes=4096*4096, Bool persistSortedArray=False,
00151 uInt64 nBins=10000
00152 );
00153
00154
00155
00156 virtual std::map<Double, AccumType> getQuantiles(
00157 const std::set<Double>& fractions, CountedPtr<uInt64> knownNpts=NULL,
00158 CountedPtr<AccumType> knownMin=NULL, CountedPtr<AccumType> knownMax=NULL,
00159 uInt binningThreshholdSizeBytes=4096*4096, Bool persistSortedArray=False,
00160 uInt64 nBins=10000
00161 );
00162
00163
00164
00165
00166
00167
00168
00169 virtual void getMinMax(AccumType& mymin, AccumType& mymax);
00170
00171
00172
00173
00174
00175 virtual uInt64 getNPts();
00176
00177
00178 virtual std::pair<Int64, Int64> getStatisticIndex(StatisticsData::STATS stat);
00179
00180
00181
00182 Bool hasData() const { return _hasData; }
00183
00184
00185
00186 virtual void reset();
00187
00188
00189
00190
00191
00192 virtual void setCalculateAsAdded(Bool c);
00193
00194
00195 void setDataProvider(StatsDataProvider<AccumType, DataIterator, MaskIterator, WeightsIterator> *dataProvider);
00196
00197 void setStatsToCalculate(std::set<StatisticsData::STATS>& stats);
00198
00199 protected:
00200
00201
00202
00203
00204
00205
00206 inline virtual void _accumNpts(
00207 uInt64& npts,
00208 const DataIterator& dataBegin, Int64 nr, uInt dataStride
00209 ) const;
00210
00211 virtual void _accumNpts(
00212 uInt64& npts,
00213 const DataIterator& dataBegin, Int64 nr, uInt dataStride,
00214 const DataRanges& ranges, Bool isInclude
00215 ) const;
00216
00217 virtual void _accumNpts(
00218 uInt64& npts,
00219 const DataIterator& dataBegin, Int64 nr, uInt dataStride,
00220 const MaskIterator& maskBegin, uInt maskStride
00221 ) const;
00222
00223 virtual void _accumNpts(
00224 uInt64& npts,
00225 const DataIterator& dataBegin, Int64 nr, uInt dataStride,
00226 const MaskIterator& maskBegin, uInt maskStride, const DataRanges& ranges,
00227 Bool isInclude
00228 ) const;
00229
00230 virtual void _accumNpts(
00231 uInt64& npts,
00232 const DataIterator& dataBegin, const WeightsIterator& weightsBegin,
00233 Int64 nr, uInt dataStride
00234 ) const;
00235
00236 virtual void _accumNpts(
00237 uInt64& npts,
00238 const DataIterator& dataBegin, const WeightsIterator& weightsBegin,
00239 Int64 nr, uInt dataStride, const DataRanges& ranges, Bool isInclude
00240 ) const;
00241
00242 virtual void _accumNpts(
00243 uInt64& npts,
00244 const DataIterator& dataBegin, const WeightsIterator& weightsBegin,
00245 Int64 nr, uInt dataStride, const MaskIterator& maskBegin, uInt maskStride,
00246 const DataRanges& ranges, Bool isInclude
00247 ) const;
00248
00249 virtual void _accumNpts(
00250 uInt64& npts,
00251 const DataIterator& dataBegin, const WeightsIterator& weightBegin,
00252 Int64 nr, uInt dataStride, const MaskIterator& maskBegin, uInt maskStride
00253 ) const;
00254
00255
00256
00257 inline void _accumulate(
00258 StatsData<AccumType>& stats, const AccumType& datum,
00259 const LocationType& location
00260 );
00261
00262 inline void _accumulate(
00263 StatsData<AccumType>& stats, const AccumType& datum,
00264 const AccumType& weight, const LocationType& location
00265 );
00266
00267
00268 void _addData();
00269
00270 void _clearData();
00271
00272 void _clearStats();
00273
00274
00275 void _doMinMax(AccumType& vmin, AccumType& vmax);
00276
00277
00278
00279
00280
00281
00282 virtual void _findBins(
00283 vector<vector<uInt64> >& binCounts,
00284 vector<CountedPtr<AccumType> >& sameVal, vector<Bool>& allSame,
00285 const DataIterator& dataBegin, Int64 nr, uInt dataStride,
00286 const vector<typename StatisticsUtilities<AccumType>::BinDesc>& binDesc,
00287 const vector<AccumType>& maxLimit
00288 ) const;
00289
00290 virtual void _findBins(
00291 vector<vector<uInt64> >& binCounts,
00292 vector<CountedPtr<AccumType> >& sameVal, vector<Bool>& allSame,
00293 const DataIterator& dataBegin, Int64 nr, uInt dataStride,
00294 const DataRanges& ranges, Bool isInclude,
00295 const vector<typename StatisticsUtilities<AccumType>::BinDesc>& binDesc, const vector<AccumType>& maxLimit
00296 ) const;
00297
00298 virtual void _findBins(
00299 vector<vector<uInt64> >& binCounts,
00300 vector<CountedPtr<AccumType> >& sameVal, vector<Bool>& allSame,
00301 const DataIterator& dataBegin, Int64 nr, uInt dataStride,
00302 const MaskIterator& maskBegin, uInt maskStride,
00303 const vector<typename StatisticsUtilities<AccumType>::BinDesc>& binDesc, const vector<AccumType>& maxLimit
00304 ) const;
00305
00306 virtual void _findBins(
00307 vector<vector<uInt64> >& binCounts,
00308 vector<CountedPtr<AccumType> >& sameVal, vector<Bool>& allSame,
00309 const DataIterator& dataBegin, Int64 nr, uInt dataStride,
00310 const MaskIterator& maskBegin, uInt maskStride, const DataRanges& ranges,
00311 Bool isInclude,
00312 const vector<typename StatisticsUtilities<AccumType>::BinDesc>& binDesc, const vector<AccumType>& maxLimit
00313 ) const;
00314
00315 virtual void _findBins(
00316 vector<vector<uInt64> >& binCounts,
00317 vector<CountedPtr<AccumType> >& sameVal, vector<Bool>& allSame,
00318 const DataIterator& dataBegin, const WeightsIterator& weightsBegin,
00319 Int64 nr, uInt dataStride,
00320 const vector<typename StatisticsUtilities<AccumType>::BinDesc>& binDesc, const vector<AccumType>& maxLimit
00321 ) const ;
00322
00323 virtual void _findBins(
00324 vector<vector<uInt64> >& binCounts,
00325 vector<CountedPtr<AccumType> >& sameVal, vector<Bool>& allSame,
00326 const DataIterator& dataBegin, const WeightsIterator& weightsBegin,
00327 Int64 nr, uInt dataStride, const DataRanges& ranges, Bool isInclude,
00328 const vector<typename StatisticsUtilities<AccumType>::BinDesc>& binDesc, const vector<AccumType>& maxLimit
00329 ) const;
00330
00331 virtual void _findBins(
00332 vector<vector<uInt64> >& binCounts,
00333 vector<CountedPtr<AccumType> >& sameVal, vector<Bool>& allSame,
00334 const DataIterator& dataBegin, const WeightsIterator& weightsBegin,
00335 Int64 nr, uInt dataStride, const MaskIterator& maskBegin, uInt maskStride,
00336 const DataRanges& ranges, Bool isInclude,
00337 const vector<typename StatisticsUtilities<AccumType>::BinDesc>& binDesc, const vector<AccumType>& maxLimit
00338 ) const;
00339
00340 virtual void _findBins(
00341 vector<vector<uInt64> >& binCounts,
00342 vector<CountedPtr<AccumType> >& sameVal, vector<Bool>& allSame,
00343 const DataIterator& dataBegin, const WeightsIterator& weightBegin,
00344 Int64 nr, uInt dataStride, const MaskIterator& maskBegin, uInt maskStride,
00345 const vector<typename StatisticsUtilities<AccumType>::BinDesc>& binDesc, const vector<AccumType>& maxLimit
00346 ) const;
00347
00348
00349 Bool _getDoMaxMin() const { return _doMaxMin; }
00350
00351 Bool _getIDataset() const { return _idataset; }
00352
00353 virtual StatsData<AccumType> _getInitialStats() const;
00354
00355 AccumType _getStatistic(StatisticsData::STATS stat);
00356
00357 StatsData<AccumType> _getStatistics();
00358
00359
00360
00361 inline virtual StatsData<AccumType>& _getStatsData() { return _statsData; }
00362
00363 inline virtual const StatsData<AccumType>& _getStatsData() const { return _statsData; }
00364
00365
00366 virtual void _minMax(
00367 CountedPtr<AccumType>& mymin, CountedPtr<AccumType>& mymax,
00368 const DataIterator& dataBegin, Int64 nr, uInt dataStride
00369 ) const;
00370
00371 virtual void _minMax(
00372 CountedPtr<AccumType>& mymin, CountedPtr<AccumType>& mymax,
00373 const DataIterator& dataBegin, Int64 nr, uInt dataStride,
00374 const DataRanges& ranges, Bool isInclude
00375 ) const;
00376
00377 virtual void _minMax(
00378 CountedPtr<AccumType>& mymin, CountedPtr<AccumType>& mymax,
00379 const DataIterator& dataBegin, Int64 nr, uInt dataStride,
00380 const MaskIterator& maskBegin, uInt maskStride
00381 ) const;
00382
00383 virtual void _minMax(
00384 CountedPtr<AccumType>& mymin, CountedPtr<AccumType>& mymax,
00385 const DataIterator& dataBegin, Int64 nr, uInt dataStride,
00386 const MaskIterator& maskBegin, uInt maskStride, const DataRanges& ranges,
00387 Bool isInclude
00388 ) const;
00389
00390 virtual void _minMax(
00391 CountedPtr<AccumType>& mymin, CountedPtr<AccumType>& mymax,
00392 const DataIterator& dataBegin, const WeightsIterator& weightsBegin,
00393 Int64 nr, uInt dataStride
00394 ) const;
00395
00396 virtual void _minMax(
00397 CountedPtr<AccumType>& mymin, CountedPtr<AccumType>& mymax,
00398 const DataIterator& dataBegin, const WeightsIterator& weightsBegin,
00399 Int64 nr, uInt dataStride, const DataRanges& ranges, Bool isInclude
00400 ) const;
00401
00402 virtual void _minMax(
00403 CountedPtr<AccumType>& mymin, CountedPtr<AccumType>& mymax,
00404 const DataIterator& dataBegin, const WeightsIterator& weightsBegin,
00405 Int64 nr, uInt dataStride, const MaskIterator& maskBegin, uInt maskStride,
00406 const DataRanges& ranges, Bool isInclude
00407 ) const;
00408
00409 virtual void _minMax(
00410 CountedPtr<AccumType>& mymin, CountedPtr<AccumType>& mymax,
00411 const DataIterator& dataBegin, const WeightsIterator& weightBegin,
00412 Int64 nr, uInt dataStride, const MaskIterator& maskBegin, uInt maskStride
00413 ) const;
00414
00415
00416
00417
00418
00419 virtual void _populateArray(
00420 vector<AccumType>& ary, const DataIterator& dataBegin, Int64 nr, uInt dataStride
00421 ) const;
00422
00423
00424 virtual void _populateArray(
00425 vector<AccumType>& ary, const DataIterator& dataBegin, Int64 nr,
00426 uInt dataStride, const DataRanges& ranges, Bool isInclude
00427 ) const;
00428
00429 virtual void _populateArray(
00430 vector<AccumType>& ary, const DataIterator& dataBegin,
00431 Int64 nr, uInt dataStride, const MaskIterator& maskBegin,
00432 uInt maskStride
00433 ) const;
00434
00435
00436 virtual void _populateArray(
00437 vector<AccumType>& ary, const DataIterator& dataBegin, Int64 nr,
00438 uInt dataStride, const MaskIterator& maskBegin, uInt maskStride,
00439 const DataRanges& ranges, Bool isInclude
00440 ) const;
00441
00442
00443 virtual void _populateArray(
00444 vector<AccumType>& ary, const DataIterator& dataBegin,
00445 const WeightsIterator& weightsBegin, Int64 nr, uInt dataStride
00446 ) const;
00447
00448
00449 virtual void _populateArray(
00450 vector<AccumType>& ary, const DataIterator& dataBegin,
00451 const WeightsIterator& weightsBegin, Int64 nr, uInt dataStride,
00452 const DataRanges& ranges, Bool isInclude
00453 ) const;
00454
00455
00456 virtual void _populateArray(
00457 vector<AccumType>& ary, const DataIterator& dataBegin,
00458 const WeightsIterator& weightBegin, Int64 nr, uInt dataStride,
00459 const MaskIterator& maskBegin, uInt maskStride
00460 ) const;
00461
00462
00463 virtual void _populateArray(
00464 vector<AccumType>& ary, const DataIterator& dataBegin, const WeightsIterator& weightBegin,
00465 Int64 nr, uInt dataStride, const MaskIterator& maskBegin, uInt maskStride,
00466 const DataRanges& ranges, Bool isInclude
00467 ) const;
00468
00469
00470
00471
00472
00473
00474
00475
00476 virtual void _populateArrays(
00477 vector<vector<AccumType> >& arys, uInt64& currentCount, const DataIterator& dataBegin, Int64 nr, uInt dataStride,
00478 const vector<std::pair<AccumType, AccumType> > &includeLimits, uInt64 maxCount
00479 ) const;
00480
00481
00482 virtual void _populateArrays(
00483 vector<vector<AccumType> >& arys, uInt64& currentCount, const DataIterator& dataBegin, Int64 nr,
00484 uInt dataStride, const DataRanges& ranges, Bool isInclude,
00485 const vector<std::pair<AccumType, AccumType> > &includeLimits, uInt64 maxCount
00486 ) const;
00487
00488 virtual void _populateArrays(
00489 vector<vector<AccumType> >& arys, uInt64& currentCount, const DataIterator& dataBegin,
00490 Int64 nr, uInt dataStride, const MaskIterator& maskBegin,
00491 uInt maskStride,
00492 const vector<std::pair<AccumType, AccumType> > &includeLimits, uInt64 maxCount
00493 ) const;
00494
00495
00496 virtual void _populateArrays(
00497 vector<vector<AccumType> >& arys, uInt64& currentCount, const DataIterator& dataBegin, Int64 nr,
00498 uInt dataStride, const MaskIterator& maskBegin, uInt maskStride,
00499 const DataRanges& ranges, Bool isInclude,
00500 const vector<std::pair<AccumType, AccumType> > &includeLimits, uInt64 maxCount
00501 ) const;
00502
00503
00504 virtual void _populateArrays(
00505 vector<vector<AccumType> >& arys, uInt64& currentCount, const DataIterator& dataBegin,
00506 const WeightsIterator& weightsBegin, Int64 nr, uInt dataStride,
00507 const vector<std::pair<AccumType, AccumType> > &includeLimits, uInt64 maxCount
00508 ) const;
00509
00510
00511 virtual void _populateArrays(
00512 vector<vector<AccumType> >& arys, uInt64& currentCount, const DataIterator& dataBegin,
00513 const WeightsIterator& weightsBegin, Int64 nr, uInt dataStride,
00514 const DataRanges& ranges, Bool isInclude,
00515 const vector<std::pair<AccumType, AccumType> > &includeLimits, uInt64 maxCount
00516 ) const;
00517
00518
00519 virtual void _populateArrays(
00520 vector<vector<AccumType> >& arys, uInt64& currentCount, const DataIterator& dataBegin,
00521 const WeightsIterator& weightBegin, Int64 nr, uInt dataStride,
00522 const MaskIterator& maskBegin, uInt maskStride,
00523 const vector<std::pair<AccumType, AccumType> > &includeLimits, uInt64 maxCount
00524 ) const;
00525
00526
00527 virtual void _populateArrays(
00528 vector<vector<AccumType> >& arys, uInt64& currentCount, const DataIterator& dataBegin, const WeightsIterator& weightBegin,
00529 Int64 nr, uInt dataStride, const MaskIterator& maskBegin, uInt maskStride,
00530 const DataRanges& ranges, Bool isInclude,
00531 const vector<std::pair<AccumType, AccumType> > &includeLimits, uInt64 maxCount
00532 ) const;
00533
00534
00535
00536
00537 virtual Bool _populateTestArray(
00538 vector<AccumType>& ary, const DataIterator& dataBegin,
00539 Int64 nr, uInt dataStride, uInt maxElements
00540 ) const;
00541
00542
00543 virtual Bool _populateTestArray(
00544 vector<AccumType>& ary, const DataIterator& dataBegin, Int64 nr,
00545 uInt dataStride, const DataRanges& ranges, Bool isInclude,
00546 uInt maxElements
00547 ) const;
00548
00549
00550 virtual Bool _populateTestArray(
00551 vector<AccumType>& ary, const DataIterator& dataBegin,
00552 Int64 nr, uInt dataStride, const MaskIterator& maskBegin,
00553 uInt maskStride, uInt maxElements
00554 ) const;
00555
00556
00557 virtual Bool _populateTestArray(
00558 vector<AccumType>& ary, const DataIterator& dataBegin, Int64 nr,
00559 uInt dataStride, const MaskIterator& maskBegin, uInt maskStride,
00560 const DataRanges& ranges, Bool isInclude, uInt maxElements
00561 ) const;
00562
00563
00564 virtual Bool _populateTestArray(
00565 vector<AccumType>& ary, const DataIterator& dataBegin,
00566 const WeightsIterator& weightBegin, Int64 nr, uInt dataStride,
00567 uInt maxElements
00568 ) const;
00569
00570
00571 virtual Bool _populateTestArray(
00572 vector<AccumType>& ary, const DataIterator& dataBegin,
00573 const WeightsIterator& weightsBegin, Int64 nr, uInt dataStride,
00574 const DataRanges& ranges, Bool isInclude, uInt maxElements
00575 ) const;
00576
00577
00578 virtual Bool _populateTestArray(
00579 vector<AccumType>& ary, const DataIterator& dataBegin,
00580 const WeightsIterator& weightBegin, Int64 nr,
00581 uInt dataStride, const MaskIterator& maskBegin,
00582 uInt maskStride, uInt maxElements
00583 ) const;
00584
00585
00586 virtual Bool _populateTestArray(
00587 vector<AccumType>& ary, const DataIterator& dataBegin, const WeightsIterator& weightBegin,
00588 Int64 nr, uInt dataStride, const MaskIterator& maskBegin, uInt maskStride,
00589 const DataRanges& ranges, Bool isInclude,
00590 uInt maxElements
00591 ) const;
00592
00593
00594
00595
00596 virtual void _unweightedStats(
00597 StatsData<AccumType>& stats, uInt64& ngood, LocationType& location,
00598 const DataIterator& dataBegin, Int64 nr, uInt dataStride
00599 );
00600
00601
00602 virtual void _unweightedStats(
00603 StatsData<AccumType>& stats, uInt64& ngood, LocationType& location,
00604 const DataIterator& dataBegin, Int64 nr, uInt dataStride,
00605 const DataRanges& ranges, Bool isInclude
00606 );
00607
00608 virtual void _unweightedStats(
00609 StatsData<AccumType>& stats, uInt64& ngood, LocationType& location,
00610 const DataIterator& dataBegin, Int64 nr, uInt dataStride,
00611 const MaskIterator& maskBegin, uInt maskStride
00612 );
00613
00614 virtual void _unweightedStats(
00615 StatsData<AccumType>& stats, uInt64& ngood, LocationType& location,
00616 const DataIterator& dataBegin, Int64 nr, uInt dataStride,
00617 const MaskIterator& maskBegin, uInt maskStride,
00618 const DataRanges& ranges, Bool isInclude
00619 );
00620
00621
00622 virtual void _updateDataProviderMaxMin(
00623 const StatsData<AccumType>& threadStats
00624 );
00625
00626
00627
00628 virtual void _weightedStats(
00629 StatsData<AccumType>& stats, LocationType& location,
00630 const DataIterator& dataBegin, const WeightsIterator& weightsBegin,
00631 Int64 nr, uInt dataStride
00632 );
00633
00634 virtual void _weightedStats(
00635 StatsData<AccumType>& stats, LocationType& location,
00636 const DataIterator& dataBegin, const WeightsIterator& weightsBegin,
00637 Int64 nr, uInt dataStride, const DataRanges& ranges, Bool isInclude
00638 );
00639
00640 virtual void _weightedStats(
00641 StatsData<AccumType>& stats, LocationType& location,
00642 const DataIterator& dataBegin, const WeightsIterator& weightBegin,
00643 Int64 nr, uInt dataStride, const MaskIterator& maskBegin, uInt maskStride
00644 );
00645
00646 virtual void _weightedStats(
00647 StatsData<AccumType>& stats, LocationType& location,
00648 const DataIterator& dataBegin, const WeightsIterator& weightBegin,
00649 Int64 nr, uInt dataStride, const MaskIterator& maskBegin, uInt maskStride,
00650 const DataRanges& ranges, Bool isInclude
00651 );
00652
00653
00654 private:
00655 StatsData<AccumType> _statsData;
00656 Int64 _idataset;
00657 Bool _calculateAsAdded, _doMaxMin, _doMedAbsDevMed, _mustAccumulate,
00658 _hasData;
00659
00660
00661 mutable typename vector<DataIterator>::const_iterator _dend, _diter;
00662 mutable vector<Int64>::const_iterator _citer;
00663 mutable vector<uInt>::const_iterator _dsiter;
00664 mutable std::map<uInt, MaskIterator> _masks;
00665 mutable uInt _maskStride;
00666 mutable std::map<uInt, WeightsIterator> _weights;
00667 mutable std::map<uInt, DataRanges> _ranges;
00668 mutable std::map<uInt, Bool> _isIncludeRanges;
00669 mutable Bool _hasMask, _hasRanges, _hasWeights, _myIsInclude;
00670 mutable DataRanges _myRanges;
00671 mutable MaskIterator _myMask;
00672 mutable DataIterator _myData;
00673 mutable WeightsIterator _myWeights;
00674 mutable uInt _dataCount, _myStride;
00675 mutable uInt64 _myCount;
00676
00677 static const uInt CACHE_PADDING;
00678 static const uInt BLOCK_SIZE;
00679
00680
00681
00682
00683
00684
00685
00686 vector<vector<uInt64> > _binCounts(
00687 vector<CountedPtr<AccumType> >& sameVal,
00688 const vector<typename StatisticsUtilities<AccumType>::BinDesc>& binDesc
00689 );
00690
00691 void _computeBins(
00692 vector<vector<uInt64> >& bins, vector<CountedPtr<AccumType> >& sameVal,
00693 vector<Bool>& allSame, DataIterator dataIter, MaskIterator maskIter,
00694 WeightsIterator weightsIter, uInt64 count,
00695 const vector<typename StatisticsUtilities<AccumType>::BinDesc>& binDesc,
00696 const vector<AccumType>& maxLimit
00697 );
00698
00699 void _computeDataArray(
00700 vector<AccumType>& ary, DataIterator dataIter,
00701 MaskIterator maskIter, WeightsIterator weightsIter,
00702 uInt64 dataCount
00703 );
00704
00705 void _computeDataArrays(
00706 vector<vector<AccumType> >& arys, uInt64& currentCount,
00707 DataIterator dataIter, MaskIterator maskIter,
00708 WeightsIterator weightsIter, uInt64 dataCount,
00709 const vector<std::pair<AccumType, AccumType> >& includeLimits,
00710 uInt64 maxCount
00711 );
00712
00713 void _computeMinMax(
00714 CountedPtr<AccumType>& mymax, CountedPtr<AccumType>& mymin,
00715 DataIterator dataIter, MaskIterator maskIter,
00716 WeightsIterator weightsIter, uInt64 dataCount
00717 );
00718
00719 void _computeStats(
00720 StatsData<AccumType>& stats, uInt64& ngood, LocationType& location,
00721 DataIterator dataIter, MaskIterator maskIter,
00722 WeightsIterator weightsIter, uInt64 count
00723 );
00724
00725
00726 static void _convertToAbsDevMedArray(vector<AccumType>& myArray, AccumType median);
00727
00728
00729
00730
00731 void _createDataArray(
00732 vector<AccumType>& array
00733 );
00734
00735 void _createDataArrays(
00736 vector<vector<AccumType> >& arrays,
00737 const vector<std::pair<AccumType, AccumType> > &includeLimits,
00738 uInt64 maxCount
00739 );
00740
00741
00742
00743
00744
00745
00746
00747 vector<std::map<uInt64, AccumType> > _dataFromMultipleBins(
00748 const vector<typename StatisticsUtilities<AccumType>::BinDesc>& binDesc, uInt64 maxArraySize,
00749 const vector<std::set<uInt64> >& dataIndices, uInt64 nBins
00750 );
00751
00752 vector<std::map<uInt64, AccumType> > _dataFromSingleBins(
00753 const vector<uInt64>& binNpts, uInt64 maxArraySize,
00754 const vector<std::pair<AccumType, AccumType> >& binLimits,
00755 const vector<std::set<uInt64> >& dataIndices, uInt64 nBins
00756 );
00757
00758 Int64 _doNpts();
00759
00760
00761 Bool _increment(Bool includeIDataset);
00762
00763
00764 void _incrementThreadIters(
00765 DataIterator& dataIter, MaskIterator& maskIter,
00766 WeightsIterator& weightsIter, uInt64& offset, uInt nthreads
00767 ) const;
00768
00769
00770 std::map<uInt64, AccumType> _indicesToValues(
00771 CountedPtr<uInt64> knownNpts, CountedPtr<AccumType> knownMin,
00772 CountedPtr<AccumType> knownMax, uInt64 maxArraySize,
00773 const std::set<uInt64>& dataIndices, Bool persistSortedArray,
00774 uInt64 nBins
00775 );
00776
00777 void _initIterators();
00778
00779 void _initLoopVars();
00780
00781 void _initThreadVars(
00782 uInt& nBlocks, uInt64& extra, uInt& nthreads, PtrHolder<DataIterator>& dataIter,
00783 PtrHolder<MaskIterator>& maskIter, PtrHolder<WeightsIterator>& weightsIter,
00784 PtrHolder<uInt64>& offset, uInt nThreadsMax
00785 ) const;
00786
00787
00788
00789
00790 Bool _isNptsSmallerThan(vector<AccumType>& arrayToSort, uInt maxArraySize);
00791
00792
00793
00794
00795
00796 static void _makeBins(
00797 typename StatisticsUtilities<AccumType>::BinDesc& bins, AccumType minData, AccumType maxData, uInt maxBins,
00798 Bool allowPad
00799 );
00800
00801 static void _mergeResults(
00802 vector<vector<uInt64> >& bins, vector<CountedPtr<AccumType> >& sameVal,
00803 vector<Bool>& allSame, const PtrHolder<vector<vector<uInt64> > >& tBins,
00804 const PtrHolder<vector<CountedPtr<AccumType> > >& tSameVal,
00805 const PtrHolder<vector<Bool> >& tAllSame, uInt nThreadsMax
00806 );
00807
00808
00809
00810
00811
00812 std::set<uInt64> _medianIndices(CountedPtr<uInt64> knownNpts);
00813
00814 uInt _nThreadsMax() const;
00815
00816 uInt _threadIdx() const;
00817
00818
00819
00820
00821
00822
00823 Bool _valuesFromSortedArray(
00824 std::map<uInt64, AccumType>& values, CountedPtr<uInt64> knownNpts,
00825 const std::set<uInt64>& indices, uInt64 maxArraySize,
00826 Bool persistSortedArray
00827 );
00828 };
00829
00830 }
00831
00832 #ifndef CASACORE_NO_AUTO_TEMPLATES
00833 #include <casacore/scimath/Mathematics/ClassicalStatistics.tcc>
00834 #endif //# CASACORE_NO_AUTO_TEMPLATES
00835
00836 #endif