1 #ifndef sampledextremefindernd_h 2 #define sampledextremefindernd_h 30 , relcube_( arr.info().getNDim() )
32 const int ndim = array_.info().getNDim();
33 for (
int idx=0; idx<ndim; idx++ )
34 relcube_.setSize( idx, 3 );
37 inline int nrExtremes()
const;
44 inline od_int64 nrIterations()
const;
47 inline int indexOf(
const int*)
const;
57 template <
class T>
inline 59 {
return array_.info().getTotalSz(); }
62 template <
class T>
inline 65 const int ndim = array_.info().getNDim();
66 return extremes_.size()/ndim;
70 template <
class T>
inline 73 const int ndim = array_.info().getNDim();
75 if ( !array_.info().getArrayPos( start, pos ) )
82 for (
int idx=
mCast(
int,start); idx<=stop && shouldContinue();
83 idx++, addToNrDone(1), iter.next() )
91 int extremeidx =
indexOf( currentextreme );
98 if ( !lock_.convReadToWriteLock() )
100 extremeidx =
indexOf( currentextreme );
101 if ( extremeidx!=-1 )
108 for (
int idy=0; idy<ndim; idy++ )
109 extremes_ += currentextreme[idy];
118 template <
class T>
inline 121 const int nrextremes = nrExtremes();
122 const int ndim = array_.info().getNDim();
124 for (
int idx=0; idx<nrextremes; idx++ )
126 const int* curpos = extremes_.arr() + idx*ndim;
128 for (
int idy=0; idy<ndim; idy++ )
130 if ( curpos[idy]!=pos[idy] )
145 template <
class T>
inline 148 const int ndim = array_.info().getNDim();
150 T extremeval = array_.getND( extremepos );
157 bool anychange =
false;
165 bool invalid =
false;
167 for (
int idx=0; idx<ndim; idx++ )
169 if ( iter[idx] ) isnull =
false;
170 const int newpos = extremepos[idx]+iter[idx]-1;
171 if ( newpos<0 || newpos>=array_.info().getSize(idx) )
177 curpos[idx] = newpos;
180 if ( invalid || isnull )
183 const T val = array_.getND( curpos );
184 if ( (minima_ && val<extremeval) || (!minima_ && val>extremeval) )
190 }
while ( iter.
next() );
Lock that permits multiple readers to lock the object at the same time, but it will not allow any rea...
Definition: thread.h:141
Finds all local maximas/minimas in an ArrayND.
Definition: sampledextremefindernd.h:24
int nrExtremes() const
Definition: sampledextremefindernd.h:63
Threads::ReadWriteLock lock_
Definition: sampledextremefindernd.h:53
ArrayNDInfoImpl relcube_
Definition: sampledextremefindernd.h:50
#define mCast(tp, v)
Definition: commondefs.h:124
#define od_int64
Definition: plftypes.h:36
Implementation of ArrayNDInfo.
Definition: arrayndinfo.h:219
TypeSet< int > extremes_
Definition: sampledextremefindernd.h:52
bool findExtreme(int *) const
Definition: sampledextremefindernd.h:146
ObjectSet< T >::size_type indexOf(const ObjectSet< T > &os, const S &val)
Locate object in set.
Definition: objectset.h:169
bool doWork(od_int64, od_int64, int)
Definition: sampledextremefindernd.h:71
Generalization of a task that can be run in parallel.
Definition: paralleltask.h:66
float findExtreme(const FloatMathFunction &, bool minima, float x1, float x2, float tol=1e-5)
const ArrayND< T > & array_
Definition: sampledextremefindernd.h:49
od_int64 nrIterations() const
Definition: sampledextremefindernd.h:58
void setPos(const T &idxabl)
Definition: arraynd.h:256
int indexOf(const int *) const
Definition: sampledextremefindernd.h:119
#define mAllocVarLenArr(type, varnm, __size)
Definition: varlenarray.h:54
const int * getExtremes() const
Definition: sampledextremefindernd.h:39
bool minima_
Definition: sampledextremefindernd.h:51
An ArrayND is an array with a given number of dimensions and a size.
Definition: arraynd.h:33
Iterates through all samples in an ArrayND.
Definition: arraynd.h:179
void sysMemCopy(void *, const void *, int64_t)
SampledExtremeFinderND(const ArrayND< T > &arr, bool minima)
Definition: sampledextremefindernd.h:27
#define mClass(module)
Definition: commondefs.h:164