I am pleased to learn that deficiencies in gmpy are not inherited by
Sage, and that
MPIR,  equivalent functionally to GMP is accessible more directly.

It doesn't seem that it should be a point of pride that there are 5000
lines in Sage that include mpz_ ...
(e.g. mpz_addmul(a,b,c)  computes a=a+b*c), since one of the alleged
advantages of
using a higher level language like Python is be that one doesn't need
to write out these low-level
constructs, and can use infix arithmetic, for example.

In my lisp code I provide a compiler (really, a macro-expander) that
allows the programmer to
use the ordinary arithmetic operations like + and *,  and
declarations, and the system chooses
the proper mpz_ ... code or other code.  Actually, the floating point
stuff is more useful, from MPFR,
so I picked an example that is "more complicated"..

Here's a piece from a lisp program which computes the value of
legendre polynomials,
in which x, t0, t1, are mpfr numbers, and i is a (single-word)
unsigned integer.


 (mpfr::with-temps (/(- (* (- (* 2 i)1) x t1) (* (- i 1) t0)) i)))

a more conventional version of this might be the "infix" version that
I thought
python / Sage programmers would use.

   ((2*i-1)*x*t1) - (i-1)*t0))/i

But if I understand you, the Sage programmer writing directly in
Python has a much worse option,
involving something like  the 7 mpfr_add, mpfr_mul, ... functions
calls,
interspersed with establishing some temporaries for intermediate
results.
 Maybe some of the 5,000 lines are really a failure of python to
provide a convenient
level upon which to write code that does some "other" kind of
arithmetic?

[the Lisp macro with-temps expands to a sequence of calls to entry
points in the mpfr library,
with some storage that is re-used at each invocation of this code
segment.]

RJF




--~--~---------~--~----~------------~-------~--~----~
To post to this group, send an email to sage-devel@googlegroups.com
To unsubscribe from this group, send an email to 
sage-devel-unsubscr...@googlegroups.com
For more options, visit this group at http://groups.google.com/group/sage-devel
URLs: http://www.sagemath.org
-~----------~----~----~----~------~----~------~--~---

Reply via email to