Re: [pure-lang-users] math.pure
Status: Beta
Brought to you by:
agraef
From: Albert G. <Dr....@t-...> - 2008-08-21 20:35:50
|
Eddie Rucker wrote: > What about > > pow (1+2i) 3; I really shouldn't have opened that can of worms by wrapping the C pow() function with Pure's pow. ;-) I must rethink the purpose of the pow function. It would be silly to replicate all functionality we already have with the ^ operator. In Q pow is just a wrapper for the GMP mpz_pow_ui function, which is then extended in rational.q to exact powers of rationals and integers with integer exponent. Maybe we should stick to that. Of course, one can extend that to exact integer powers of complex rationals in *polar* notation quite easily, but in rectangular notation AFAICS the best you can do is addition-chain exponentiation which only works with nonnegative integer exponents and even that needs Theta(log n) additions. That's why I think pow should actually be restricted to the exact rational and integer cases, with ^ covering all inexact powers, and leave it up to the programmer to extend the former in any manner he needs it. At least that was the conclusion we reached when discussing this issue in the context of Q. Comments? Albert -- Dr. Albert Gr"af Dept. of Music-Informatics, University of Mainz, Germany Email: Dr....@t-..., ag...@mu... WWW: http://www.musikinformatik.uni-mainz.de/ag |