quil-lang/magicl

Initial elements concern in Tensor/Vector/Matrix storage constructors

Opened this issue · 0 comments

In storage constructors of tensor, vector, and matrix, make-array has been used to initialise the actual storage.

Before PR #143, make-array doesn't specify zero as the :initial-element argument. It causes inconsistencies among different Lisp implementations, as unspecified :initial-element argument is undefined behaviour in the standard.

One example is from-diag. It forgot to specify :initial-elements in both of the occurrences of make-tensor. While this works in SBCL (where make-array initialises all zeros), it won't work in other implementations e.g. allegro.

Therefore, PR #143 tried to fix this issue by explicitly specifying zeros as :initial-element argument in all storage constructors.

As Erik suggested:

perhaps it is something we will try to fix in a more systematic fashion.