On Wed, Feb 12, 2014 at 4:55 AM,  <[email protected]> wrote:
> Ah, I see what you mean.  If that's the case then I understand.  How does
> one find out if this is true?

1. It is *NOT* true.    Sage just directly calls the PARI C library,
which is always loaded on startup of Sage.

2. Thanks for clarifying your original question. It's surprising that
MPFR is a full *order of magnitude* slower than PARI at computing
gamma on real input.    It's pretty likely that when the line of code
in question was written (prob in 2005 or 2006) this speed difference
wasn't the case.  I've cc'd Paul Zimmerman (author of MPFR) in case he
has any comments about this:

a = RealField(1000)(pi^2)
b = ComplexField(1000)(pi^2)

%timeit a.gamma() # SLOW -- uses mpfr --  "mpfr_gamma(x.value,
self.value, (<RealField_class>self._parent).rnd)"
%timeit b.gamma() # FAST -- uses pari --
"sage.libs.pari.all.pari.complex(self.real()._pari_(),
self.imag()._pari_())"

Maybe we should switch to PARI for this.    At the least, you could add

   a.gamma(algorithm='pari')

and at some point make that the default...

 -- William

>
> On Wednesday, February 12, 2014 7:46:21 AM UTC-5, Jori Mantysalo wrote:
>>
>> On Wed, 12 Feb 2014, [email protected] wrote:
>>
>> > I don't understand what you mean.  The real and complex fields are
>> > loaded
>> > upon start up. It seems as though time testing that if the user wishes
>> > to
>> > compute gamma(x) for real x, he would achieve a faster result by
>> > changing x
>> > into a complex number and then computing gamma(x).
>>
>> Fields are, but how about pari? I think that
>>
>> gamma(3.14159)
>>
>> actually means something like
>>
>> load_to_memory(mpfr)
>> mpfr.gamma(3.14159)
>>
>> and
>>
>> gamma(3.14159+2.71828*I)
>>
>> means
>>
>> load_to_memory(pari)
>> pari.gamma(3.14159+2.71828*I)
>>
>> And if we have old server and 20 students using Sage, it may mean
>> something more than just waiting for few hunder milliseconds.
>>
>> --
>> Jori Mäntysalo
>
> --
> You received this message because you are subscribed to the Google Groups
> "sage-devel" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To post to this group, send email to [email protected].
> Visit this group at http://groups.google.com/group/sage-devel.
> For more options, visit https://groups.google.com/groups/opt_out.



-- 
William Stein
Professor of Mathematics
University of Washington
http://wstein.org

-- 
You received this message because you are subscribed to the Google Groups 
"sage-devel" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sage-devel.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to