Again $table function, speed/functionality improved



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 ...

See attachment for sourcefile 'table.lisp'.

Table can now handle all the cases $makelist does, except the ones  
where the variable is not a sybol:
table( a[i], [ a[i], 5]); doesn't work
I've decided not to support this case, since it complicates the  
program severely while adding really marginal improvement featurewise  
(you can always subst() a[i] to a 'symbol').
table(i, [i, a[i], a[i] + 5 , 0.2]); now works correctly. (The  
requirement is that (end - start) evaluates to a $numberp expression).

I've changed the behaviour, so there are empty lists returned instead  
of errors for many cases. Example:
table( random(1.0), [-4]);
table( i, [i, 1, 10, -1]);
...

I've revised the evaluating part of iterators - instead of using  
'mbinding' for each evaluation of expression, it is now used only  
once per iterator, to provide the safety. After that, values are set  
via (setf (symbol-value var) value). The $table overhead has severely  
decreased (!) and $table is now faster than $create_list (!!).  
Besides, $table offers even faster iteration, when you don't need a  
bound variable, for instance:

%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.

When the expression is 'cheaper' than 'random(1.0)', the difference  
is bigger ofcourse.

%i109: table(0, [10^6])$
Evaluation took 0.0430 seconds (0.0430 elapsed) using 7.629 MB.
%i102: table(0, [i, 10^6])$
Evaluation took 0.8490 seconds (0.8490 elapsed) using 7.633 MB.
%i105: create_list(0, i, 1, 10^6)$
Evaluation took 1.1200 seconds (1.1270 elapsed) using 22.888 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.

Any comments on $table implementation? Any comments on the function  
name? Anything needs changing before this gets into Maxima?

A similar function could be written for arrays - if Maxima ever gets  
a better array support (like amatrix package).

-------------- next part --------------
A non-text attachment was scrubbed...
Name: table.lisp
Type: application/octet-stream
Size: 13061 bytes
Desc: not available
Url : http://www.math.utexas.edu/pipermail/maxima/attachments/20090513/d36fb6f4/attachment-0001.obj 
-------------- next part --------------



Regards,
Ziga Lenarcic