
Boost : 
Subject: Re: [boost] math/tools/rational.hpp gcc 3.2 problem
From: John Maddock (john_at_[hidden])
Date: 20091014 10:18:12
>> gcc 3.2 doesn't compile this code (works with gcc 3.3 and up):
>>
>> #include <boost/math/distributions.hpp>
>> int
>> main()
>> {
>> boost::math::students_t_distribution<double> dist(1.);
>> dist.find_degrees_of_freedom(1.,2.,3.,4.,5.);
>> return 0;
>> }
>>
>>
>>
>> Reduced:
>>
>> template <unsigned N, class T, class V>
>> inline V evaluate_polynomial(const T(&a)[N], const V& val)
>>
>
> I will be wrong linguistically, but I hate the definition of 'a' here.
> What
> is it to be? I assume it is a reference to an array, I guess. But then why
> not just take a reference to the first element and a count, or use a range
> (pointer + size)?
>
> Sorry, I don't know anything about boost/math/distributions. But this kind
> of nonproblem being a problem is in fact, a problem.
>
> If 'a' is just an array, say it like it is. Why make a fuss?
Because it makes a difference, both for maintenance and performance:
* For maintenance, we're much less likely to introduce subtle bugs if the
function "knows" how big the array is, rather than us having to specify the
size at the call site, as well as at the definition of the array.
* For performance: for small arrays of known size we can omit the forloop
and just evaluate the polynomial using nearoptimal code. Since
polynomial/rational function evaluation is often the pinchpoint for
functions implemented using rationalapproximations it makes sense to
optimize this as far as possible even if it only gains us 2030%.
We could of course code the polynomial evaluation separately each time it's
needed  and without a separate function  that's what most other similar
libraries do, but as well as being untidy, it precludes library wide
improvements to this core function, unless of course you change every usage
:(
As for the original problem: I'm afraid I don't have an obvious workaround
that springs to mind, I will try and install an early gcc version to test
with, but last time I tried you can't even *build* gcc3.x on recent Linux
builds :(
John.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk