from numpy import array, eye, matrix
x = array([1, 0])
A = eye(2)
print(A.dot(x))
prints [1. 0.]
.
On the other hand,
Stop using matrix
. numpy.matrix.flatten returns a 1-row matrix, because that's as flat as matrix
instances get. If for some reason you are dead set on using matrix
, convert to ndarray with matrix.A before flattening:
flat = whatever_matrix.A.flatten()
or just use A1
to get a flat ndarray directly:
flat = whatever_matrix.A1