Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

using of M.permute_rows_and_columns

Hi

I am aware that with this question my Karma will drop a notch !

despite explanations

I don't understand the use of M.permute_rows_and_columns() how to use it to do this function below ?

M = matrix(ZZ,[[1,0,0,0,0],[0,2,0,0,0],[0,0,3,0,0],[0,0,0,4,0],[0,0,0,0,5]])

def permRandC(a,b) :
    "permute row and column a,b"
    Mc=copy(M)
    Mc[:,a]=M[:,b]
    Mc[:,b]=M[:,a]
    Mr=copy(Mc)    
    Mr[a,:]=Mc[b,:]
    Mr[b,:]=Mc[a,:]
    return Mr

show(permRandC(0,1))