 |
OpendTect
6.6
|
Go to the documentation of this file.
38 template <
class RT,
class PT>
59 template <
class RT,
class PT>
65 {
return getValue(*pos); }
80 template <
class RT,
class PT>
88 {
return func_.getValue( sd.atIndex(idx) ); }
103 template <
class RT,
class PT>
111 {
return getValue(pos[0],pos[1]);}
120 template <
class RT,
class PT>
128 {
return getValue(pos[0],pos[1],pos[2]);}
149 template <
class xT,
class yT>
163 int size()
const {
return x_.size(); }
168 {
return itype_ == Snap ? snapVal(x) : interpVal(x); }
178 virtual yT
getNDValue(
const xT* p )
const {
return getValue(*p); }
187 int baseIdx(xT)
const;
188 yT snapVal(xT)
const;
189 yT interpVal(xT)
const;
190 yT outsideVal(xT)
const;
194 void setXValue(
int idx,xT x);
213 template <
class RT,
class PT>
218 const PT* P_,
const PT* N_)
226 const int nrdim = func.getNrDim();
228 for (
int idx=0; idx<nrdim; idx++ )
229 pos[idx] =
P[idx] + N[idx]*lambda;
231 return func.getNDValue( pos );
250 : a( a_ ), b( b_ ), c( c_ )
260 a = ( (y0+y2) / 2 ) - y1;
267 return pos*pos * a + pos * b + c;
278 pos0 = pos1 =
mUdf(
float);
289 const double halfp = b/a/2;
290 const double q = c/a;
292 const double squareterm = halfp*halfp-q;
299 pos0 = (float)(-halfp+sq);
300 pos1 = (float)(-halfp-sq);
318 float c_=0,
float d_=0 )
319 : a( a_ ), b( b_ ), c( c_ ), d( d_ )
328 b = ( (y2+y0) / 2 ) - y1;
329 c = y2 - ( ( 2*y0 + 3*y1 + y3 ) / 6 );
330 a = ( (y2-y0) / 2 ) - c;
337 const float possq = pos * pos;
338 return possq * pos * a + possq * b + pos * c + d;
346 pos0 = pos1 =
mUdf(
float);
356 return derivate.
getRoots(pos0, pos1);
378 template <
class mXT,
class mYT>
inline
381 const int sz = x_.size();
382 if ( sz < 1 )
return -1;
383 const mXT x0 = x_[0];
384 if ( x < x0 )
return -1;
385 if ( sz == 1 )
return x >= x0 ? 0 : -1;
386 const mXT xlast = x_[sz-1];
387 if ( x >= xlast )
return sz-1;
388 if ( sz == 2 )
return 0;
390 int ilo = 0;
int ihi = sz - 1;
391 while ( ihi - ilo > 1 )
393 int imid = (ihi+ilo) / 2;
404 template <
class mXT,
class mYT>
inline
408 if ( x_.isPresent(x) )
return;
410 const int baseidx = baseIdx( x );
413 const int sz = x_.size();
414 if ( baseidx > sz - 3 )
417 mXT prevx = x; mYT prevy = y;
418 for (
int idx=baseidx+1; idx<sz; idx++ )
420 mXT tmpx = x_[idx]; mYT tmpy = y_[idx];
421 x_[idx] = prevx; y_[idx] = prevy;
422 prevx = tmpx; prevy = tmpy;
427 template <
class mXT,
class mYT>
inline
430 if ( idx<0 || idx >= size() )
437 template <
class mXT,
class mYT>
inline
440 if ( idx<0 || idx>=size() )
443 x_.removeSingle( idx );
444 y_.removeSingle( idx );
448 template <
class mXT,
class mYT>
inline
451 if ( extrapol_ ==
None )
454 const int sz = x_.size();
456 if ( extrapol_==EndVal || sz<2 )
457 return x-x_[0] < x_[sz-1]-x ? y_[0] : y_[sz-1];
461 const mYT gradient = (mYT)(y_[1]-y_[0]) / (mYT) (x_[1]-x_[0]);
462 return (mYT)(y_[0] + (x-x_[0]) * gradient);
465 const mYT gradient = (mYT)(y_[sz-1]-y_[sz-2]) / (mYT) (x_[sz-1]-x_[sz-2]);
466 return (mYT)(y_[sz-1] + (x-x_[sz-1]) * gradient);
472 template <
class mXT,
class mYT>
inline
475 const int sz = x_.size();
476 if ( sz < 1 )
return mUdf(mYT);
478 if ( x < x_[0] || x > x_[sz-1] )
479 return outsideVal(x);
481 const int baseidx = baseIdx( x );
485 if ( baseidx > sz-2 )
487 return x - x_[baseidx] < x_[baseidx+1] - x ? y_[baseidx] : y_[baseidx+1];
491 template <
class mXT,
class mYT>
inline
494 const int sz = x_.size();
495 if ( sz < 1 )
return mUdf(mYT);
497 if ( x < x_[0] || x > x_[sz-1] )
498 return outsideVal(x);
502 const int i0 = baseIdx( x );
503 const mYT v0 = y_[i0];
507 const mXT x0 = x_[i0];
508 const int i1 = i0 + 1;
const mXT x1 = x_[i1];
const mYT v1 = y_[i1];
509 const mXT dx = x1 - x0;
510 if ( dx == 0 )
return v0;
512 const mXT relx = (x - x0) / dx;
514 return relx < 0.5 ? v0 : v1;
521 return (mYT)(v1 * relx + v0 * (1-relx));
523 const int im1 = i0 > 0 ? i0 - 1 : i0;
524 const mXT xm1 = im1 == i0 ? x0 - dx : x_[im1];
525 const mYT vm1 =
mIsUdf(y_[im1]) ? v0 : y_[im1];
527 const int i2 = i1 < sz-1 ? i1 + 1 : i1;
528 const mXT x2 = i2 == i1 ? x1 + dx : x_[i2];
529 const mYT v2 =
mIsUdf(y_[i2]) ? v1 : y_[i2];
533 (
float) x2, v2, (
float) x );
ThirdOrderPoly(float a_=0, float b_=0, float c_=0, float d_=0)
Definition: mathfunc.h:317
Interface to a series of values.
Definition: odmemory.h:16
Multidimensional Mathematical function.
Definition: mathfunc.h:40
@ None
Definition: mathfunc.h:155
float d
Definition: mathfunc.h:359
bool extrapolate() const
Definition: mathfunc.h:175
T poly1D(float x0, T v0, float x1, T v1, float x2, T v2, float x3, T v3, float x)
Definition: interpol1d.h:217
A class for 2nd order polynomials of the form: a x^2 + b x + c.
Definition: mathfunc.h:247
RT getValue(PT lambda) const
Definition: mathfunc.h:224
A Math Function as in F(x,y).
Definition: mathfunc.h:105
virtual RT getValue(PT, PT) const =0
yT snapVal(xT) const
Definition: mathfunc.h:473
void setFromSamples(float y0, float y1, float y2, float y3)
Definition: mathfunc.h:326
#define mIsUdf(val)
Use mIsUdf to check for undefinedness of simple types.
Definition: undefval.h:289
void setInterpolType(InterpolType t)
Definition: mathfunc.h:176
virtual RT getValue(PT, PT, PT) const =0
MathFunction< float, float > FloatMathFunction
Definition: mathfunc.h:72
void setExtrapolateType(ExtrapolType t)
Definition: mathfunc.h:177
int size() const
Definition: mathfunc.h:163
float getExtremePos() const
Definition: mathfunc.h:270
Makes a MathFunction indexable through an operator[].
Definition: mathfunc.h:82
float getValue(float pos) const
Definition: mathfunc.h:264
#define mExpClass(module)
Definition: commondefs.h:177
int getNrDim() const
Definition: mathfunc.h:112
int getNrDim() const
Definition: mathfunc.h:129
#define mDefEps
Definition: commondefs.h:71
@ P
Definition: seistype.h:60
ExtrapolType
Definition: mathfunc.h:155
RT getNDValue(const PT *pos) const
Definition: mathfunc.h:127
virtual RT getNDValue(const PT *) const =0
void setXValue(int idx, xT x)
Definition: mathfunc.h:428
const MathFunctionND< RT, PT > & func
Definition: mathfunc.h:238
Mathematical function.
Definition: mathfunc.h:61
AlongVectorFunction(const MathFunctionND< RT, PT > &func_, const PT *P_, const PT *N_)
Definition: mathfunc.h:217
MathFunction based on bend points.
Definition: mathfunc.h:151
virtual ~MathFunctionND()
Definition: mathfunc.h:42
SamplingData< PT > sd
Definition: mathfunc.h:90
const PT * N
Definition: mathfunc.h:237
bool isUdf(const T &t)
Definition: undefval.h:245
ValSeriesMathFunc(const ValueSeries< float > &, int sz)
InterpolType
Definition: mathfunc.h:154
bool remove(const char *)
const TypeSet< xT > & xVals() const
Definition: mathfunc.h:170
#define mIsZero(x, eps)
Definition: commondefs.h:66
ExtrapolType extrapol_
Definition: mathfunc.h:183
#define mClass(module)
Definition: commondefs.h:181
int sz_
Definition: mathfunc.h:373
A class for 3rd order polynomials on the form: a x^3 + b x^2 + c x + d.
Definition: mathfunc.h:315
@ Linear
Definition: simpnumer.h:189
SecondOrderPoly(float a_=0, float b_=0, float c_=0)
Definition: mathfunc.h:249
LineParameters< float > * createDerivative() const
const ValueSeries< float > & vs_
Definition: mathfunc.h:372
Steepness and intercept.
Definition: linear.h:26
virtual yT getNDValue(const xT *p) const
Definition: mathfunc.h:178
float c
Definition: mathfunc.h:306
yT outsideVal(xT) const
Definition: mathfunc.h:449
void setEmpty()
Definition: mathfunc.h:162
MathFunction< double, double > DoubleMathFunction
Definition: mathfunc.h:73
InterpolType interpolType() const
Definition: mathfunc.h:173
virtual int getNrDim() const
Definition: mathfunc.h:66
MathFunctionSampler(const MathFunction< RT, PT > &f)
Definition: mathfunc.h:84
virtual int getNrDim() const =0
yT interpVal(xT) const
Definition: mathfunc.h:492
A Math Function as in F(x,y,z).
Definition: mathfunc.h:122
@ None
Definition: networkcommon.h:33
MathFunctionND< float, float > FloatMathFunctionND
Definition: mathfunc.h:48
SecondOrderPoly * createDerivative() const
Definition: mathfunc.h:341
void add(xT x, yT y)
Definition: mathfunc.h:405
A MathFunction that cuts through another mathfunction with higher number of dimensions.
Definition: mathfunc.h:215
virtual RT getNDValue(const PT *pos) const
Definition: mathfunc.h:64
virtual RT getValue(PT) const =0
void setFromSamples(float y0, float y1, float y2)
Definition: mathfunc.h:257
BendPointBasedMathFunction< float, float > PointBasedMathFunction
Definition: mathfunc.h:200
Definition: mathfunc.h:365
#define mAllocVarLenArr(type, varnm, __size)
Definition: varlenarray.h:53
RT getNDValue(const PT *pos) const
Definition: mathfunc.h:110
bool isEmpty() const
Definition: mathfunc.h:164
TypeSet< xT > x_
Definition: mathfunc.h:184
#define mUdf(type)
Use this macro to get the undefined for simple types.
Definition: undefval.h:274
const MathFunction< RT, PT > & func_
Definition: mathfunc.h:94
RT operator[](int idx) const
Definition: mathfunc.h:87
yT getValue(xT x) const
Definition: mathfunc.h:167
float getValue(float) const
int getRoots(float &pos0, float &pos1) const
Definition: mathfunc.h:276
ExtrapolType extrapolateType() const
Definition: mathfunc.h:174
void remove(int idx)
Definition: mathfunc.h:438
float getValue(float pos) const
Definition: mathfunc.h:334
BendPointBasedMathFunction(InterpolType t=Linear, ExtrapolType extr=EndVal)
Definition: mathfunc.h:157
TypeSet< yT > y_
Definition: mathfunc.h:185
const TypeSet< yT > & yVals() const
Definition: mathfunc.h:171
int baseIdx(xT) const
Definition: mathfunc.h:379
int getExtremePos(float &pos0, float &pos1) const
Definition: mathfunc.h:344
InterpolType itype_
Definition: mathfunc.h:182
const PT * P
Definition: mathfunc.h:236
Generated at
for the OpendTect
seismic interpretation project.
Copyright (C): dGB Beheer B.V. 1995-2021