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" <fateman at cs.berkeley.edu> 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
> Maxima at math.utexas.edu
> http://www.math.utexas.edu/mailman/listinfo/maxima
>
>
>
--
Camm Maguire camm at enhanced.com
==========================================================================
"The earth is but one country, and mankind its citizens." -- Baha'u'llah