Dear all,

I’m writing a block that outputs a vector of complex number inheriting

from

gr_sync_block. In my code I wrote:

gr_complex *out =(gr_complex *) output_items[0];*

gr_complex out_vector [NN];

where out_vector is the array where the actual output values are stored.

I

copied the data to the pointer using:

memcpy(out, out_vector, N*N*sizeof(gr_complex));

before returning noutput_items from work(). make and make install work

fine;

no error shows up. The problem is when I run the flow graph taking the

output of my block to a file sink, the values stored are all zeros.

Any help or suggestions?

Thanks a lot.

##
Sam

View this message in context:

http://old.nabble.com/complex-vector-output-of-a-block-tp28828557p28828557.html

Sent from the GnuRadio mailing list archive at Nabble.com.

On Wed, Jun 09, 2010 at 03:40:07AM -0700, Sammour wrote:

memcpy(out, out_vector, N*N*sizeof(gr_complex));

before returning noutput_items from work(). make and make install work fine;

no error shows up. The problem is when I run the flow graph taking the

output of my block to a file sink, the values stored are all zeros.

Any help or suggestions?

Hi Sammour,

looks like your generating a lot of output data (or how large is N^2?).

Is the number of samples in the file what you expected?

Do you have a history in your block? And what kind of operation are you

performing in work?

MB

–

Karlsruhe Institute of Technology (KIT)

Communications Engineering Lab (CEL)

Dipl.-Ing. Martin B.

Research Associate

KaiserstraÃŸe 12

Building 05.01

76131 Karlsruhe

Phone: +49 721 608-3790

Fax: +49 721 608-6071

www.cel.kit.edu

KIT – University of the State of Baden-WÃ¼rttemberg and

National Laboratory of the Helmholtz Association

Dear Martin,

Thanks for replying. N is designed to be 2:12.

The block uses a number of inputs (N) to update a matrix that I am

sending

to the output as a vector that will be reshaped in the next block when

it

is used. Do you think that my programme takes much time to execute?

Cheers,

##
Sam

View this message in context:

http://old.nabble.com/complex-vector-output-of-a-block-tp28828557p28830131.html

Sent from the GnuRadio mailing list archive at Nabble.com.

To isolate the problem, I removed all the complex code and wrote the

following in work() to generate a vector of random numbers:

gr_complex *out =(gr_complex *) output_items[0];

unsigned int index = 0;

for (unsigned int m =1; m<=4; m++)

{

*(out+index)=gr_complex(std::rand(), std::rand());

index++;

}

return noutput_items;

Here, I get a bunch of complex numbers followed by many zeros followd by

many complex numbers. The number in each group is not constant.

Any suggestions to control this?

Best wishes,

##
Sam

View this message in context:

http://old.nabble.com/complex-vector-output-of-a-block-tp28828557p28831629.html

Sent from the GnuRadio mailing list archive at Nabble.com.

Thanks again Martin.

I believe the problem is not in the algorithm as I actually tested it

and

can print the output of it on the screen as you suggested (I mean “out”

in

my original post). Everything excellent at this stage. However, the

problem

is that the block in GRC doesn’t generate output.

I didn’t want to give details in order not to divert direction of the

problem investigation. However, the block finds the autocovariance

matrix

of N inputs using the update method.

Best regards,

Sam

Martin B.-4 wrote:

Karlsruhe Institute of Technology (KIT)

Fax: +49 721 608-6071

Discuss-gnuradio Info Page

–

View this message in context:

http://old.nabble.com/complex-vector-output-of-a-block-tp28828557p28832150.html

Sent from the GnuRadio mailing list archive at Nabble.com.

On Wed, Jun 09, 2010 at 06:06:01AM -0700, Sammour wrote:

Thanks for replying. N is designed to be 2:12.

The block uses a number of inputs (N) to update a matrix that I am sending

to the output as a vector that will be reshaped in the next block when it

is used. Do you think that my programme takes much time to execute?

Hi Sam,

I have no clue what your block does, and you’re not giving away too much

information

But I don’t think your block should be too difficult to debug, I assume

you have unit tests running (and failing), if not, do that first. Put

in enough data for work() to be called once, and use printfs to see

what’s happening.

MB

–

Karlsruhe Institute of Technology (KIT)

Communications Engineering Lab (CEL)

Dipl.-Ing. Martin B.

Research Associate

KaiserstraÃŸe 12

Building 05.01

76131 Karlsruhe

Phone: +49 721 608-3790

Fax: +49 721 608-6071

www.cel.kit.edu

KIT – University of the State of Baden-WÃ¼rttemberg and

National Laboratory of the Helmholtz Association

On Wed, Jun 09, 2010 at 03:40:07AM -0700, Sammour wrote:

Sam

What are your io_signatures?

Can you describe more clearly what your block is trying to do,

including it’s input type, output type, how many inputs it consumes

for each output produced, etc?

Eric

HI Eric,

Thanks for replying. My block has N=2:12 complex input streams and one

complex vector output stream of length N^2 (represents a reshaped NxN

matrix). The block basically is meant to calculate the covariance matrix

using a MATLAB library.

The signatures are:

input: gr_make_io_signature (2, 2, sizeof(gr_complex));

output: gr_make_io_signature (1, 1,N*N*sizeof(gr_complex));

However, the last thing I reached now is that I can get the output into

a

file sink but when displaying the content, I see the N^2 elements

followed

by a huge number of zeros then N^2 elements and then zeros. For example

if N

= 2 input streams, the output vector will appear like:

a

b

c

d

0

0

0

…

e

f

g

h

0

0

0… and so on.

A remark I noticed is that difference between “a” and “e” is always

around

4096. What confuses me is how to get rid of the zeros and extract only

the

numbers of interest when connecting this block to the next block. Any

hint?

Best regards,

##
Sam

View this message in context:

http://old.nabble.com/complex-vector-output-of-a-block-tp28828557p28836135.html

Sent from the GnuRadio mailing list archive at Nabble.com.

On Wed, Jun 9, 2010 at 5:37 PM, Sammour [email protected] wrote:

output: gr_make_io_signature (1, 1,N*N*sizeof(gr_complex));

0

A remark I noticed is that difference between “a” and “e” is always around

4096. What confuses me is how to get rid of the zeros and extract only the

numbers of interest when connecting this block to the next block. Any hint?

Best regards,

## Sam

View this message in context: http://old.nabble.com/complex-vector-output-of-a-block-tp28828557p28836135.html

Sent from the GnuRadio mailing list archive at Nabble.com.

You’re almost certainly not returning the correct number of items or

telling the schedule the correct number you are consuming. From my

very quick thinking about this (i.e., I’m probably wrong), you need N

inputs from each input stream to produce and N*N vector output stream.*

They way you set up the io_signatures, you are telling the scheduler

that each output item is NN complex floats long. Therefore, this acts

as a N-to-1 decimation block. Are you inheriting from

gr_sync_decimator or gr_sync_block? It should be the former with N as

the decimation rate. Then, when you return the number of items you’ve

created (the number of NxN matrices), you’ve taken care of your cases.

Tom

Hi John, Thanks for the message sorry for using MATLAB notation without

clarification 2:12 = from 2 upto 12.

To simplify the case, I wrote the following code that actually carry the

same problem concept:

#ifdef HAVE_CONFIG_H

#include “config.h”

#endif

#include <arraycomms_construct_rxx_vcc.h>

#include <gr_io_signature.h>

arraycomms_construct_rxx_vcc_sptr arraycomms_make_construct_rxx_vcc (int

input_ports){

return arraycomms_construct_rxx_vcc_sptr (new

arraycomms_construct_rxx_vcc (input_ports));

}

unsigned int N=0; // number of input ports

arraycomms_construct_rxx_vcc::arraycomms_construct_rxx_vcc (int

num_input_ports)

: gr_sync_block (“construct_rxx_vcc”, gr_make_io_signature (2, 12,

sizeof(gr_complex)),

gr_make_io_signature (1,1 ,

num_input_ports*num_input_ports*sizeof(gr_complex))){

```
N=num_input_ports;
```

}

arraycomms_construct_rxx_vcc::~arraycomms_construct_rxx_vcc (){}

int arraycomms_construct_rxx_vcc::work (int noutput_items,

gr_vector_const_void_star &input_items,

gr_vector_void_star &output_items)

{

gr_complex *out =(gr_complex **) output_items[0];*

gr_complex out_vector [NN];

const gr_complex *in[N];*

for (unsigned int i = 0; i<N; i++)

{

in[i] = (const gr_complex *) input_items[i];*

}

for (int i = 0; i < noutput_items; i++){

unsigned int index = 0;

for (unsigned int n =1; n<=NN; n++){

out_vector[index]=gr_complex(4, 0);

index++;

}

}

memcpy(out, out_vector, NNsizeof(gr_complex));

return noutput_items;

}

This code is supposed to generate a vector of 4 elements ( I used N=2 in

the GRC) with each element = 4+j0 whatever the input is. However, the

content of the sink file is:

4.0000000e+00

4.0000000e+00

4.0000000e+00

4.0000000e+00

0.0000000e+00

0.0000000e+00

0.0000000e+00

0.0000000e+00

0.0000000e+00

0.0000000e+00

…

4.0000000e+00

4.0000000e+00

4.0000000e+00

4.0000000e+00

0.0000000e+00

0.0000000e+00

0.0000000e+00

0.0000000e+00

0.0000000e+00

0.0000000e+00

I hope the situation is now clearer.

Cheers,

Sam

Thanks for everyone, I sorted the problem out. I needed to increment

“out”

after memcpy and then return noutput_items/(N*N).

Cheers,

Sam

Sammour wrote:

#endif

arraycomms_construct_rxx_vcc::~arraycomms_construct_rxx_vcc (){}

in[i] = (const gr_complex *) input_items[i];

}

0.0000000e+00

0.0000000e+00

To: [email protected]; [email protected]

Do you have a story that started on Hotmail? Tell us now

Discuss-gnuradio mailing list

[email protected]

Discuss-gnuradio Info Page

–

View this message in context:

http://old.nabble.com/complex-vector-output-of-a-block-tp28828557p28867921.html

Sent from the GnuRadio mailing list archive at Nabble.com.

Tom,

I only need a single sample from each stream to generate the vector (

there

is a method of doing this in signal processing) and I am inherting from

gr_sync_block as the block is 1:1. I am also returning noutput_items and

didn’t use consume_each() of course. Thanks anyway.

Still thinking

##
Cheers,

Sam

View this message in context:

http://old.nabble.com/complex-vector-output-of-a-block-tp28828557p28836849.html

Sent from the GnuRadio mailing list archive at Nabble.com.

On Sat, Jun 12, 2010 at 03:40:21PM -0700, Sammour wrote:

Thanks for everyone, I sorted the problem out. I needed to increment “out”

after memcpy and then return noutput_items/(N*N).

Cheers,

Sam

OK. Glad you (think) you solved your problem.

Given that your block was asked to compute noutput_items, why are you

only computing (and/or returning) noutput_items/(N*N) items?*

Doing it this way is increasing the runtime overhead by something on

the order of NN.

This smells like there’s something that you don’t understand about

io_signatures, forecast, work, set_output_multiple and/or

gr_sync_decimator…

Eric

Well, I think I used io_signature correctly. And, as I am using

gr_sync_block, I dont need to worry about forecast, set_output_multiple

or

gr_sync_decimator. (I hope this understanding is correct?!)

I have read the " how to write a block" and followed what’s in there,

but if

you guide me to better documentation, I will be very grateful.

Cheers,

Sam

Eric B. wrote:

OK. Glad you (think) you solved your problem.

Eric

Discuss-gnuradio mailing list

[email protected]

Discuss-gnuradio Info Page

–

View this message in context:

http://old.nabble.com/complex-vector-output-of-a-block-tp28828557p28869890.html

Sent from the GnuRadio mailing list archive at Nabble.com.