Boost logo

Boost :

From: Eric Niebler (eric_at_[hidden])
Date: 2007-08-01 13:36:42


Hugo Duncan wrote:
> Given recent discussion on Time Series and Accumulators, I thought I would
> have a go at implementing a FIR filter for Accumulators, and have run into
> a problem.
>
> I decided to do this in two parts; first create a (reusable) delay
> statistic (similar to tail) that provides a history buffer for the signal
> and then create the filter (similar to tail_variate) , that will depend on
> the delay buffer.
>
> I have created the delay buffer with a length determined by a cache_size
> argument. This works well.
>
> I am now creating the filter, which has a "coefficents" argument to set
> the filter coefficients. I would like to pass the size of the coefficients
> list as the cache_size argument to the underlying delay buffer.
>
> Is this possible?

Certainly. You can use Boost.Parameter to define a new keyword:

   BOOST_PARAMETER_NAME(coefficients)

The accumulator_set has constructors that take named parameters and
builds and argument pack.

   accumulator_set<... > acc( ..., coefficients = 5, ...);

The resulting argument pack is passed as the constructor parameter to
all the accumulators in the set. Your accumulator can then extract the
coefficients argument from the pack with "args[coefficients]".

HTH,

-- 
Eric Niebler
Boost Consulting
www.boost-consulting.com
The Astoria Seminar ==> http://www.astoriaseminar.com

Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk