OpendTect 8.0
Loading...
Searching...
No Matches
Stats::ParallelCalc< T > Class Template Reference

Stats computation running in parallel. More...

#include <statparallelcalc.h>

Inheritance diagram for Stats::ParallelCalc< T >:
[legend]

Public Member Functions

 ParallelCalc (const CalcSetup &s)
 
 ParallelCalc (const CalcSetup &s, const T *data, size_type sz, const T *weights=0)
 
 ~ParallelCalc ()
 
const uiString errMsg () const
 
 mUseType (CalcSetup, idx_type)
 
 mUseType (CalcSetup, size_type)
 
void setEmpty ()
 
void setValues (const T *inp, size_type sz, const T *wght=0)
 
double variance () const
 
double variance () const override
 
- Public Member Functions inherited from ParallelTask
virtual ~ParallelTask ()
 
void doParallel (bool yn)
 
bool execute () override
 
virtual bool executeParallel (bool parallel)
 
od_int64 nrDone () const override
 May be -1, i.e. class does not report nrdone.
 
od_int64 totalNr () const override
 
- Public Member Functions inherited from ReportingTask
 ReportingTask (const ReportingTask &)=delete
 
virtual ~ReportingTask ()
 
void getProgress (const ReportingTask &)
 
ReportingTask & operator= (const ReportingTask &)=delete
 
void setSimpleMeter (bool yn, int repperc)
 
int simpleMeterStep () const
 
bool useSimpleMeter () const
 
- Public Member Functions inherited from Task
 Task (const Task &)=delete
 
virtual ~Task ()
 
virtual void controlWork (Control)
 
virtual void enableWorkControl (bool=true)
 Must be called before execute()
 
virtual uiRetVal errorWithDetails () const
 
virtual Control getState () const
 
Task & operator= (const Task &)=delete
 
bool shouldContinue_ ()
 
virtual uiString uiMessage () const
 
virtual uiString uiNrDoneText () const
 
bool workControlEnabled () const
 
- Public Member Functions inherited from NamedCallBacker
 NamedCallBacker (const char *nm=nullptr)
 
 NamedCallBacker (const NamedCallBacker &)=delete
 
 ~NamedCallBacker ()
 
virtual Notifier< NamedCallBacker > & objectToBeDeleted () const
 
NamedCallBacker & operator= (const NamedCallBacker &)=delete
 
bool operator== (const NamedCallBacker &oth) const
 
bool operator== (const NamedObject &oth) const
 
- Public Member Functions inherited from CallBacker
 CallBacker ()
 
 CallBacker (const CallBacker &)
 
virtual ~CallBacker ()
 
bool attachCB (const NotifierAccess &, const CallBack &, bool onlyifnew=false) const
 
bool attachCB (const NotifierAccess *notif, const CallBack &cb, bool onlyifnew=false) const
 
void detachAllNotifiers () const
 Call from the destructor of your inherited object.
 
void detachCB (const NotifierAccess &, const CallBack &) const
 
void detachCB (const NotifierAccess *notif, const CallBack &cb) const
 
virtual bool isCapsule () const
 
bool isNotifierAttached (const NotifierAccess *) const
 Only for debugging purposes, don't use.
 
CallBacker & operator= (const CallBacker &)=delete
 
void stopReceivingNotifications () const
 
virtual CallBacker * trueCaller ()
 
- Public Member Functions inherited from NamedObject
 NamedObject (const char *nm=nullptr)
 
 NamedObject (const NamedObject &oth)
 
virtual ~NamedObject ()
 
virtual BufferString getName () const
 
bool getNameFromPar (const IOPar &)
 
const name_type & name () const override
 
NamedObject & operator= (const NamedObject &)
 
bool operator== (const NamedObject &oth) const
 
virtual void setName (const char *nm)
 
- Public Member Functions inherited from ObjectWithName
virtual ~ObjectWithName ()
 
bool hasName (const char *nm) const
 
bool hasName (const name_type &nm) const
 
void putNameInPar (IOPar &) const
 
- Public Member Functions inherited from Stats::BaseCalc< T >
virtual ~BaseCalc ()
 
double average () const
 
void clear ()
 
T clipVal (float ratio, bool upper) const
 requires sort; 0 <= ratio <= 1
 
size_type count () const
 
T extreme (idx_type *index_of_extr=0) const
 
idx_type getIndex (Type) const
 only for Median, Min and Max
 
double getValue (Type) const
 
bool hasUndefs () const
 
bool isEmpty () const
 
bool isWeighted () const
 
T max (idx_type *index_of_max=0) const
 
T median (idx_type *index_of_median=0) const
 
const T * medValsArr () const
 
T min (idx_type *index_of_min=0) const
 
T mostFreq () const
 
float_complex mostFreq () const
 
 mUseType (CalcSetup, idx_type)
 
 mUseType (CalcSetup, size_type)
 
double normvariance () const
 
double rms () const
 
const CalcSetup & setup () const
 
size_type size (bool used=true) const
 
T sqSum () const
 
double stdDev () const
 
T sum () const
 
double variance () const
 

Protected Member Functions

bool doFinish (bool)
 
bool doFinish (bool) override
 
bool doPrepare (int) override
 
bool doWork (od_int64, od_int64, int)
 
bool doWork (od_int64, od_int64, int) override
 
od_int64 nrIterations () const override
 
const float_complex * sort (idx_type *idx_of_med)
 
const T * sort (idx_type *index_of_median=nullptr) override
 
- Protected Member Functions inherited from ParallelTask
 ParallelTask (const char *nm=0)
 
void addToNrDone (od_int64 increment)
 
od_int64 calculateThreadSize (od_int64 totalnr, int nrthreads, int thread) const
 
virtual int maxNrThreads () const
 
virtual int minThreadSize () const
 
void quickAddToNrDone (od_int64 loopidx)
 
void resetNrDone ()
 
virtual bool stopAllOnFailure () const
 
- Protected Member Functions inherited from ReportingTask
 ReportingTask (const char *nm=nullptr)
 
void incrementProgress ()
 
ProgressMeter * progressMeter () const
 
void reportProgressFinished ()
 
void reportProgressStarted ()
 
void resetProgress ()
 
void setProgressMeter (ProgressMeter *) override
 Must be called before execute()
 
void updateProgressMeter (bool forced=false, od_int64 *totalnr=0)
 
void updateReportedName ()
 
- Protected Member Functions inherited from Task
 Task (const char *nm=nullptr)
 
virtual bool shouldContinue ()
 
- Protected Member Functions inherited from NamedCallBacker
void sendDelNotif () const
 
- Protected Member Functions inherited from Stats::BaseCalc< T >
 BaseCalc (const CalcSetup &s)
 
T computeMedian (idx_type *index_of_median=nullptr) const
 
T computeWeightedMedian (idx_type *index_of_median=nullptr) const
 
bool isZero (const double &val) const
 
bool isZero (const float &val) const
 
bool isZero (const T &) const
 
const float_complex * sort (idx_type *idx_of_med)
 

Protected Attributes

Threads::Barrier barrier_
 
const T * data_ = nullptr
 
uiString errmsg_
 
T meanval_
 
T meanval_w_
 
bool * udfarr_ = nullptr
 
T variance_
 
T variance_w_
 
const T * weights_ = nullptr
 
- Protected Attributes inherited from Task
Control control_ = Task::Run
 
Threads::ConditionVar * workcontrolcondvar_ = nullptr
 
- Protected Attributes inherited from NamedCallBacker
Threads::Atomic< bool > delalreadytriggered_
 
Notifier< NamedCallBacker > delnotif_
 
- Protected Attributes inherited from NamedObject
BufferString name_
 
- Protected Attributes inherited from Stats::BaseCalc< T >
LargeValVec< idx_type > clss_
 
LargeValVec< T > clsswt_
 
bool issorted_ = false
 
idx_type maxidx_
 
T maxval_
 
LargeValVec< idx_type > medidxs_
 
LargeValVec< T > medvals_
 
LargeValVec< T > medwts_
 
idx_type minidx_
 
T minval_
 
size_type nradded_
 
Threads::Atomic< size_type > nrused_
 
CalcSetup setup_
 
T sum_w_
 
T sum_wx_
 
T sum_wxx_
 
T sum_x_
 
T sum_xx_
 

Additional Inherited Members

- Public Types inherited from Task
enum  Control { Run , Pause , Stop }
 
- Public Types inherited from ObjectWithName
typedef OD::String name_type
 
- Static Public Member Functions inherited from ParallelTask
static uiString sPosFinished ()
 
static uiString sTrcFinished ()
 
- Static Public Member Functions inherited from ReportingTask
static PtrMan< ProgressMeter > getTextProgressMeter (od_ostream &, const IOPar *iop=nullptr)
 
static bool needSimpleLogging (const IOPar &)
 
static const char * sKeySimpleLogging ()
 
static const char * sKeySimpleLoggingStep ()
 
- Static Public Member Functions inherited from Task
static uiString uiStdNrDoneText ()
 
- Static Public Member Functions inherited from CallBacker
static void createReceiverForCurrentThread ()
 
static void removeReceiverForCurrentThread ()
 
- Public Attributes inherited from ReportingTask
Notifier< ReportingTask > progressUpdated
 

Detailed Description

template<class T>
class Stats::ParallelCalc< T >

Stats computation running in parallel.

The difference with the running values (Stats::RunCalc) is that you have to pass the entire data array prior to the execution.

It also works with optional weights.

Constructor & Destructor Documentation

◆ ParallelCalc() [1/2]

template<class T>
Stats::ParallelCalc< T >::ParallelCalc ( const CalcSetup & s,
const T * data,
size_type sz,
const T * weights = 0 )
inline

◆ ParallelCalc() [2/2]

template<class T>
Stats::ParallelCalc< T >::ParallelCalc ( const CalcSetup & s)
inline

◆ ~ParallelCalc()

template<class T>
Stats::ParallelCalc< T >::~ParallelCalc ( )
inline

Member Function Documentation

◆ doFinish() [1/2]

bool Stats::ParallelCalc< float_complex >::doFinish ( bool success)
inlineprotectedvirtual

Called after all doWork have finished.

Parameters
successindicates whether all doWork returned true.

Reimplemented from ParallelTask.

◆ doFinish() [2/2]

template<class T>
bool Stats::ParallelCalc< T >::doFinish ( bool success)
inlineoverrideprotectedvirtual

Called after all doWork have finished.

Parameters
successindicates whether all doWork returned true.

Reimplemented from ParallelTask.

◆ doPrepare()

template<class T>
bool Stats::ParallelCalc< T >::doPrepare ( int nrthreads)
inlineoverrideprotectedvirtual

Called once, before any doWork is called.

Reimplemented from ParallelTask.

◆ doWork() [1/2]

bool Stats::ParallelCalc< float_complex >::doWork ( od_int64 start,
od_int64 stop,
int threadidx )
inlineprotectedvirtual

The functions that does the job. The function will be called with all intervals from 0 to ParallelTask::nrIterations()-1. The function must be designed to be able to run in parallel.

Parameters
startfirst index
stoplast index
threadidxgives an identifier (between 0 and nr of threads -1) that is unique to each call to doWork.

Implements ParallelTask.

◆ doWork() [2/2]

template<class T>
bool Stats::ParallelCalc< T >::doWork ( od_int64 start,
od_int64 stop,
int threadidx )
inlineoverrideprotectedvirtual

The functions that does the job. The function will be called with all intervals from 0 to ParallelTask::nrIterations()-1. The function must be designed to be able to run in parallel.

Parameters
startfirst index
stoplast index
threadidxgives an identifier (between 0 and nr of threads -1) that is unique to each call to doWork.

Implements ParallelTask.

◆ errMsg()

template<class T>
const uiString Stats::ParallelCalc< T >::errMsg ( ) const
inline

◆ mUseType() [1/2]

template<class T>
Stats::ParallelCalc< T >::mUseType ( CalcSetup ,
idx_type  )

◆ mUseType() [2/2]

template<class T>
Stats::ParallelCalc< T >::mUseType ( CalcSetup ,
size_type  )

◆ nrIterations()

template<class T>
od_int64 Stats::ParallelCalc< T >::nrIterations ( ) const
inlineoverrideprotectedvirtual
Returns
the number of times the process should be run.

Implements ParallelTask.

◆ setEmpty()

template<class T>
void Stats::ParallelCalc< T >::setEmpty ( )
inline

◆ setValues()

template<class T>
void Stats::ParallelCalc< T >::setValues ( const T * inp,
size_type sz,
const T * wght = 0 )
inline

◆ sort() [1/2]

const float_complex * Stats::ParallelCalc< float_complex >::sort ( idx_type * idx_of_med)
inlineprotectedvirtual

Reimplemented from Stats::BaseCalc< T >.

◆ sort() [2/2]

template<class T>
const T * Stats::ParallelCalc< T >::sort ( idx_type * index_of_median = nullptr)
inlineoverrideprotectedvirtual

Reimplemented from Stats::BaseCalc< T >.

◆ variance() [1/2]

double Stats::ParallelCalc< float_complex >::variance ( ) const
inlinevirtual

Reimplemented from Stats::BaseCalc< T >.

◆ variance() [2/2]

template<class T>
double Stats::ParallelCalc< T >::variance ( ) const
inlineoverridevirtual

Reimplemented from Stats::BaseCalc< T >.

Member Data Documentation

◆ barrier_

template<class T>
Threads::Barrier Stats::ParallelCalc< T >::barrier_
mutableprotected

◆ data_

template<class T>
const T* Stats::ParallelCalc< T >::data_ = nullptr
protected

◆ errmsg_

template<class T>
uiString Stats::ParallelCalc< T >::errmsg_
protected

◆ meanval_

template<class T>
T Stats::ParallelCalc< T >::meanval_
protected

◆ meanval_w_

template<class T>
T Stats::ParallelCalc< T >::meanval_w_
protected

◆ udfarr_

template<class T>
bool* Stats::ParallelCalc< T >::udfarr_ = nullptr
protected

◆ variance_

template<class T>
T Stats::ParallelCalc< T >::variance_
protected

◆ variance_w_

template<class T>
T Stats::ParallelCalc< T >::variance_w_
protected

◆ weights_

template<class T>
const T* Stats::ParallelCalc< T >::weights_ = nullptr
protected

Generated at for the OpendTect seismic interpretation project. Copyright (C): dGB Beheer B.V. 1995-2026