[Numpy-discussion] matmul as a ufunc

Andras Deak deak.andris at gmail.com
Tue May 29 05:22:09 EDT 2018


On Tue, May 29, 2018 at 5:40 AM, Stephan Hoyer <shoyer at gmail.com> wrote:
> But given that idiomatic NumPy code uses 1D arrays in favor of explicit
> row/column vectors with shapes (1,n) and (n,1), I do think it does make
> sense for matrix transpose on 1D arrays to be the identity, because matrix
> transpose should convert back and forth between row and column vectors
> representations.
>
> Certainly, matrix transpose should error on 0d arrays, because it doesn't
> make sense to transpose a scalar.

Apologies for the probably academic nitpick, but if idiomatic code
uses 1d arrays as vectors then shouldn't scalars be compatible with
matrices with dimension (in the mathematical sense) of 1? Since the
matrix product of shapes (1,n) and (n,1) is (1,1) but the same for
shapes (n,) and (n,) is (), it might make sense after all for the
matrix transpose to be identity for scalars.
I'm aware that this is tangential to the primary discussion, but I'm
also wondering if I'm being confused about the subject (wouldn't be
the first time that I got confused about numpy scalars).

András


More information about the NumPy-Discussion mailing list