
Boost Users : 
From: ravioli_at_[hidden]
Date: 20020614 16:44:08
 Original Message 
From: Daryle Walker
>> Is there an interest into having a power() template calculating the Nth power
>> of any number, when N is known at compiletime ?t uses the algorithm of the
>> STL power function(), and runs between two or three times faster, and maybe
>> could be of interest in the " <boost/math/common_factor.hpp> which provides
>> runtime and compiletime evaluation of the greatest common divisor (GCD) or
>> least common multiple (LCM)
>Proposals for new libraries usually go to the regular Boost list, not this
>one. Besides that:
Sorry for that.
>What would this have to do with the commonfactor library?
It's about math and compiletime calculation.
>I've never heard of a function called "power".
>Are there any docs for it?
http://www.sgi.com/tech/stl/power.html
> Is it a STL function that didn't get into the standard?
You're right : "This function is an SGI extension; it is not part of the C++ standard."
>How do you know what algorithm it uses?
You can take a look at the code in the preceding link. Although the algorithm is not defined by the implementation,
this is one of the fastest (Called in french "algorithme dy paysan russe").
>> It simply works this way, for example to have PI at exponent three :
>> double a = power_const<3>( 3.14159)
[TRUNCATE code]
>I don't think your implementation will work for negative exponents.
You're right. It follows the guidelines of SGI STL where it's written :
"Power is generalized exponentiation: it raises the value x to the power n, where n is a nonnegative integer."
Anyway, the change should not be difficult.
[Nontext portions of this message have been removed]
Boostusers list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net