def chck_posdef1(C):
    s="pos"
    i=0
    while i<len(C.rows()):

        ci=C[:i+1,:i+1]
        if det(ci)>0:
            i=i+1
        else:
            s="not pos"
            break    
    print s
    
A1=matrix([[2,-1,-1],[-1,2,-1],[-1,-1,2]])
chck_posdef1(A1)
out:not pos

A2=matrix([[2,-1,-1],[-1,2,1],[-1,1,2]])
chck_posdef1(A2)
out:pos

A3=matrix([[0,1,2],[1,0,1],[2,1,0]])
A4=A3*A3
chck_posdef1(A4)
out:pos

Strang-326-2-U (last edited 2010-12-17 04:51:19 by rupampy)