[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Discuss-gnuradio] Cumsum block on GRC
From: |
Nick Foster |
Subject: |
Re: [Discuss-gnuradio] Cumsum block on GRC |
Date: |
Sat, 07 May 2011 16:57:19 +0200 |
On Sat, 2011-05-07 at 15:53 +0100, Tom Rondeau wrote:
> On Sat, May 7, 2011 at 3:44 PM, mehmet kabasakal
> <address@hidden> wrote:
> Hi List,
>
> I am trying to write a block, that finds the cumulative sum of
> the points.
> But when i run the block on GRC, the output of the block
> becomes as in
> the attached figure. It wraps for a period of time. I expect
> it to go
> negatively downwards. Because i am accumulating negative
> values. I
> couldn't understand the reason. Is there something missing in
> the
> code. The c++ code of the block is attached also.
>
> Thanks for the help!
> Mehmet.
>
>
>
> Mehmet,
> It looks like it's because you are setting out[0] = 0 before entering
> the for loop in your work function. This will then reset the counter
> every time you enter work.
I'm pretty sure it won't work even if you remove that call. You can't
count on out[0] having any sort of reasonable value when invoking the
work call. Try saving the cumulative sum in a private member variable of
your class, initialize it to 0 in your constructor, and setting out[0]
to that saved value when starting each work function call.
--n
>
>
> Tom
>
>
> _______________________________________________
> Discuss-gnuradio mailing list
> address@hidden
> https://lists.gnu.org/mailman/listinfo/discuss-gnuradio