 |
OpendTect
6.6
|
Go to the documentation of this file.
29 float& relpos,
const float eps=1e-4 )
31 int arridx = (int)farridx;
32 relpos = farridx - arridx;
34 if ( arridx==-1 &&
mIsEqual(relpos,1,1e-4) )
35 { arridx = 0; relpos = 0; }
36 else if ( arridx==arrsz-1 &&
mIsZero(relpos,1e-4) )
37 { arridx = arrsz-2; relpos = 1; }
48 template <
class T>
inline
53 if ( !val0 )
return val1;
54 if ( !
val1 )
return val0;
56 while ( (val0&1)==0 && (
val1&1)==0 )
67 else if ((
val1 & 1) == 0)
69 else if (val0 >=
val1)
70 val0 = (val0-
val1) >> 1;
82 template <
class T>
inline
86 const T start =
mMIN( a.start, b.start );
106 if ( val==base )
return 1;
112 if ( res )
return 1 + res;
122 while ( res<val ) res *= base;
129 iT minsz=1, iT maxsz=0 )
131 char npow = 0;
char npowextra = actsz == 1 ? 1 : 0;
135 if (
above && !npowextra && sz % 2 )
141 if ( sz<minsz ) sz = minsz;
142 if ( maxsz && sz>maxsz ) sz = maxsz;
167 inline iT
nrBlocks( iT totalsamples, iT basesize, iT overlapsize )
170 while ( totalsamples>basesize )
173 totalsamples = totalsamples - basesize + overlapsize;
196 if ( lowpos >= sz || lowpos < 0 ||
197 highpos >= sz || highpos < 0 ||
201 int pos = lowpos < highpos ? 0 : sz - 1 ;
202 int inc = lowpos < highpos ? 1 : -1 ;
204 while ( pos != lowpos )
210 int tapersz = abs( highpos - lowpos );
215 while ( pos != highpos )
217 array[pos] *= type ==
Taper::Cosine ? .5 + .5 * cos( taperfactor )
220 taperfactor += taperfactorinc;
244 {
if ( !u0 && !(um1 && u1) )
return um1 ? y1_ - y0_ : y0_ - ym1; }
246 return (y1_-ym1) * .5;
248 else if ( (um1 && u1) || (u0 && (um1 || u1)) )
249 return (y2-ym2) * .25;
250 else if ( um1 || u1 )
252 return um1 ? ((16*y1_) - 3*y2 - ym2) / 12 - y0_
253 : ((-16*ym1) + 3*ym2 + y2) / 12 + y0_;
256 return (8 * ( y1_ - ym1 ) - y2 + ym2) / 12;
262 template <
class X,
class Y,
class RT>
263 inline void getGradient(
const X& x,
const Y& y,
int sz,
int firstx,
int firsty,
264 RT* gradptr=0,
RT* interceptptr=0 )
266 RT xy_sum = 0, x_sum=0, y_sum=0, xx_sum=0;
268 for (
int idx=0; idx<sz; idx++ )
270 RT xval = x[idx+firstx];
271 RT yval = y[idx+firsty];
279 RT grad = ( sz*xy_sum - x_sum*y_sum ) / ( sz*xx_sum - x_sum*x_sum );
280 if ( gradptr ) *gradptr = grad;
282 if ( interceptptr ) *interceptptr = (y_sum - grad*x_sum)/sz;
289 if ( sz < 2 )
return mUdf(
float);
294 for (
int idx=0; idx<sz; idx++ )
302 return (sqsum - sum * sum / sz)/ (sz -1);
322 const double a2 = a*a;
323 const double q = (a2-3*b)/9;
324 const double r = (2*a2*a-9*a*b+27*c)/54;
325 const double q3 = q*q*q;
326 const double r2 = r*r;
329 const double minus_a_through_3 = -a/3;
333 const double minus_twosqrt_q = -2*
Math::Sqrt(q);
335 const double twopi =
M_2PI;
338 root0 = minus_twosqrt_q*cos(theta/3)+minus_a_through_3;
339 root1=minus_twosqrt_q*cos((theta-twopi)/3)+minus_a_through_3;
340 root2=minus_twosqrt_q*cos((theta+twopi)/3)+minus_a_through_3;
344 const double A=(r>0?-1:1)*pow(fabs(r)+
Math::Sqrt(r2-q3),1/3);
347 root0 = A+B+minus_a_through_3;
368 if (
mIsUdf(val) )
return true;
369 if ( val < -
mDefEps )
return false;
370 const int ival = (int)(val + .5);
377 const unsigned int maxclss=50,
378 const unsigned int samplesz=100 )
380 if ( sz < 1 )
return true;
381 if ( sz <= samplesz )
383 for (
int idx=0; idx<sz; idx++ )
394 for (
int idx=0; idx<samplesz; idx++ )
396 od_int64 arridx = ((1+idx) * seed) % samplesz;
410 if ( val>127 || val<-128 )
413 const int ival = (int)(val>0 ? val+.5 : val-.5);
420 const unsigned int samplesz=100 )
425 if ( sz <= samplesz )
427 for (
int idx=0; idx<sz; idx++ )
438 for (
int idx=0; idx<samplesz; idx++ )
440 od_int64 arridx = ((1+idx) * seed) % samplesz;
FixedString X()
Definition: keystrs.h:188
iT exactPower(iT val, iT base)
Definition: simpnumer.h:104
StepInterval< T > getCommonStepInterval(const StepInterval< T > &a, const StepInterval< T > &b)
Definition: simpnumer.h:83
const T val1
Definition: arrayndalgo.h:1706
iT getPow2Sz(iT actsz, const bool above=true, iT minsz=1, iT maxsz=0)
Definition: simpnumer.h:128
@ above
Definition: i_layout.h:28
#define mIsEqual(x, y, eps)
Definition: commondefs.h:67
T greatestCommonDivisor(T val0, T val1)
Definition: simpnumer.h:49
bool taperArray(T *array, int sz, int lowpos, int highpos, Taper::Type type)
Definition: simpnumer.h:194
#define mIsUdf(val)
Use mIsUdf to check for undefinedness of simple types.
Definition: undefval.h:289
int nrSteps() const
Definition: ranges.h:791
#define od_int64
Definition: plftypes.h:35
#define mMAX(x, y)
Definition: commondefs.h:61
iT nextPower2(iT nr, iT minnr, iT maxnr)
Definition: simpnumer.h:148
#define mDefEps
Definition: commondefs.h:71
bool is8BitesData(const T *vals, od_int64 sz, const unsigned int samplesz=100)
Definition: simpnumer.h:419
unsigned int Abs(unsigned int i)
Definition: math2.h:79
iT IntPowerOf(iT i, iPOW p)
Definition: math2.h:121
int getArrIdxPosition(const float farridx, const int arrsz, float &relpos, const float eps=1e-4)
Definition: simpnumer.h:28
Taper an indexable array from 1 to taperfactor. If lowpos is less than highpos, the samples array[0] ...
Definition: simpnumer.h:188
#define M_2PI
Definition: commondefs.h:83
Interval with step.
Definition: commontypes.h:32
bool isUdf(const T &t)
Definition: undefval.h:245
iT nextPower(iT val, iT base)
Definition: simpnumer.h:119
#define mIsZero(x, eps)
Definition: commondefs.h:66
int solve3DPoly(double a, double b, double c, double &root0, double &root1, double &root2)
Definition: simpnumer.h:317
@ Linear
Definition: simpnumer.h:189
bool isSigned8BitesValue(const T val)
Definition: simpnumer.h:408
bool holdsClassValues(const T *vals, od_int64 sz, const unsigned int maxclss=50, const unsigned int samplesz=100)
Definition: simpnumer.h:376
#define mMIN(x, y)
Definition: commondefs.h:62
void getGradient(const X &x, const Y &y, int sz, int firstx, int firsty, RT *gradptr=0, RT *interceptptr=0)
Definition: simpnumer.h:263
Type
Definition: simpnumer.h:189
float variance(const X &x, int sz)
Definition: simpnumer.h:287
iT nrBlocks(iT totalsamples, iT basesize, iT overlapsize)
Definition: simpnumer.h:167
#define M_PI
Definition: commondefs.h:77
#define mUdf(type)
Use this macro to get the undefined for simple types.
Definition: undefval.h:274
FixedString Y()
Definition: keystrs.h:193
#define mDefineStaticLocalObject(type, var, init)
Definition: commondefs.h:203
Definition: interpol1d.h:38
@ Cosine
Definition: simpnumer.h:189
T sampledGradient(T ym2, T ym1, T y0_, T y1_, T y2)
Definition: simpnumer.h:236
bool holdsClassValue(const T val, const unsigned int maxclss=50)
Definition: simpnumer.h:366
T step
Definition: ranges.h:200
Generated at
for the OpendTect
seismic interpretation project.
Copyright (C): dGB Beheer B.V. 1995-2021