0
$\begingroup$

I read in a book that the output of a decimate filter can be calculated at output sampling rate. In this way the number of filtering operations can be greatly reduced. But I am wondering how to implement that in practice.

The built-in filter functions provided by Matlab and a lot of realtime DSP libraries are optimized to have best computation and storage performance, but they don't provide the capability of calculating the filter output only at output sampling rate. Is it possible to write a code, in a for-loop style, that only calculates the decimated data, and outperforms the performance of built-in functions? If not, what modifications can be done to the built-in functions to reduce the computation of decimation filter, especially in realtime implementations?

Thank you

$\endgroup$

1 Answer 1

1
$\begingroup$

Is it possible to write a code, in a for-loop style, that only calculates the decimated data, and outperforms the performance of built-in functions?

Yes.

(the way you asked this, here would be where the answer is over, but it's not what you meant, sooooo let's continue)

"for loop style" isn't very specific, and any algorithm that implements some form of convolution will iterate over elements, but sure:

For decimation by a factor of $M$: Decompose your filter in $M$ subfilters. Round-robin the input samples into the individual subfilters. Every $M$ input samples, calculate the output as sum of the outputs of the subfilters.

There's many publications on polyphase filters. harris' multirate signal processing is the go-to reference; but there's really many other references, too, see for example this slide deck from the Binghamton University (I'm not even sure the graphics are from that slide deck's author, my apologies if I'm wrong, but I feel I've seen the graphics before).

I recently added a different answer on the same topic, with a bit more background on the polyphase "Magic" that allows the lower rate.

The built-in filter functions provided by Matlab and a lot of realtime DSP libraries are optimized to have best computation and storage performance, but they don't provide the capability of calculating the filter output only at output sampling rate.

That's not true; any real-time DSP framework I can think of has decimating / resampling filters that do exactly that. (example: GNU Radio's decimating FIR filter function; Liquid DSP's firdecim, csdr fir_decimate, the list goes on: this is really a core functionality of every real-time signal processing toolkit.)

I don't know how efficient matlab's implementation is, but upfirdn with an interpolation ratio of 1 and a decimation > 1 should do exactly that.

$\endgroup$
2
  • $\begingroup$ Thank you for the clarification. BTW., do you know whether Nvidia cuda library has such decimating function? $\endgroup$
    – ecook
    Commented Jul 24, 2020 at 1:35
  • $\begingroup$ CUDA itself: don't know. Libraries like cusignal: certainly; worst case, you'd need to modify cusignal's resample.decimate function to use your filter instead of one that it designs itself. $\endgroup$ Commented Jul 24, 2020 at 6:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.