Simple GR_SYNC_BLOCK

I think I’ve misunderstood they way GR_SYNC_BLOCK
works. Can someone set me strait?

I’ve called set_history(1) in the constructor; I have
one input and one output. I assumed that the in buffer
would contain noutput_items + 1 samples; with in[0]
being the history (overlap) from the previous.

I’m trying to take a diff then do a cumsum on the
stream.

Can someone point me in the right direction?

-Daniel

work (
int noutput_items,
gr_vector_const_void_star &input_items,
gr_vector_void_star &output_items)
{

const float *in = (const float *) input_items[0];
float *out = (float *) output_items[0];

for (int ii = 0; ii < noutput_items; ii++) {
out[ii] = in[ii + 1] - in[ii];
}
for (int ii = 0; ii < noutput_items; ii++) {
d_cumsum = out[i] + d_cumsum;
out[ii] = d_cumsum;
}

return noutput_items;
}


8:00? 8:25? 8:40? Find a flick in no time
with the Yahoo! Search movie showtime shortcut.
http://tools.search.yahoo.com/shortcuts/#news

Daniel G. wrote:

out[ii] = in[ii + 1] - in[ii];

}
for (int ii = 0; ii < noutput_items; ii++) {
d_cumsum = out[i] + d_cumsum;
out[ii] = d_cumsum;
}

return noutput_items;
}

I haven’t actually tried to figure out the answer to your question, but

  1. That out[i] bothers me. Shouldn’t it be out[ii]?

  2. Is there a good reason for doing this in two passes with two stores
    to each memory location? You can do this in one pass with another temp
    variable to hold the first value of out[ii]. The compiler might optimize
    it for you, and then again it might not…

-Dan

On Wed, Mar 07, 2007 at 09:59:02AM -0800, Daniel G. wrote:

stream.

Can someone point me in the right direction?

You are off by one. The nomenclature might not be the best in the
world, but it’s what we’ve got.

history refers to how many samples you need to look at to compute a
single output (ignoring decimation and interpolation). Thus, the
normal case is 1. That is y[i] = f(x[i]).

If you want noutput_samples + 1, then set_history(2).

Eric

  1. That out[i] bothers me. Shouldn’t it be out[ii]?

Yes, it should. I edited the snippet in the email to
remove a bunch of std::cout junk… mucked that up in
the process.

  1. Is there a good reason for doing this in two
    passes with two stores
    to each memory location?

There is a very good reason for doing it in two
passes: it doesn’t work. I’m just trying to write it
as straight-forward was possible. After it works, I
can optimize it.

-Daniel


Bored stiff? Loosen up…
Download and play hundreds of games for free on Yahoo! Games.
http://games.yahoo.com/games/front