[Top][All Lists]

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

Re: OutofTree Block C++ problem

From: Mario Moran
Subject: Re: OutofTree Block C++ problem
Date: Mon, 15 Nov 2021 13:18:35 -0700

This fixed my problem. Thank you so much. I am wondering if you know anything about runtime error: itemsize mismatch? Would this mean that I am returned a value that the chunks to symbols block can't handle it? Because it says that my random block is 8 while the chunks to symbol is 1. 

On Mon, Nov 15, 2021 at 4:23 AM Malte Lenhart <malte.lenhart@mailbox.org> wrote:
Hi Mario,

have a look at the header file here: https://github.com/gnuradio/gnuradio/blob/eb91fb04b3d0ca8124b9bea375e3bf72963fa172/gnuradio-runtime/include/gnuradio/random.h

61|    double X = gr::random(0,0,2)
    |                           ^~~~~~~~~~~
    |                           gr::random

you are calling the constructor of gr::random here, which does not return anything.

Instead you need to assign it something and then query it for random numbers


gr::random foo = gr::random(0,0,2);
int i = foo.ran_int();
// .. you can then do it again of course
int j = foo.ran_int();

you seem to be wanting a double, where you have to check which distribution you want (see the header file).

One example could be

double d = static_cast<double>(foo.gasdev());

which will, if I looked right, give you a float in the range of -1 and 1. To get it in range 0 to 2, you can just add 1.0 to it.

Best regards,


[my mail program/me took the wrong mail address when replying to the digest, therefore answer delayed a bit]

reply via email to

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