Reputation: 49
I want to remove a column from the matrix and I want to keep original one but whenever I use command col_del()
it deletes all columns of matrices even if I rename another one. For example:
q=sp.Matrix([[x,x+1],[x-1,x+2]])
display(q)
w=q
display(w)
w.col_del(0)
w1=w
display(w1)
display(w)
display(q)
If I delete column for w
, it also deletes column of q
which I want it to be unchanged. How can I keep the original one?
Upvotes: 0
Views: 1496
Reputation: 7058
to understand what w=q
means, I suggest you watch this talk by Brendan Rhodes. In short, w
and q
point to the same object, so removing something from the one, removes it from the other too
w = c.copy()
might solve your trouble
Upvotes: 1
Reputation: 415
Variables and Other References In Python
Change your code here:
w=q.copy()
Upvotes: 0