[SciPy-user] solve for symetric matrix ?

fred fredmfp at gmail.com
Thu Apr 26 08:46:29 EDT 2007


Joachim Dahl a écrit :
> if diag(A)=0 then   ei'*A*ei  = 0 so A is not positive definite.  Same 
> goes for -A,  so A is
> not negative definite either.
>
Uh, I surely misunderstand something but what ?....

diag(A) =  0  but b'Ab != 0
 
cat test.py
#! /usr/bin/env python
#-*- coding: iso-8859-15 -*-

from scipy import *
from scipy.linalg import *

n = 5

A = zeros((n,n))

b = rand(n)

A[0,:] = range(5)
A[1,1:] = range(4)
A[2,2:] = range(3)
A[3,3:] = range(2)

for i in range(1,n):
    for j in range(0,i):
        A[i,j] = A[j,i]

print A

print inner(inner(b.transpose(), A), b)

./test.py
[[ 0.  1.  2.  3.  4.]
 [ 1.  0.  1.  2.  3.]
 [ 2.  1.  0.  1.  2.]
 [ 3.  2.  1.  0.  1.]
 [ 4.  3.  2.  1.  0.]]
16.9365786993

-- 
http://scipy.org/FredericPetit




More information about the SciPy-User mailing list