add Vcs entries to control file
[debian/gnuradio] / gnuradio-core / src / lib / filter / gr_fir_ccc_generic.cc
1 /* -*- c++ -*- */
2 /*
3  * Copyright 2002 Free Software Foundation, Inc.
4  * 
5  * This file is part of GNU Radio
6  * 
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)
10  * any later version.
11  * 
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.
16  * 
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.
21  */
22
23 #ifdef HAVE_CONFIG_H
24 #include <config.h>
25 #endif
26 #include <gr_fir_ccc_generic.h>
27
28 #if (2 == 4)
29
30 gr_complex
31 gr_fir_ccc_generic::filter (const gr_complex input[])
32 {
33   static const int N_UNROLL = 4;
34
35   gr_complex    acc0 = 0;
36   gr_complex    acc1 = 0;
37   gr_complex    acc2 = 0;
38   gr_complex    acc3 = 0;
39
40
41   unsigned      i = 0;
42   unsigned      n = (ntaps () / N_UNROLL) * N_UNROLL;
43
44   for (i = 0; i < n; i += N_UNROLL){
45     acc0 += d_taps[i + 0] *  input[i + 0];
46     acc1 += d_taps[i + 1] *  input[i + 1];
47     acc2 += d_taps[i + 2] *  input[i + 2];
48     acc3 += d_taps[i + 3] *  input[i + 3];
49   }
50
51   for (; i < ntaps (); i++)
52     acc0 += d_taps[i] *  input[i];
53
54   return (gr_complex) (acc0 + acc1 + acc2 + acc3);
55 }
56
57 #else 
58
59 gr_complex
60 gr_fir_ccc_generic::filter (const gr_complex input[])
61 {
62   static const int N_UNROLL = 2;
63
64   gr_complex    acc0 = 0;
65   gr_complex    acc1 = 0;
66
67   unsigned      i = 0;
68   unsigned      n = (ntaps () / N_UNROLL) * N_UNROLL;
69
70   for (i = 0; i < n; i += N_UNROLL){
71     acc0 += d_taps[i + 0] *  input[i + 0];
72     acc1 += d_taps[i + 1] *  input[i + 1];
73   }
74
75   for (; i < ntaps (); i++)
76     acc0 += d_taps[i] *  input[i];
77
78   return (gr_complex) (acc0 + acc1);
79 }
80
81 #endif // N_UNROLL
82
83 void 
84 gr_fir_ccc_generic::filterN (gr_complex output[],
85                              const gr_complex input[],
86                              unsigned long n)
87 {
88   for (unsigned i = 0; i < n; i++)
89     output[i] = filter (&input[i]);
90 }
91
92 void 
93 gr_fir_ccc_generic::filterNdec (gr_complex output[],
94                                 const gr_complex input[],
95                                 unsigned long n,
96                                 unsigned decimate)
97 {
98   unsigned j = 0;
99   for (unsigned i = 0; i < n; i++){
100     output[i] = filter (&input[j]);
101     j += decimate;
102   }
103 }