Thank you all for help/suggestions.

I think I was most successful in implementing it the way Karthik described
it. My code below:
const float *in = (const float *) input_items[0];
float *out = (float *) output_items[0];

for (int i = 0; i < d_vlen; i++){
        temp = in[i] * (i+1);
        d_buffer.push_back(temp);
}
for(int j = 0; j < d_vlen; j++) {avg += d_buffer[j]; }

out[0] = avg / d_vlen;
d_buffer.clear();

It seems to work with built-in "how to...block" test script.  I've tried
putting in a size 512 vector and received an output vector of length 1.

Regards,
Mikhail

P.S. I've attached my code if somebody wants a look.

On Mon, Mar 30, 2009 at 11:56 PM, Eric Blossom <e...@comsec.com> wrote:

> On Mon, Mar 30, 2009 at 09:17:18AM +0200, Martin Braun wrote:
> > On Sat, Mar 28, 2009 at 05:35:59PM -0700, Mikhail Tadjikov wrote:
> > > Thanks, but I'm trying to get weighted average specifically. I've
> looked at the
> > > code for moving_average... it's close to what I need, but its 1:1
> in/out ratio,
> > > but I need N:1 ratio. That's the part I'm particular unclear about.
> >
> > Since you're turning 1 vector into 1 output value, you could also use a
> > gr_sync_block and prepend it with a gr_stream_to_vector. That
> > automatically takes care of aligning etc.; if you use a sync_decimator
> > you're not guaranteed to get N samples every time.
>
> Actually, with a sync decimator, you'll get a multiple of N input samples
> every time.
>
> Eric
>
>
> _______________________________________________
> Discuss-gnuradio mailing list
> Discuss-gnuradio@gnu.org
> http://lists.gnu.org/mailman/listinfo/discuss-gnuradio
>



-- 
Mikhail Tadjikov
Graduate Student
UCLA Department of
Electrical Engineering

Attachment: cores_weighted_avg_ff.cc
Description: Binary data

Attachment: cores_weighted_avg_ff.h
Description: Binary data

_______________________________________________
Discuss-gnuradio mailing list
Discuss-gnuradio@gnu.org
http://lists.gnu.org/mailman/listinfo/discuss-gnuradio

Reply via email to