[SciPy-user] determinants
David Goldsmith
David.L.Goldsmith@noaa....
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?)
DG
> 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.
>
> Anne
>
>
> On 13/09/2007, dmitrey <openopt@ukr.net> 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
>> 0.00356531521304
>> 210176.6131
>> -6.3723083425e+24
>> 1.45560352703e+80
>> 8.58872496027e+217
>> -2.76708200113e+296
>> -inf
>>
>> 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
>>> SciPy-user@scipy.org
>>> http://projects.scipy.org/mailman/listinfo/scipy-user
>>>
>>>
>>>
>>>
>>>
>> _______________________________________________
>> SciPy-user mailing list
>> SciPy-user@scipy.org
>> http://projects.scipy.org/mailman/listinfo/scipy-user
>>
>>
> _______________________________________________
> SciPy-user mailing list
> SciPy-user@scipy.org
> http://projects.scipy.org/mailman/listinfo/scipy-user
>
More information about the SciPy-user
mailing list