avatarzhang / python-statlib

Automatically exported from code.google.com/p/python-statlib
Other
0 stars 0 forks source link

ZeroDivisionError when computing det on a matrix #6

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
Python 2.4.4 (#71, Oct 18 2006, 08:34:43) [MSC v.1310 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import numpy
>>> m = [[516, 3080, 1540], [3080, 18400, 9200], [1540, 9200, 4600]]
>>> from numpy import linalg
>>> linalg.det(m)
0.0
>>> from statlib import matfunc
>>> matfunc.Square(m).det()
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
  File "c:\bs\gitrepo\statlib\matfunc.py", line 194, in det
    def det( self ):  return self.qr( ROnly=1 ).det()
  File "c:\bs\gitrepo\statlib\matfunc.py", line 142, in qr
    v, beta = R.tr()[i].house(i)
  File "c:\bs\gitrepo\statlib\matfunc.py", line 96, in house
    v = Vec( Table([0]*index).concat(self[index:]) ).normalize()
  File "c:\bs\gitrepo\statlib\matfunc.py", line 87, in normalize
    def normalize( self ):  return self / self.norm()
  File "c:\bs\gitrepo\statlib\matfunc.py", line 55, in __div__
    def __div__( self, rhs ):  return self.map( operator.div, rhs )
  File "c:\bs\gitrepo\statlib\matfunc.py", line 47, in map
    return self.__class__( [op(e,rhs) for e in self] )
ZeroDivisionError: float division

Original issue reported on code.google.com by kamil.dw...@googlemail.com on 1 Dec 2008 at 4:34

GoogleCodeExporter commented 8 years ago
This similarly occurs if 
m = Square([
            [1, 1, 1],
            [1, 1, 1],
            [1, 2, 3]
        ])

Original comment by TAT.Wri...@googlemail.com on 2 Dec 2008 at 12:23

GoogleCodeExporter commented 8 years ago
Looks like the problem occurs when the norms of two row vectors end up 
identical.

I will contact the original author to get his input.

Original comment by istvan.a...@gmail.com on 2 Dec 2008 at 1:22

GoogleCodeExporter commented 8 years ago
any news on this one?

Original comment by kamil.dw...@googlemail.com on 24 Dec 2008 at 2:43

GoogleCodeExporter commented 8 years ago
original author not responding in any way, fix will have to wait until he or 
someone
else adds the necessary fix

Original comment by istvan.a...@gmail.com on 26 Feb 2009 at 12:21