3 * Copyright 2004,2010 Free Software Foundation, Inc.
5 * This file is part of GNU Radio
7 * GNU Radio is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 3, or (at your option)
12 * GNU Radio is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with GNU Radio; see the file COPYING. If not, write to
19 * the Free Software Foundation, Inc., 51 Franklin Street,
20 * Boston, MA 02110-1301, USA.
24 * config.h is generated by configure. It contains the results
25 * of probing for features, options etc. It should be the first
26 * file included in your .cc file.
32 #include <howto_square_ff.h>
33 #include <gr_io_signature.h>
36 * Create a new instance of howto_square_ff and return
37 * a boost shared_ptr. This is effectively the public constructor.
40 howto_make_square_ff ()
42 return gnuradio::get_initial_sptr(new howto_square_ff ());
46 * Specify constraints on number of input and output streams.
47 * This info is used to construct the input and output signatures
48 * (2nd & 3rd args to gr_block's constructor). The input and
49 * output signatures are used by the runtime system to
50 * check that a valid number and type of inputs and outputs
51 * are connected to this block. In this case, we accept
52 * only 1 input and 1 output.
54 static const int MIN_IN = 1; // mininum number of input streams
55 static const int MAX_IN = 1; // maximum number of input streams
56 static const int MIN_OUT = 1; // minimum number of output streams
57 static const int MAX_OUT = 1; // maximum number of output streams
60 * The private constructor
62 howto_square_ff::howto_square_ff ()
63 : gr_block ("square_ff",
64 gr_make_io_signature (MIN_IN, MAX_IN, sizeof (float)),
65 gr_make_io_signature (MIN_OUT, MAX_OUT, sizeof (float)))
67 // nothing else required in this example
71 * Our virtual destructor.
73 howto_square_ff::~howto_square_ff ()
75 // nothing else required in this example
79 howto_square_ff::general_work (int noutput_items,
80 gr_vector_int &ninput_items,
81 gr_vector_const_void_star &input_items,
82 gr_vector_void_star &output_items)
84 const float *in = (const float *) input_items[0];
85 float *out = (float *) output_items[0];
87 for (int i = 0; i < noutput_items; i++){
88 out[i] = in[i] * in[i];
91 // Tell runtime system how many input items we consumed on
94 consume_each (noutput_items);
96 // Tell runtime system how many output items we produced.