discuss-gnuradio
[Top][All Lists]
Advanced

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

[Discuss-gnuradio] Re: Multiplying blocks


From: Eric Blossom
Subject: [Discuss-gnuradio] Re: Multiplying blocks
Date: Fri, 9 Jun 2006 15:31:23 -0700
User-agent: Mutt/1.5.9i

On Thu, Jun 08, 2006 at 06:01:16PM -0700, Johnathan Corgan wrote:
> Eric,
> 
> I'm trying to figure out how to multiply two vectors together.

> One is the output of gr.serial_to_parallel()

(FYI, the prefered name for this block is now gr.stream_to_vector.
It's inverse, previously known as parallel_to_serial, is now vector_to_stream)

> The other is the output of gr.vector_source_f()
> 
> I think I'm looking for the vector equivalent of gr.multiply_const()

OK, let me make sure I understand this.  Is this right?

  You want a block that takes in two streams: one float, one "vector float",
  and produces a single output stream: "vector float",
  where each element of each output vector is multplied by the scaling
  factor of the corresponding first input.

If I've got this right, we don't currently have a block that does
this.  However, this and other operations like it would be a great
addition to the code base.

There has been a bit of discussion about this in the past.

One idea has been to use the "Universal function" (ufunc) idea from
NumPy and Numeric:

    Universal functions are wrappers that provide a common interface to 
mathematical
    functions that operate on scalars, and can be made to operate on arrays in
    an element-by-element fashion. All universal functions (ufuncs) wrap some 
core
    function that takes $n_i$ (scalar) inputs and produces $n_o$ (scalar) 
outputs.

Assume for the sake of discussion that we've got a bunch of unary and
binary functions, with some common signatures.
E.g., float -> float; complex -> complex; float -> complex and complex -> float

These could be things like:

  unary:
    abs
    negate
    conj
    sin
    cos
    add_const
    mult_const
    ...

  binary:
    add
    sub
    mult
    div
    ...

Then we would need only a small number of GR blocks that would deal
with the various signatures.  You'd pass the "ufunc" (basically a
pointer to a function, or more likely a class), to the constructor, and
then it would apply it to your data.

  gr.apply_binary_ufunc_ff(ufunc, vlen_in0, vlen_in1, vlen_out0)

where vlen_in0 was the vector length of the first input, etc.
If the vector length of an element was shorter than the other, say one
of them was 1, then the last value in the vector would be "broadcast"
(extended) across the other vector.

These would operate "horizontally", across the inputs, producing an
output value.


Are you interested in building something along these lines?
It would be a *very* useful contribution.

> The application is applying an custom analysis window to incoming blocks
> of complex data prior to some further manipulation and feeding into an
> fft block.

Sounds interesting.

> Scratching my head on this one.

Me too ;)

Eric




reply via email to

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