Thu Sep 13 13:44:26 CDT 2007
If you have problems with determinants becoming excessively large, you
may be able to circumvent them by computing the log of the
determinant. The easiest way to do this is to use LU decomposition:
P,L,U = scipy.linalg.lu(M)
d = sum(log(abs(diag(L))))
Of course you lose track of the sign doing this (P may be either an
even or odd permutation, though det should be reliable and efficient
This is not necessarily much slower than using scipy's built-in det;
both are O(N^3), at least, and scipy may implement its det this way.
On 13/09/2007, dmitrey <email@example.com> wrote:
> from scipy import linalg
> from scipy import rand
> for N in [10, 50, 100, 200, 400, 500, 1000]:
> print linalg.det(rand(N, N))
> So typical A[i,j] values are 0.0 ... 1.0 (that is much less than your
> -13...54) and
> typical output is
> Same in MATLAB/Octave
> So I don't see any bugs here.
> Regards, D.
> Alastair Basden wrote:
> > Hi,
> > I wonder whether there is a bug in scipy.linalg.det? If I call this with
> > my matrix, it returns inf. The matrix is 2048x2048 in size, with no inf
> > elements (max 54, min -13), float64 type.
> > I can't work out why it would think the determinant is infinity!
> > Thanks...
> > _______________________________________________
> > SciPy-user mailing list
> > SciPyfirstname.lastname@example.org
> > http://projects.scipy.org/mailman/listinfo/scipy-user
> SciPy-user mailing list
More information about the SciPy-user