Boost logo

Boost Users :

From: ravioli_at_[hidden]
Date: 2002-06-14 16:44:08


  ----- Original Message -----
  From: Daryle Walker
>> Is there an interest into having a power() template calculating the N-th power
>> of any number, when N is known at compile-time ?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
>> run-time and compile-time 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 common-factor library?
  It's about math and compile-time 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 non-negative integer."
  Anyway, the change should not be difficult.

[Non-text portions of this message have been removed]


Boost-users 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