Obtaining the determinant from a LinearSolveFunction object

I am working with matrices of which I need both the LinearSolveFunction and the determinant. My question is about something the documentation isn't entirely clear on. As far as I can tell, the LinearSolveFunction obtained from LinearSolve stores the LU decomposition of the matrix and from that it would be very easy to obtain the determinant.

mat = RandomReal[{-1, 1}, {3, 3}]
ls = LinearSolve[mat]
ls[[2, 3]]
Det[mat]
Tr[ls[[2, 3, 1]], Times]

However, the documentation mentions that:

When you create a LinearSolveFunction using LinearSolve[m], this often works by decomposing the matrix m into triangular forms, and sometimes it is useful to be able to get such forms explicitly."

So my question is: when use the above code, am I guaranteed that I will find the LU decomposition of my matrix when I evaluate ls[[2, 3]]? I can see that this is certainly not true when using other Methods in LinearSolve, but the default Automatic method seems to do have the LU decompositions there. Then again: the method being Automatic suggests that it might do something different depending on the matrix I put in.

So all being said and done: is there a good, reliable way to obtain the determinant from a LinearSolveFunction object?

• A related math.SE question. – J. M. will be back soon Sep 24 '17 at 11:09
• It depends on the method used (esp. the non-LU ones, such as "Cholesky", "Banded", "Krylov", and even "Multifrontal", which seems to produce a nonstandard LU decomposition). – Michael E2 Mar 17 '18 at 14:43

In this case, you will need to use some undocumented functionality:

Tr[ls["getU"], Times] Signature[ls["getPermutations"][]]

(currently away from my computer, so I'm only using gedanken Mathematica)