26 template <
class A,
class B,
class C>
28 int ly,
int ify,
const B& y,
29 int lz,
int ifz, C& z)
31 int ilx=ifx+lx-1,ily=ify+ly-1,ilz=ifz+lz-1,i,j,jlow,jhigh;
34 for ( i=ifz; i<=ilz; ++i )
37 if ( jlow < ifx ) jlow = ifx;
40 if ( jhigh > ilx ) jhigh = ilx;
42 for ( j=jlow,sum=0.0; j<=jhigh; ++j )
45 sum += x[j-ifx]*y[i-j-ify];
53 template <
class A,
class B,
class C>
55 int ly,
int ify,
const B& y,
56 int lz,
int ifz, C& z)
58 int ilx=ifx+lx-1,ily=ify+ly-1,ilz=ifz+lz-1,i,j,jlow,jhigh;
61 for ( i=ifz; i<=ilz; ++i )
64 if ( jlow < ifx ) jlow = ifx;
67 if ( jhigh > ilx ) jhigh = ilx;
69 for ( j=jlow,sum=0.0; j<=jhigh; ++j )
70 sum += x[j-ifx]*y[i-j-ify];
81 template <
class A,
class B>
82 inline float similarity(
const A& a,
const B& b,
int sz,
bool normalize=
false,
83 int firstposa=0,
int firstposb=0 )
86 double sqdist = 0, sq1 = 0, sq2 = 0;
88 double meana =
mUdf(
double), stddeva =
mUdf(
double);
89 double meanb =
mUdf(
double), stddevb =
mUdf(
double);
93 if ( sz==1 ) normalize =
false;
97 for (
int idx=0; idx<sz; idx++ )
99 asum += a[firstposa+idx];
100 bsum += b[firstposb+idx];
108 for (
int idx=0; idx<sz; idx++ )
110 const double adiff = a[firstposa+idx]-meana;
111 const double bdiff = b[firstposb+idx]-meanb;
124 int curposa = firstposa;
125 int curposb = firstposb;
127 for (
int idx=0; idx<sz; idx++ )
129 val1 = normalize ? (float) ( (a[curposa]-meana)/stddeva ) : a[curposa];
130 val2 = normalize ? (float) ( (b[curposb]-meanb)/stddevb ) : b[curposb];
136 sqdist += (val1-val2) * (val1-val2);
156 float x1,
float x2,
float dist,
int sz,
bool normalize );
175 float& res,
float targetval = 0,
float tol=1e-5);
197 float x2,
float tol = 1e-5);
200 template <
class A,
class B>
inline 202 B& output,
int nrsamples )
204 for (
int idx=0; idx<nrsamples; idx++ )
206 const float sampleval = samplevals[idx];
227 template <
class A,
class B,
class C>
229 int ly,
int ify,
const B& y,
230 int lz,
int ifz, C& z)
234 for (
int i=0,j=lx-1; i<lx; ++i,--j)
244 for (
int idx=0; idx<sz; idx++ )
245 out[idx] = in[sz-1-idx];
249 for (
int idx=0; idx<sz/2; idx++ )
251 tmparr[idx] = in[idx];
252 int opsamp = sz-1-idx;
253 in[idx] = in[opsamp];
254 in[opsamp] = tmparr[idx];
#define mIsUdf(val)
Use mIsUdf to check for undefinedness of simple types.
Definition: undefval.h:285
double LanczosKernel(int size, double x)
#define mGlobal(module)
Definition: commondefs.h:160
#define mIsZero(x, eps)
Definition: commondefs.h:55
void GenericConvolve(int lx, int ifx, const A &x, int ly, int ify, const B &y, int lz, int ifz, C &z)
Definition: genericnumer.h:27
Mathematical function.
Definition: mathfunc.h:59
void genericCrossCorrelation(int lx, int ifx, const A &x, int ly, int ify, const B &y, int lz, int ifz, C &z)
Definition: genericnumer.h:228
float semblance(const ObjectSet< float > &trcs, const Interval< int > &)
float findExtreme(const FloatMathFunction &, bool minima, float x1, float x2, float tol=1e-5)
#define mUdf(type)
Use this macro to get the undefined for simple types.
Definition: undefval.h:270
float similarity(const A &a, const B &b, int sz, bool normalize=false, int firstposa=0, int firstposb=0)
Definition: genericnumer.h:82
float findValueInAperture(const FloatMathFunction &, float startx, const Interval< float > &aperture, float dx, float target=0, float tol=1e-5)
#define mAllocVarLenArr(type, varnm, __size)
Definition: varlenarray.h:52
#define mDefEps
Definition: commondefs.h:60
void reverseArray(A *in, int sz, A *out=0)
Definition: genericnumer.h:241
bool findValue(const FloatMathFunction &, float x1, float x2, float &res, float targetval=0, float tol=1e-5)
void GenericConvolveNoUdf(int lx, int ifx, const A &x, int ly, int ify, const B &y, int lz, int ifz, C &z)
Definition: genericnumer.h:54
#define mAllocLargeVarLenArr(type, varnm, __size)
Definition: varlenarray.h:29
bool isUdf(const T &t)
Definition: undefval.h:241
virtual RT getValue(PT) const =0
void reSample(const FloatMathFunction &input, const A &samplevals, B &output, int nrsamples)
Definition: genericnumer.h:201