From: Paul Brossier Date: Mon, 28 Sep 2009 18:58:03 +0000 (+0200) Subject: src/aubio_priv.h: define VERY_SMALL_NUMBER here, add KILL_DENORMAL and CEIL_DENORMAL... X-Git-Tag: bzr2git~269 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=258195f8cf3aff3e626f5482e6a7a5c07f3e5692;p=aubio.git src/aubio_priv.h: define VERY_SMALL_NUMBER here, add KILL_DENORMAL and CEIL_DENORMAL macros, SAFE_LOG10 and SAFE_LOG --- diff --git a/src/aubio_priv.h b/src/aubio_priv.h index 3342377a..c2506638 100644 --- a/src/aubio_priv.h +++ b/src/aubio_priv.h @@ -189,7 +189,15 @@ typedef enum { #define ELEM_SWAP(a,b) { register smpl_t t=(a);(a)=(b);(b)=t; } -#define ISDENORMAL(f) f < 1.e-37 +#define VERY_SMALL_NUMBER 2.e-42 //1.e-37 + +#define IS_DENORMAL(f) f < VERY_SMALL_NUMBER + +#define KILL_DENORMAL(f) IS_DENORMAL(f) ? 0. : f +#define CEIL_DENORMAL(f) IS_DENORMAL(f) ? VERY_SMALL_NUMBER : f + +#define SAFE_LOG10(f) LOG10(CEIL_DENORMAL(f)) +#define SAFE_LOG(f) LOG(CEIL_DENORMAL(f)) #define UNUSED __attribute__((unused)) diff --git a/src/temporal/filter.c b/src/temporal/filter.c index 3d958832..f3d0c91c 100644 --- a/src/temporal/filter.c +++ b/src/temporal/filter.c @@ -44,7 +44,7 @@ void aubio_filter_do_outplace(aubio_filter_t * f, fvec_t * in, fvec_t * out) { y = f->y->data[i]; for (j = 0; j < in->length; j++) { /* new input */ - if (ISDENORMAL(in->data[i][j])) { + if (IS_DENORMAL(in->data[i][j])) { x[0] = y[0] = 0.; } else { x[0] = in->data[i][j];