Dealing with `divide 0` or `Inf` in GNU Radio C++ code

Let’s think about the following auto/cross correlator:
http://i.imgur.com/Fy5hdVj.png
I’ve placed divide because I need to normalize the correlation result.

If we place null source, or constant source with value of zero right
before the pad source, the simplified form of the correlator becomes 0
divided by 0.

I’ve placed time sink right after the pad sink then, I can see the
line
hit the infinity. With a simplified flow graph:
http://i.imgur.com/Msx9EQj.png

Back to the my correlator, how can I handle such infinity value coming
into the next block?

My guess is that if a source block is a type of float, then infinity
might have a maximum value of float. So, I think I can reject infinity
value with if (in[i] > threshold), where threshold is big enough,
for
correlator it is fine to have a value just larger than one.

Do you think what I guess is right? Or can some boost numeric types, or
PMT
help somehow to deal with it?

In addition, not important.
In pages std::numeric_limits<T>::infinity - cppreference.com
and
INFINITY - cppreference.com,
non floating point numeric types can’t handle infinity.
Is it also applied to GNU Radio?

Regards,
Jeon.

Jeon,

You can add an appropriate constant before the divide and compensate for
it afterward. The exact math will depend on the values coming out of the
correlators.

Jeff

(That should be “moving averages”, not “correlators”). Also, subtracting
instead of dividing might do what you want.

Jeff

Hi Jeff,

you could use a strcture like this
MA_divisor => Divide: % => multiply => pad sink.
|-> threshold detector -^

i.e. take the divisor path in parallel into threshold detector and use
the output (in {0,1}) in a multiplier for masking the dividing by zero
cases.

By adjusting the threshold to 0+eps (a small number of your choice),
this also solves the problem of huge output if the divisor is almost
0.

Best regards

Stephan Ludwig

Robert Bosch GmbH
Corporate Sector Research & Advance Engineering, Communication
Technology (CR/AEH4)
Renningen
70465 Stuttgart
GERMANY

Tel. +49(711)811-8809
Fax +49(711)811-1052
Mobile +49(172)5630639
[email protected]

Registered Office: Stuttgart, Registration Court: Amtsgericht Stuttgart,
HRB 14000;
Chairman of the Supervisory Board: Franz Fehrenbach; Managing Directors:
Dr. Volkmar Denner,
Dr. Stefan Asenkerschbaumer, Dr. Rolf Bulander, Dr. Stefan Hartung, Dr.
Markus Heyn, Dr. Dirk Hoheisel,
Christoph Kbel, Uwe Raschke, Dr. Werner Struth, Peter Tyroller

-----Ursprngliche Nachricht-----
Von: discuss-gnuradio-bounces+stephan.ludwig2=removed_email_address@domain.invalid
[mailto:discuss-gnuradio-bounces+stephan.ludwig2=removed_email_address@domain.invalid]
Im Auftrag von Jeff L.
Gesendet: Mittwoch, 19. August 2015 13:31
An: [email protected]
Betreff: Re: [Discuss-gnuradio] Dealing with divide 0 or Inf in GNU
Radio C++ code.

(That should be “moving averages”, not “correlators”). Also, subtracting
instead of dividing might do what you want.

Jeff

On 08/19/2015 07:25 AM, Jeff L. wrote:

http://i.imgur.com/Fy5hdVj.png
Back to the my correlator, how can I handle such infinity value
In addition, not important.


Discuss-gnuradio mailing list
[email protected]
Discuss-gnuradio Info Page


Discuss-gnuradio mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/discuss-gnuradio