[Numpy-discussion] Should dot return 1x1 matrix as scalar?

Paulo J. S. Silva pjssilva at ime.usp.br
Fri Jan 13 03:49:05 CST 2006


Hello,

I was playing with the matrix type in numpy and I felt the "need" to
have the "dot" function returning a 1x1 matrix as a scalar. This would
allow for expressions like:

x = matrix(arange(10.))
versorX  = x / sqrt(x.T*x)

Right now, I have to write:

versorX = x / sqrt(x.T*x).item()

Actually, a.T*b can not always be used as the inner product with the
current behavior.

Note that dot already returns scalars when we multiply rank-1 arrays,
but matrices are always rank-2.

Best,

Paulo







More information about the Numpy-discussion mailing list