[Numpy-discussion] matmul as a ufunc

Daπid davidmenhur at gmail.com
Tue May 29 06:16:07 EDT 2018


On 29 May 2018 at 05:40, 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.
>

When doing algebra on paper, I like the braket notation. It makes
abundantly clear the shape of the outputs, without having to remember on
which side the transpose goes: <u|v> is a scalar, |u><v| is a matrix. I
don't have a good way of translating this to numpy, but maybe someone else
has an idea.


Certainly, matrix transpose should error on 0d arrays, because it doesn't
> make sense to transpose a scalar.
>

Unless the scalar is 8, in which case the transpose is np.inf...

Right now, np.int(8).T throws an error, but np.transpose(np.int(8)) gives a
0-d array. On one hand, it is nice to be able to use the same code for
scalars as for vectors, but on the other, you may be making a mistake.


/David.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20180529/c1929c1a/attachment.html>


More information about the NumPy-Discussion mailing list