Re: [q-lang-users] Exponentiation operator
Brought to you by:
agraef
From: Albert G. <Dr....@t-...> - 2006-06-16 20:33:47
|
Rob Hubbard wrote: > (2) A value of a type as simple as possible (up to the simplicity of the > arguments perhaps): thus Int if possible, otherwise Rational if > possible, otherwise Real if possible, otherwise (perhaps) Complex (e.g. > (-1)^(1/2) would be complex). I suppose you mean "Float" rather than "Real" here. ("Real" is similar to "Num" in that it's an abstract type with no objects of its own. It's just a common umbrella for Int, Float and (soon) Rational.) > That is, I think either > (1) no attempt at all should be made to return an exact value in a > suitable type; a Float should be returned where possible (i.e. where > defined and Real), or > (2) a thorough attempt should be made. I foresee that (2), while desirable, would mean a lot of complication. In particular, we need to be able to check whether a given root of a bigint is again a bigint, _without_ converting to an inexact representation somewhere in that decision procedure. Thus I'm leaning towards solution (1). Q is not supposed to be a computer algebra system after all, and the pow function is there if an exact solution is needed, in cases where its existence is obvious. The rest should be the burden of the application programmer. :) So that means that exponentiation yields a Float result if it exists, and a Complex result otherwise. In fact this is the way it is implemented right now, but this would then also apply to the Rational type. > That doesn't really answer the question does it?? It does, since it helped to remind me that innocent-looking changes sometimes have dramatic consequences. ;-) 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 |