On Jun 6, 3:34 pm, Ajith Kumar <aj...@iuac.res.in> wrote: > Hello, > I ran the following code (Using Debian 5.0) > > from numpy import * > a = arange(1.,10.) > b = reshape(a, [3,3]) > c = linalg.inv(b) > print b > print c > print dot(b,c) > print dot(c,b) > > And the result is > > [[ 1. 2. 3.] > [ 4. 5. 6.] > [ 7. 8. 9.]] > > [[ 3.15221191e+15 -6.30442381e+15 3.15221191e+15] > [ -6.30442381e+15 1.26088476e+16 -6.30442381e+15] > [ 3.15221191e+15 -6.30442381e+15 3.15221191e+15]] > > [[-0.5 -1. -1. ] > [-1. -2. 2. ] > [-1.5 -3. 1. ]] > > [[ 5.5 8. 10.5] > [ 3. 0. -3. ] > [ -1. 0. -3. ]] > > NOT the identity matrix. Any help ?
It's a longer time than I care to divulge since I took courses in matrix algebra, but I do have a vague recollection that if determinant (B) is zero, inverse(B) is not defined ... seeing the rows and columns in B are linear (as are those of C), IIRC that means the determinants are zero, and you are out of luck. Are you ignoring exceptions? Is that _exactly_ what you typed in? Try running it again, print the calculated determinants of B and C, and tell what version of (a) numpy (b) Python you are using. Isn't there a mailing list for numpy? HTH, John -- http://mail.python.org/mailman/listinfo/python-list