[SciPy-user] verify whether a matrix is positive definite or not

Joachim Dahl dahl.joachim@gmail....
Thu Jun 28 14:09:04 CDT 2007


Hi Nils,

is this not similar to the eigenvalue problems we discussed off-list?

You can numerically find the smallest x (if that's what you want) by solving
minimize   x   s.t.   Bo - B1*x >= 0

In CVXOPT you can solve it as follows:

from cvxopt.base import matrix
from cvxopt.solvers import sdp
from cvxopt.lapack import syev

c  = matrix(-1.0)
B0 = matrix([ [11.,8.], [8.,7.] ])
B1 = matrix([ [20.,1.] ,[1.,26.] ])
Gs = [ B1[:] ]
hs = [ B0 ]

sol = sdp(c, Gs=Gs, hs=hs)
x = sol['x']

v = matrix([0., 0.])
syev(B0 - x*B1, v)
print v


- Joachim

On 6/28/07, Nils Wagner <nwagner@iam.uni-stuttgart.de> wrote:
>
> Hi all,
>
> I have a parameter-dependent matrix
>
> B(x) = B_0 + x B_1,  0 \le x \le 1
>
> where B_0 and B_1 are symmetric. How can I determine critical values x*
> (if any) such that B(x*) is not positive definite ?
>
>
> from scipy import *
>
> def B(x):
>
>     return array(([[11.,8.],[8.,7.]])) - x*array(([[20.,1.],[1.,26]]))
>
> X = linspace(0,1,100)
>
> for x in X:
>     print x
>     L=linalg.cholesky(B(x),lower=1)
>
> I mean it would be nice if cholesky could return info=1 if the matrix is
> not spd.
> The current behaviour is
>
> Traceback (most recent call last):
>   File "test_spd.py", line 11, in ?
>     L=linalg.cholesky(B(x),lower=1)
>   File "/usr/lib64/python2.4/site-packages/scipy/linalg/decomp.py", line
> 552, in cholesky
>     if info>0: raise LinAlgError, "matrix not positive definite"
> numpy.linalg.linalg.LinAlgError: matrix not positive definite
>
> Helpful suggestions would be appreciated.
>
> Nils
>
> _______________________________________________
> SciPy-user mailing list
> SciPy-user@scipy.org
> http://projects.scipy.org/mailman/listinfo/scipy-user
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://projects.scipy.org/pipermail/scipy-user/attachments/20070628/c7162be4/attachment.html 


More information about the SciPy-user mailing list