Again $table function, speed/functionality improved



> 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

Hi!

I get these resoults on my machine:
(%i1) showtime:true;
Evaluation took 0.0010 seconds (0.0000 elapsed) using 0 bytes.
(%o1) true
(%i2) load(table)$
Evaluation took 0.0800 seconds (0.0810 elapsed) using 4.075 MB.
(%i3) table(0, [10^5])$
Evaluation took 0.0050 seconds (0.0060 elapsed) using 780.000 KB.
(%i4) table(random(1.0), [10^5])$
Evaluation took 0.3370 seconds (0.3490 elapsed) using 28.323 MB.
(%i5) create_list(0,i,1,10^5)$
Evaluation took 0.1110 seconds (0.1110 elapsed) using 2.289 MB.
(%i6) create_list(random(1.0),i,1,10^5)$
Evaluation took 0.6000 seconds (0.6070 elapsed) using 29.858 MB.
(%i7) build_info();
Maxima version: 5.19.1
Maxima build date: 12:23 8/17/2009
host type: i686-apple-darwin8.11.1
lisp-implementation-type: SBCL
lisp-implementation-version: 1.0.30
Evaluation took 0.0010 seconds (0.0250 elapsed) using 3.922 KB.

SBCL and CMUCL should be near identical in speed so I don't know  
where the difference lies. Perhaps somehow CMUCL is running the  
interpreted version of $table..

I did post it to the phpBB.
https://sourceforge.net/apps/phpbb/maxima/viewtopic.php?f=3&t=5

It's true - it's not a drop in replacement. I don't feel it's much of  
an advantage to be able to use non-symbol indices - I find that step  
iteration (with possibility of negative step) and speed are more  
useful, but that ofcourse depends on what you use Maxima for.

The biggest argument for not including it as a separate function was  
that there are already two functions for making lists. I don't think  
that's a good argument. I wouldn't *replace* these two with 'table'  
but rather give the user the extended functionality 'table' offers.  
There are two ways to do it - either by having a separate 'table'  
function OR by hiding the 'table' functionality behind 'makelist'. In  
$makelist one would simply check the arguments - if they are lists,  
use the $table algorithm, if they are not, use the '$makelist'  
algorithm... This wouldn't brake any existing code nor create another  
function, though the documentation would look somewhat confusing.

Another idea - I could modify $table to detect 'non-symbol' indices  
and in these cases use the same algorithm that 'makelist' uses (which  
is slower) internally. Then 'makelist's' functionality would be a  
subset of 'table's'.

Regards,
Ziga