Copy Numpy Matrix Into Numpy Array
I am using cvxpy to solve an optimization problem. I want to store the output, a matrix into a ndarray. This is the reduced test case. a representing the returned value from cvxpy.
Solution 1:
One simple way would be to use a list of the column index for indexing into z
and then simply assign the NumPy matrix a
there -
z[:,[0]] = a
Another way would be to use the transpose of the matrix a
, which would be a row vector to assign into the sliced version of the first column in z
-
z[:,0] = a.T
Post a Comment for "Copy Numpy Matrix Into Numpy Array"