=head1 NAME PDL::DSP::Iir -- Infinite impulse response and recursive filters =head1 DESCRIPTION This module provides recursive filters. Currently, only moving average filters are implemented. The moving average is actually a FIR, but it is implemented recursively as are IIR filters, so it is included here. =head1 SYNOPSIS use PDL::LiteF; use PDL::DSP::Iir( 'moving_average' ); # apply three passes of a moving average with window size 2*5+1 = 11. $filtered_data = moving_average($data,5,3); # apply one pass of a moving average with window size 2*3+1 = 7. $filtered_data = moving_average($data,3); # call as method with window size 2 * $hw + 1 $y = $x->moving_average($hw); =cut =head1 FUNCTIONS =cut =head2 The function C calls one of the lower level functions C or C, but they can be used directly as well. =head2 moving_average =for ref moving_average($data, $half_width [, $n_passes ]); Other terms for this kind of filter are: smoothing, sliding average, box smoothing, boxcar smoothing, boxcar filter, etc. This function applies a moving average of C< $data > with window of size C. That is, the output value of point C is the (uniformly weighted) average of the input points from C through C. The filter is repeated C<$n_passes> times if C<$n_passes> is supplied. This effectively applies a filter with a response that decreases with the distance from the point C. The recursive algorithm is used, which can be much faster than the equivalent direct convolution with a rectangular window. The boundary at C is treated by using a window of size 1 at C, then of size 3 at C, and so on until the size reaches C. The boundary at C is treated in the same way. In this way, the response around each point is symmetric. The accumulator for all fixed point types is of type C, and for both floating point types is C. =cut =head2 mov_avg =for sig Signature: (x(n); double [o]y(n); int half_width) =for ref Moving average with a single pass. =for bad mov_avg ignores the bad-value flag of the input piddles. It will set the bad-value flag of all output piddles if the flag is set for any of the input piddles. =cut =head2 multi_pass_mov_avg =for sig Signature: (x(n); double [o]y(n); double [t]ytemp(n); int half_width; int n_passes) =for ref This is the same as C, except that smoothing is repeated n_passes times. Note that storage C is created. =for bad multi_pass_mov_avg ignores the bad-value flag of the input piddles. It will set the bad-value flag of all output piddles if the flag is set for any of the input piddles. =cut