Menu

#2649 Correction for $matrix evaluation

None
closed
nobody
Lisp Core (457)
5
2013-11-20
2013-10-29
No

apply('matrix,'[[print(3)]]) prints 3 -- that is, it evaluates its argument twice. This is a bug that causes problems in, e.g., mat_function. See http://comments.gmane.org/gmane.comp.mathematics.maxima.general/43716

The fix is to redefine $matrix as a regular function (not a defmspec):

(remprop '$matrix 'mfexpr*)
(defun $matrix (&rest rows)
  (dolist (row rows)
    (if (not ($listp row)) (merror (intl:gettext "matrix: row must be a list; found: ~M") row)))
  (matcheck rows)
  (cons '($matrix) rows))

I have NOT run the test suite after adding this fix.

Discussion

  • Jaime E. Villate

    • Description has changed:

    Diff:

    --- old
    +++ new
    @@ -2,11 +2,11 @@
    
     The fix is to redefine $matrix as a regular function (not a defmspec):
    
    -(remprop '$matrix 'mfexpr*)
    -(defun $matrix (&rest rows)
    -  (dolist (row rows)
    -    (if (not ($listp row)) (merror (intl:gettext "matrix: row must be a list; found: ~M") row)))
    -  (matcheck rows)
    -  (cons '($matrix) rows))
    +    (remprop '$matrix 'mfexpr*)
    +    (defun $matrix (&rest rows)
    +      (dolist (row rows)
    +        (if (not ($listp row)) (merror (intl:gettext "matrix: row must be a list; found: ~M") row)))
    +      (matcheck rows)
    +      (cons '($matrix) rows))
    
     I have NOT run the test suite after adding this fix.
    
     
  • Robert Dodier

    Robert Dodier - 2013-11-20

    Fixed by commit 31c58ed22 (rework $MATRIX in a slightly different way than shown here).

     
  • Robert Dodier

    Robert Dodier - 2013-11-20
    • labels: --> Lisp Core
    • status: open --> closed
     

Log in to post a comment.