简体   繁体   中英

How to remove a column or a row of a matrix in SymPy with keeping the original one

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?

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM