Skip to content Skip to sidebar Skip to footer

Estimating Determinant Using Lapack Wrapper For Lu Decomposition In Cython

I define the function that calculates the determinant of a matrix here. But sometimes I get the wrong sign. I modeled my function from this answer. from scipy.linalg.cython_lapack

Solution 1:

dgetrf is a Fortran subroutine, and Fortran uses 1-based indexing, so the values in ipiv are between 1 and n (inclusive). To account for this, change the test in your loop from

        if j != ipiv[j]:

to

ifj!=ipiv[j]-1:

Post a Comment for "Estimating Determinant Using Lapack Wrapper For Lu Decomposition In Cython"