Thu Sep 13 16:05:58 CDT 2007
Anne Archibald wrote:
> 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
> on it).
Of course, one can keep track of the sign by cumprod(sgn(diag(L))),
yes? (Sorry, I don't know the numpy functions for these off hand, but I
assume they exist, yes?)
> 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:
>>> 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!
>>> SciPy-user mailing list
>> SciPy-user mailing list
> SciPy-user mailing list
More information about the SciPy-user