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:
rtest_amatrix: 48/48 passed before the change.AI assistance disclosure: the investigation, proposed patch, and tests were prepared with OpenAI Codex (GPT-6). Submitted as a proposed fix for maintainer review.