![]() |
Subject: Dot product of a matrix and an array Newsgroups: gmane.comp.python.scientific.user Date: Friday 17th February 2012 11:04:00 UTC (over 6 years ago) Hi! The dot product of a matrix and an array seems to return a matrix. However, this resulting matrix seems to have inconsistent shape. For simplicity, let I be an identity matrix (matrix object) and x a vector (1-d array object). Then np.dot gives wrong dimensions for I*x which causes that one can not compute I*(I*x). See the code below: >>> >>> import numpy as np >>> >>> x = np.arange(5) >>> >>> I = np.asmatrix(np.identity(5)) >>> >>> np.dot(I,x) matrix([[ 0., 1., 2., 3., 4.]]) >>> >>> np.dot(I, np.dot(I,x)) Traceback (most recent call last): File " |
||