discuss-gnuradio
[Top][All Lists]
Advanced

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

[Discuss-gnuradio] Avoiding divide by zero in case of input being zero.


From: Anshul Thakur
Subject: [Discuss-gnuradio] Avoiding divide by zero in case of input being zero.
Date: Fri, 30 Mar 2018 23:19:18 +0530

Hi,

I used a circular buffer of finite size to keep the past 'N' power values of the sample stream in my block as a part of creating a running sum. This buffer is initialized to 0 in the constructor. 
The running sum of powers is used to compute the average power used in computing signal correlation.

I have a capture stream (cfile) to test the operation of the block. The test case uses a vector_source_c block to read the contents of the file into memory. The unit tests pass without error. 

However, when I use the block in a flowgraph in that reads the same file from a file source block gnuradio_companion, I am getting the first few sample values as 0 which cause a divide by zero problem. This messes up the rest of the running sum. I don't want to put an 'if' block that checks for the zero condition as it is not expected that a device/stream would ever spit out zero values.

(a) Why am I getting the initial zero samples from the file block in gnuradio_companion and non-zero values when using a vector_source in unit tests?

(b) What can I do about it (here specifically as a fix to the situation, and a general guideline to always remember)?

I am using GNURadio version 3.7.12. 

Regards,
Anshul

reply via email to

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