28 , relcube_( arr.info().getNDim() )
30 const int ndim = array_.info().getNDim();
31 for (
int idx=0; idx<ndim; idx++ )
32 relcube_.setSize( idx, 3 );
35 inline int nrExtremes()
const;
42 inline od_int64 nrIterations()
const;
45 inline int indexOf(
const int*)
const;
55 template <
class T>
inline 57 {
return array_.info().getTotalSz(); }
60 template <
class T>
inline 63 const int ndim = array_.info().getNDim();
64 return extremes_.size()/ndim;
68 template <
class T>
inline 71 const int ndim = array_.info().getNDim();
73 if ( !array_.info().getArrayPos( start, pos ) )
80 for (
int idx=
mCast(
int,start); idx<=stop && shouldContinue();
81 idx++, addToNrDone(1), iter.next() )
83 OD::memCopy( currentextreme, iter.getPos(), ndim*
sizeof(int) );
89 int extremeidx =
indexOf( currentextreme );
96 if ( !lock_.convReadToWriteLock() )
98 extremeidx =
indexOf( currentextreme );
106 for (
int idy=0; idy<ndim; idy++ )
107 extremes_ += currentextreme[idy];
116 template <
class T>
inline 119 const int nrextremes = nrExtremes();
120 const int ndim = array_.info().getNDim();
122 for (
int idx=0; idx<nrextremes; idx++ )
124 const int* curpos = extremes_.arr() + idx*ndim;
126 for (
int idy=0; idy<ndim; idy++ )
128 if ( curpos[idy]!=pos[idy] )
143 template <
class T>
inline 146 const int ndim = array_.info().getNDim();
148 T extremeval = array_.getND( extremepos );
152 OD::memCopy( bestpos, extremepos, ndim*
sizeof(
int) );
155 bool anychange =
false;
163 bool invalid =
false;
165 for (
int idx=0; idx<ndim; idx++ )
167 if ( iter[idx] ) isnull =
false;
168 const int newpos = extremepos[idx]+iter[idx]-1;
169 if ( newpos<0 || newpos>=array_.info().getSize(idx) )
175 curpos[idx] = newpos;
178 if ( invalid || isnull )
181 const T val = array_.getND( curpos );
182 if ( (minima_ && val<extremeval) || (!minima_ && val>extremeval) )
184 OD::memCopy( bestpos, curpos, ndim*
sizeof(
int) );
188 }
while ( iter.
next() );
192 OD::memCopy( extremepos, bestpos, ndim*
sizeof(
int) );
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:22
int nrExtremes() const
Definition: sampledextremefindernd.h:61
Threads::ReadWriteLock lock_
Definition: sampledextremefindernd.h:51
ArrayNDInfoImpl relcube_
Definition: sampledextremefindernd.h:48
#define mCast(tp, v)
Definition: commondefs.h:120
#define od_int64
Definition: plftypes.h:34
Implementation of ArrayNDInfo.
Definition: arrayndinfo.h:217
TypeSet< int > extremes_
Definition: sampledextremefindernd.h:50
bool findExtreme(int *) const
Definition: sampledextremefindernd.h:144
ObjectSet< T >::size_type indexOf(const ObjectSet< T > &os, const S &val)
Locate object in set.
Definition: objectset.h:173
bool doWork(od_int64, od_int64, int)
Definition: sampledextremefindernd.h:69
Generalization of a task that can be run in parallel.
Definition: paralleltask.h:64
float findExtreme(const FloatMathFunction &, bool minima, float x1, float x2, float tol=1e-5)
const ArrayND< T > & array_
Definition: sampledextremefindernd.h:47
od_int64 nrIterations() const
Definition: sampledextremefindernd.h:56
void setPos(const T &idxabl)
Definition: arraynd.h:252
int indexOf(const int *) const
Definition: sampledextremefindernd.h:117
#define mAllocVarLenArr(type, varnm, __size)
Definition: varlenarray.h:52
const int * getExtremes() const
Definition: sampledextremefindernd.h:37
bool minima_
Definition: sampledextremefindernd.h:49
An ArrayND is an array with a given number of dimensions and a size.
Definition: arraynd.h:29
Iterates through all samples in an ArrayND.
Definition: arraynd.h:175
SampledExtremeFinderND(const ArrayND< T > &arr, bool minima)
Definition: sampledextremefindernd.h:25
#define mClass(module)
Definition: commondefs.h:161