Greetings! Just FYI ---
gcl GCL (GNU Common Lisp) 2.6.8 CLtL1 Jul 4 2007 16:45:08 Source License: LGPL(gcl,gmp), GPL(unexec,bfd,xgcl) Binary License: GPL due to GPL'ed components: (XGCL READLINE BFD UNEXEC) Modifications of this banner must retain notice of a compatible license Dedicated to the memory of W. Schelter Use (help) to get some basic information on how to use GCL. Temporary directory for compiler files set to /tmp/ >(defun h (n) (let ((acc 0)) (dotimes (i n acc) (setq acc (+ acc (/ 1 (+ 1 i))))))) H >(compile 'h) Compiling /tmp/gazonk_16089_0.lsp. End of Pass 1. End of Pass 2. OPTIMIZE levels: Safety=0 (No runtime error checking), Space=0, Speed=3 Finished compiling /tmp/gazonk_16089_0.lsp. Loading /tmp/gazonk_16089_0.o start address -T 0x8644000 Finished loading /tmp/gazonk_16089_0.o #<compiled-function H> NIL NIL >(time (progn (h 5000) nil)) real time : 12.820 secs run-gbc time : 6.510 secs child run time : 0.000 secs gbc time : 0.390 secs NIL > GCL_ANSI=t gclcvs GCL (GNU Common Lisp) 2.7.0 ANSI Jul 18 2007 10:48:57 Source License: LGPL(gcl,gmp,pargcl), GPL(unexec,bfd,xgcl) Binary License: GPL due to GPL'ed components: (XGCL READLINE BFD UNEXEC) Modifications of this banner must retain notice of a compatible license Dedicated to the memory of W. Schelter Use (help) to get some basic information on how to use GCL. Temporary directory for compiler files set to /tmp/ >(defun h (n) (let ((acc 0)) (dotimes (i n acc) (setq acc (+ acc (/ 1 (+ 1 i))))))) H >(compile 'h) ;; Compiling /tmp/gazonk_16375_0.lsp. ;; End of Pass 1. ;; End of Pass 2. ;; OPTIMIZE levels: Safety=0 (No runtime error checking), Space=0, Speed=3, (Debug quality ignored) ;; Finished compiling /tmp/gazonk_16375_0.o. ;; Loading /tmp/gazonk_16375_0.o ;; start address -T 0xaa5d88 ;; Finished loading /tmp/gazonk_16375_0.o #<compiled-function H> NIL NIL >(time (progn (h 5000) nil)) real time : 0.080 secs run-gbc time : 0.010 secs child run time : 0.000 secs gbc time : 0.070 secs NIL Take care, Barton Willis <[EMAIL PROTECTED]> writes: > Which function will compute 1 + 1/2 + ... + 1/5000 the fastest? > > ;; Use Maxima rational numbers with add & div. > > (defun $harmonic (n) > (let ((acc 0)) > (dotimes (i n acc) > (setq acc (add acc (div 1 (+ 1 i))))))) > > ;; Use CL rationals with + and /. > > (defun $harmonic2 (n) > (let ((acc 0)) > (dotimes (i n (cl-rat-to-maxima acc)) > (setq acc (+ acc (/ 1 (+ 1 i))))))) > > Using GCL, I get > > (%i1) load("harmonic.o")$ > > (%i2) harmonic(5000)$ > Evaluation took 0.19 seconds (0.19 elapsed) > > (%i3) harmonic2(5000)$ > Evaluation took 19.89 seconds (19.89 elapsed) > > Is this due to fast code in addk? Or is GCL just slow > with rational addition and division? Or something else? > What's the story? > > Barton > _______________________________________________ > Maxima mailing list > [EMAIL PROTECTED] > http://www.math.utexas.edu/mailman/listinfo/maxima > > > -- Camm Maguire [EMAIL PROTECTED] ========================================================================== "The earth is but one country, and mankind its citizens." -- Baha'u'llah _______________________________________________ Gcl-devel mailing list Gcl-devel@gnu.org http://lists.gnu.org/mailman/listinfo/gcl-devel