def diagonalize(X):
    if is_diag(X):
        a= X.eigenvectors_left()
        l=[]
        for i in a:
            l.append(list(i[1][0]))
        S=transpose(matrix(l))
        D=(S^(-1))*X*S
        return D
    else:
        print "not diag"   


A1=matrix([[1,1,1],[1,1,1],[1,1,1]])    
diagonalize(A1)
out:not diag

Strang-250-3-U (last edited 2010-12-17 05:07:57 by rupampy)