Re: Is this the optimal FIR filter on all platforms?
From: Johan Bergman (johan.bergman_at_ericsson.com)
Date: 10/26/03
- Next message: Johan Bergman: "Re: [OT] Re: Is this the optimal FIR filter on all platforms?"
- Previous message: Lloyd Parker: "Re: Fundamental Reason for High Achievements of Jews"
- In reply to: Arthur J. O'Dwyer: "Re: Is this the optimal FIR filter on all platforms?"
- Next in thread: Johan Bergman: "Re: Is this the optimal FIR filter on all platforms?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Sun, 26 Oct 2003 17:43:09 +0100
Hi Arthur, thanks for your reply!
> What in the world is an FIR filter? (Finite impulse-response, yes,
> yes, I know, I looked it up. Point is, practically nobody in this
> newsgroup will know, either, and they'll *all* have to look it up
> if they really want to help you. You're making it harder for people
> to help you when you don't define your terms.)
Sorry, maybe I should have described the background a bit better. An FIR
filter is one of the basic filter types in digital signal processing, and my
example shows one of the ways to realize it. For FIR filter this long (10000
taps), it would actually make more sence to choose another realization based
on FFTs (Fast Fourier Transforms). But first I would like to see how fast I
can make the realization in the example.
> Well, first let's clean up your code and see what it looks like
> then. Clean code is always easier to operate on. :-)
OK then! :-)
> #include <stdlib.h>
>
> int main(void)
> {
> int nrof_lags = 10000; /* Could both of these be #defines? */
> int nrof_taps = 10000; /* That would help a little. */
>
> int *coeffs = malloc(nrof_taps * sizeof *coeffs);
> int *input = malloc((nrof_taps+nrof_lags) * sizeof *input);
> int *output = malloc(nrof_lags * sizeof *output);
> int i, j;
>
> for (i=0; i < nrof_lags; ++i)
> {
> int sum = 0;
> for (j=0; j < nrof_taps; ++j)
> sum += coeffs[j] * input[i+j];
> output[i] = sum;
> }
>
> free(coeffs);
> free(input);
> free(output);
> return 0;
> }
Thanks for the cleanup!
> How's the code do now?
Sorry, it is slightly slower than my (admittedly terrible) original code.
BR,
Johan
- Next message: Johan Bergman: "Re: [OT] Re: Is this the optimal FIR filter on all platforms?"
- Previous message: Lloyd Parker: "Re: Fundamental Reason for High Achievements of Jews"
- In reply to: Arthur J. O'Dwyer: "Re: Is this the optimal FIR filter on all platforms?"
- Next in thread: Johan Bergman: "Re: Is this the optimal FIR filter on all platforms?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|
|