discuss-gnuradio
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Discuss-gnuradio] nlog10: do we consider "normalizes log10(x <= 0)


From: Kevin Reid
Subject: Re: [Discuss-gnuradio] nlog10: do we consider "normalizes log10(x <= 0) to -18" as API?
Date: Mon, 20 Nov 2017 17:34:32 -0800

On Mon, Nov 20, 2017 at 7:52 AM, Marcus Müller <address@hidden> wrote:
I was about to commit a PR VOLKizing nlog10 [1], but it struck me that
my processor (imho, correctly) says that log(0) == nan and log(-10) ==
nan.

Whereas the old nlog10 test case asserts that it's log_10(x<=0) == -18.

So, am I allowed to break that assertion for the greater mathematical
appropriateness and speed?

I think it would be appropriate to produce negative infinity rather than NaN for log(0). Still not finite, but a more useful answer — you can max() with it to get a finite lower bound if that is what your application finds useful, whereas NaN just gives NaN.

The most common use of nlog10 is presumably log scaled FFTs. In that case, there will be output NaN/infs any time the input signal is zeroes, which is a plausible happening. In that context, it might break somebody's graphics code; depending on the language and libraries used, either with an unexpected exception or with just that frame not drawing at all (which, since it would typically be fully outside the viewport, doesn't seem that bad).

Certainly it would be good to make sure that the GR QT GUI widgets don't have any trouble with the resulting NaN/infs.

Overall it seems like a reasonable change to me, for what that's worth.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]