gcl-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Gcl-devel] Re: [Maxima] faster factorial


From: Camm Maguire
Subject: [Gcl-devel] Re: [Maxima] faster factorial
Date: 12 Apr 2006 14:44:58 -0400
User-agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.2

Greetings!

Well, I thought I could do better by bringing forward mpz_fac_ui, but:

(time (progn (setq a (si::factorial 100000) c 2) (= a c))) ;just call
                                                           ;to mpz_fac_ui in gmp

real time       :      0.560 secs
run-gbc time    :      0.570 secs
child run time  :      0.000 secs
gbc time        :      0.000 secs
NIL

>(time (progn (setq a (k 100000 1) c 2) (= a c)))

real time       :      0.450 secs
run-gbc time    :      0.450 secs
child run time  :      0.000 secs
gbc time        :      0.000 secs
NIL

>

So I guess there is no interest in including such a factorial function
in GCL.

Take care,


"Richard Fateman" <address@hidden> writes:

> For GCL, this program is faster than the much longer one used in Maxima
> (defined in ASUM.lisp.).
> 
> Almost  3X faster computing 20000!  .
> 
> 
> (defun k (n m) ;; (k n 1) is n!
>   (declare (fixnum n m))
>   (if (<= n m) n
>     (* (k n (* 2 m))
>        (k (- n m)(* 2 m)))))
> 
> There are even faster ways, but I'm not sure how to actually use the
> GMP arithmetic to best advantage in GCL.
> 
> see http://www.cs.berkeley.edu/~fateman/papers/factorial.pdf
> for more thoughts.
> 
> RJF
> 
> _______________________________________________
> Maxima mailing list
> address@hidden
> http://www.math.utexas.edu/mailman/listinfo/maxima
> 
> 
> 

-- 
Camm Maguire                                            address@hidden
==========================================================================
"The earth is but one country, and mankind its citizens."  --  Baha'u'llah




reply via email to

[Prev in Thread] Current Thread [Next in Thread]