|
Boost : |
Subject: Re: [boost] accumulators + complex
From: Eric Niebler (eric_at_[hidden])
Date: 2008-12-19 12:22:48
Neal Becker wrote:
> Neal Becker wrote:
>
>> I'm interested in 2nd order stats for complex numbers.
>>
>> typedef std::complex<double> complex_t;
>> typedef accumulator_set<complex_t, stats<tag::mean, tag::moment<2> > >
>> acc_t;
>>
>> 2 issues:
>>
>> 1) Need
>> template<typename flt_t>
>> inline std::complex<flt_t> operator/ (std::complex<flt_t> const& a,
>> unsigned long int b) {
>> return std::complex<flt_t> (real (a)/b, imag (a)/b);
>> }
This should work if you #include
<boost/accumulators/numeric/functional/complex.hpp>, or better, compile
with BOOST_NUMERIC_FUNCTIONAL_STD_COMPLEX_SUPPORT defined.
>> 2) What do I get for moment<2> in the case of complex (and does this match
>> the usual mathematical definition?)
>>
>
> I believe what I want to is mean, and
> \sum |x- mean(x)|**2
>
> Can I do this with accumlators framework?
Yes, I believe so.
-- Eric Niebler BoostPro Computing http://www.boostpro.com
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk