Menu ▾ ▴

#5672 amatrix_multiply fails for ordinary and empty products

open
nobody
5
6 days ago
6 days ago
No

Loading amatrix and multiplying ordinary nonempty matrices currently fails:

load(amatrix)$
A: old2new_matrix(matrix([1,2],[3,4]))$
amatrix_multiply(A,A);
/* structure amatrix: wrong number of arguments; expected 7, not 8. */

There is a second failure for a zero inner dimension:

amatrix_multiply(make_matrix(3,0),make_matrix(0,2));
/* Matrix index out of bounds */

Mathematically, the latter product should be a 3-by-2 zero matrix: each entry is an empty sum.

The attached patch fixes the result's constructor arity and initializes its storage reference count. It also computes the operand-view offsets without asking compute_index0 to validate nonexistent elements. The existing dot-product loop then returns zero naturally when its length is zero. No special branch for empty products is added.

The patch is against c24012415b91192b9c7f9303ca28f4391a890f01. Tests cover ordinary products, transposes and slices, copy-on-write after multiplication, incompatible dimensions, and all 64 combinations of row/inner/column dimensions from 0 through 3.

Validation:

  • Existing rtest_amatrix: 48/48 passed before the change.
  • Seven added regression cases failed before the change; 56/56 matrix cases pass after it.
  • Current package files on Maxima 5.50.0 / ECL 26.5.5: 56/56 matrix cases and 11/11 Wilcoxon cases pass.
  • The same 56 matrix cases pass with the modified Lisp definitions in Maxima 5.44.0.
  • A broader installed-5.50 core/share run completed 117/161 test files before its 600-second limit during LAPACK compilation. Its nine failures were reproduced on unmodified Maxima. This is not a clean full-suite pass.

AI assistance disclosure: the investigation, proposed patch, and tests were prepared with OpenAI Codex (GPT-6). Submitted as a proposed fix for maintainer review.

1 Attachments

Discussion


Log in to post a comment.