discuss-gnuradio
[Top][All Lists]
Advanced

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

Re: OutofTree Block C++ problem


From: Malte Lenhart
Subject: Re: OutofTree Block C++ problem
Date: Mon, 15 Nov 2021 12:23:24 +0100

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

like

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,

Malte

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

Attachment: OpenPGP_signature
Description: OpenPGP digital signature


reply via email to

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