[PATCH] lisp ratio and bigfloat



On 9/27/2013 7:07 AM, Stavros Macrakis wrote:
> I'm not sure I understand what problem this is supposed to solve.
I don't know particularly about John's problem, but if a lisp rational 
number makes sense
(as it does here), why not?  One motivation is that it makes it easier 
to use, unchanged,
  separately written lisp code that returns lisp numbers.
>
> Are you planning to go through the whole Maxima codebase to make it 
> rational-safe?
I think this can be done piecemeal, without harm.  I've offered a number 
of pieces
that work and (I believe) don't break anything.  Presumably they 
slightly slow some programs.

  A better solution might be to use common lisp
rational numbers e.g. 1/2  instead of  ((rat) 1 2) throughout Maxima, 
but that is hard.
Maclisp did not have rational numbers, and the Maxima ((rat) ...) has no 
representational
advantage.  That is, Maxima has declined to extend rationals to (say)  
((rat) 1 0)
for a rational infinity,  or ((rat) 0 0) for a rational "undefined".  
(If it did, then I might
argue that ((rat) ...) was important to preserve.

There is an argument to be made that Maxima's "type" system is to always 
look at the
(caar *) , but almost everywhere we have to check for atoms. Perhaps we 
should have
used   ((integer)  123)   and  ((symbol)  x) ?  But I'm rambling.

There is another kind of native common lisp number that can be converted 
to bigfloats,
and that is common lisp COMPLEX numbers.  That is, #c(1 2)  could be 
recognized and
treated at 1+2*%i.
Even better would be the adoption of the complex bigfloat package.



RJF

>
>        -s
>
>
> On Fri, Sep 27, 2013 at 8:00 AM, John Lapeyre 
> <lapeyre.math122a at gmail.com <mailto:lapeyre.math122a at gmail.com>> wrote:
>
>     Hi,
>
>     It seems like there is a bit of support in maxima for
>     lisp ratios, although not much. Here is a patch that
>     allows ratios to work with bfloats in many instances.
>     I tried to arrange it to have a low impact on efficiency.
>     The patch passed the test suite.
>
>     btw. In the original code, it looks like special constants are checked
>     before integers (I'm not certain). I did not change this, but maybe
>     it should be the other way around.
>
>     --John
>
>
>     _______________________________________________
>     Maxima mailing list
>     Maxima at math.utexas.edu <mailto:Maxima at math.utexas.edu>
>     http://www.math.utexas.edu/mailman/listinfo/maxima
>
>
>
>
> _______________________________________________
> Maxima mailing list
> Maxima at math.utexas.edu
> http://www.math.utexas.edu/mailman/listinfo/maxima