Again $table function, speed/functionality improved




On Wed, 13 May 2009, iga Lenari wrote:

< Hello again!
< 
< I've made many corrections to my $table function and now I feel it's ready to
< be included into Maxima. I haven't written the documentation yet (beside the
< comment in lisp file), but will do so ...
 
< %i92: table(random(1.0), [10^6])$
< Evaluation took 4.2030 seconds (4.4250 elapsed) using 283.225 MB.
< %i95: table(random(1.0), [i, 10^6])$
< Evaluation took 5.5540 seconds (5.7890 elapsed) using 283.248 MB.
< %i94: create_list(random(1.0), i, 1, 10^6)$
< Evaluation took 6.0090 seconds (6.0200 elapsed) using 298.482 MB.
 
< So there you go.. $table as a $makelist and $create_list replacement is ready.
< It's faster, more featureful, and more correct than $create_list. Besides of
< the difference of outputs of
< create_list([i,j], i, 1, 4, j, 1, 4);
< table([i,j], [i,4], [j,4] );
< all bases are covered. I would tackle this with extending $flatten's
< functionality - to allow list flattening to a certain level.
 
Ziga,
I have just tried to recreate your test results above. I am unable to do
so. Incidentally, makelist has a substantial advantage over table (and
create_list) in that the indices need not be symbols, so table is not
exactly a drop-in.

In all events, could you put your code on the maxima contributed code
page (https://sourceforge.net/apps/phpbb/maxima/viewforum.php?f=3),
please.

(%i2) compile_file("/home/work/lisp/table.lisp");
Evaluation took 0.1000 seconds (0.1000 elapsed) using 1.954 MB.
(%o2) ["/home/work/lisp/table.lisp",?\/home\/work\/lisp\/table\.x86f]
(%i3) table(0, [10^5])$
Evaluation took 1.6700 seconds (1.6700 elapsed) using 8.496 MB.
(%i4) table(random(1.0), [10^5])$
Evaluation took 3.9100 seconds (3.9100 elapsed) using 40.616 MB.
(%i5) create_list(0,i,1,10^5)$
Evaluation took 0.1500 seconds (0.1500 elapsed) using 2.289 MB.
(%i6) create_list(random(1.0),i,1,10^5)$
Evaluation took 1.8800 seconds (1.8800 elapsed) using 34.533 MB.
(%i7) build_info();

Maxima version: 5.19.0
Maxima build date: 20:10 8/10/2009
host type: i686-pc-linux-gnu
lisp-implementation-type: CMU Common Lisp
lisp-implementation-version: CVS 19d 19d-release (19D)

Leo

-- 
The University of Edinburgh is a charitable body, registered in
Scotland, with registration number SC005336.