cmVectOps.h,cmVectOpsRIHdr.h,cmVectOpsRICode.h: Added use of generic cmIsClose()
to vector op. IsClose().
This commit is contained in:
parent
72bfc7442f
commit
172b562022
@ -104,6 +104,8 @@ cmReal_t cmVOI_Variance(const int* sp, unsigned sn, const cmReal_t* mean);
|
|||||||
// dbp[1,dn] = v[1,vn] * m[vn,dn]
|
// dbp[1,dn] = v[1,vn] * m[vn,dn]
|
||||||
cmComplexR_t* cmVORC_MultVVM( cmComplexR_t* dbp, unsigned dn, const cmComplexR_t* vp, unsigned vn, const cmComplexR_t* m );
|
cmComplexR_t* cmVORC_MultVVM( cmComplexR_t* dbp, unsigned dn, const cmComplexR_t* vp, unsigned vn, const cmComplexR_t* m );
|
||||||
|
|
||||||
|
#define cmAbs(x) _Generic((x), double:fabs, float:fabsf, int:abs, unsigned:abs, default:fabs )(x)
|
||||||
|
#define cmIsClose(x0,x1,eps) _Generic((x0), double:cmIsCloseD, float:cmIsCloseF, int:cmIsCloseI, unsigned:cmIsCloseU, default:cmIsCloseD)(x0,x1,eps)
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
@ -873,22 +873,12 @@ bool VECT_OP_FUNC(IsEqual)( const VECT_OP_TYPE* s0p, const VECT_OP_TYPE* s1p, un
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool VECT_OP_FUNC(IsClose)( const VECT_OP_TYPE* s0p, const VECT_OP_TYPE* s1p, unsigned sn, double pct )
|
bool VECT_OP_FUNC(IsClose)( const VECT_OP_TYPE* s0p, const VECT_OP_TYPE* s1p, unsigned sn, double eps )
|
||||||
{
|
{
|
||||||
const VECT_OP_TYPE* ep = s0p + sn;
|
const VECT_OP_TYPE* ep = s0p + sn;
|
||||||
for(; s0p < ep; ++s0p,++s1p )
|
for(; s0p < ep; ++s0p,++s1p )
|
||||||
{
|
{
|
||||||
double d = *s1p - *s0p;
|
if( !cmIsClose(*s0p,*s1p,eps) )
|
||||||
double s = cmMin(*s1p,*s0p);
|
|
||||||
|
|
||||||
// take abs value of d and s
|
|
||||||
if( d < 0 )
|
|
||||||
d *= -1;
|
|
||||||
|
|
||||||
if( s < 0 )
|
|
||||||
s *= -1;
|
|
||||||
|
|
||||||
if( d*100.0/s > pct )
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
@ -137,8 +137,9 @@ unsigned* VECT_OP_FUNC(MaxIndexM)( unsigned* dp, const VECT_OP_TYPE* sp, unsign
|
|||||||
/// Return true if s0p[sn] is equal to s1p[sn]
|
/// Return true if s0p[sn] is equal to s1p[sn]
|
||||||
bool VECT_OP_FUNC(IsEqual)( const VECT_OP_TYPE* s0p, const VECT_OP_TYPE* s1p, unsigned sn );
|
bool VECT_OP_FUNC(IsEqual)( const VECT_OP_TYPE* s0p, const VECT_OP_TYPE* s1p, unsigned sn );
|
||||||
|
|
||||||
/// Return true if all elements of s0p[sn] are within 'pct' percent of s1p[sn].
|
/// Return true if all elements of s0p[sn] are within 'eps' of s1p[sn].
|
||||||
bool VECT_OP_FUNC(IsClose)( const VECT_OP_TYPE* s0p, const VECT_OP_TYPE* s1p, unsigned sn, double pct );
|
/// This function is based on cmMath.h:cmIsCloseX()
|
||||||
|
bool VECT_OP_FUNC(IsClose)( const VECT_OP_TYPE* s0p, const VECT_OP_TYPE* s1p, unsigned sn, double eps );
|
||||||
|
|
||||||
/// Return the most frequently occuring element in sp.
|
/// Return the most frequently occuring element in sp.
|
||||||
VECT_OP_TYPE VECT_OP_FUNC(Mode)( const VECT_OP_TYPE* sp, unsigned sn );
|
VECT_OP_TYPE VECT_OP_FUNC(Mode)( const VECT_OP_TYPE* sp, unsigned sn );
|
||||||
|
Loading…
Reference in New Issue
Block a user