#46 array: not dynamical sizes/FIX

closed
nobody
Lisp Core (471)
5
2012-12-04
2002-04-19
No

The following code does not work:

---------------------------text.mac-------------------
use_fast_arrays : true;
trial(a):= block([myvar, i],
/*local (i)*/ /* Comment this or not, it's the same */
array(i,a),
for myvar : 1 thru 7 do i[myvar] : [],
i[1])$
---------------------------text.mac end---------------

It might be an (undocumented) issue, in which case the
bug is in the doc, or it might be a real bug (I think
one should be able to dimension arrays using variables,
not only numbers).

====================follows session===================
Session:

bash-2.05$ maxima
GCL (GNU Common Lisp) Version(2.4.0) Sat Jul 14
20:26:43 GMT 2001
Licensed under GNU Library General Public License
Contains Enhancements by W. Schelter
Maxima 5.6 Sat Jul 14 20:26:37 GMT 2001 (with
enhancements by W. Schelter).
Licensed under the GNU Public License (see file COPYING)
(C1) load("text.mac");

(D1) text.mac
(C2) trial(30);

Error: |$a| is not of type NUMBER.
Fast links are on: do (si::use-fast-links nil) for
debugging
Error signalled by MACSYMA-TOP-LEVEL.
Broken at MACSYMA-TOP-LEVEL. Type :H for Help.
MAXIMA>>:q

(C3)

===============end of session===================

Discussion

    • summary: array: not dynamical sizes --> array: not dynamical sizes/FIX
     
  • Logged In: YES
    user_id=588346

    The blocks, loops, etc. are irrelevant; any non-constant
    argument causes this problem:

    use_fast_arrays: true$
    array(wer,3+3) =>
    Error: ((MPLUS) 3 3) is not of type NUMBER.

    Fix in $ARRAY:
    ($use_fast_arrays
    (mset (car x)
    (apply '$make_array '$any
    (mapcar #'(lambda (dim)
    ;;let make_array catch bad vals
    (add 1 (meval dim)))
    (cdr x)))))

     
  • Robert Dodier
    Robert Dodier
    2006-06-26

    • labels: --> Lisp Core
    • assigned_to: nobody --> robert_dodier
     
  • Robert Dodier
    Robert Dodier
    2006-09-09

    • milestone: --> Includes_proposed_fix
     
  • Dieter Kaiser
    Dieter Kaiser
    2009-01-03

    I have tested the proposed fix. With this fix fast arrays and normal arrays work identically. The code for normal arrays already contains the following line

    (setq diml (mapcar #'meval diml))

    which does an evaluation of the dimension list.

    An example is:

    (%i) i:3$

    (%i4) array(a,2*i+1); /* normal array */
    (%o4) a

    (%i8) use_fast_arrays:true$

    (%i9) array(b,2*i+1); /* works now for fast array too */
    (%o9) ?\#\(NIL\ NIL\ NIL\ NIL\ NIL\ NIL\ NIL\ NIL\)

    (%i10) array(wer,3+3); /* the original example */
    (%o10) ?\#\(NIL\ NIL\ NIL\ NIL\ NIL\ NIL\ NIL\)

    The testsuite has no problems.

    I think we should do the proposed fix and close the bug report.

    Dieter Kaiser

     
  • Robert Dodier
    Robert Dodier
    2009-01-03

    > I think we should do the proposed fix and close the bug report.

    OK by me. Thanks for following up.

     
  • Robert Dodier
    Robert Dodier
    2009-01-03

    • assigned_to: robert_dodier --> nobody
     
  • Dieter Kaiser
    Dieter Kaiser
    2009-01-03

    The suggested fix is applied in revision 1.72.

    Closing the bug report.

     
  • Dieter Kaiser
    Dieter Kaiser
    2009-01-03

    • status: open --> closed