Boost logo

Boost :

From: Daryle Walker (darylew_at_[hidden])
Date: 2001-12-10 00:20:43


on 12/8/01 4:21 PM, Beman Dawes at bdawes_at_[hidden] wrote:

> At 05:06 AM 12/3/2001, Moore, Paul wrote:
>
>> From: Daryle Walker <darylew_at_[hidden]>
>>> There is now a header dedicated to computing the greatest common divisor or
>>> the least common multiple of two numbers, at compile-time or run-time. I
>>> think there are two libraries currently using private GCD/LCM routines, pool
>>> and rational. Maybe they can transition to the new header, if possible, by
>>> the next release?
>>
>> As discussed previously on the list, I can "drop in" the new GCD calls.
>> However, I do not have time to build and test the resulting code, other than
>> a quick "did the regression test still work" check on MSVC6. I also won't
>> have time to field any reports resulting from this change.
>>
>> If this is acceptable to the group, I can make the (pretty trivial) patch.
>
> There is discussion going on about improving the release procedure. One of the
> aims is to identify regressions earlier, so that there is time to fix them
> before the actual release.
>
> So go ahead and make the change. If it causes problems, we will back it out
> before the release.
>
>> BTW, this also alters the public interface of the rational header, as the gcd
>> and lcm functions were previously documented as exposed by that header. I
>> assume that the loss of those functions from that location is also
>> acceptable?
>
> It seems to me that is OK.
>
>> BTW[2], I see no performance or dependency notes for the new GCD library
>> (such as the rational library has). I'm not sure what implication this has on
>> the rational class documentation, as now I cannot be explicit about
>> performance or dependencies whenever I use gcd() (basically, everywhere). Can
>> performance and dependency notes be added to the gcd library? And can someone
>> check that no new dependencies, or worse performance, is added by the new
>> library. I can then just point the rational documentation at the gcd
>> documentation.
>
> Daryle?

The new GCD function basically uses the same algorithm currently in the
rational header. There is about 5 inline function call indirections, which
should be optimized out. For dependencies, the rational header #includes a
lot more headers than the GCD/LCM header. The only potential problem is
that the rational header doesn't use std::numeric_limits, and the GCD/LCM
header does use std::numeric_limits and needs its constants at compile time.

Another difference is that the rational version always includes sign
compensation, but the stand-alone version only has sign compensation if the
type signals sign-ness with std::numeric_limits. Unknown types get a
sign-ignorant version, which may lead to sign errors if the unknown type is
really a signed number type.

-- 
Daryle Walker
Mac, Internet, and Video Game Junkie
darylew AT mac DOT com

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