Skip to content

Commit 92165f2

Browse files
committed
Add a logabsdet method for triangular SMatrix.
This relies on `mapreduce` doing the right thing.
1 parent 9ba2a06 commit 92165f2

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

src/det.jl

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,13 @@ end
4444

4545
det(F::LU) = det(F.U) * _parity(F.p)
4646

47+
function logabsdet(A::Union{LowerTriangular{<:Any,<:StaticMatrix},
48+
UpperTriangular{<:Any,<:StaticMatrix}})
49+
checksquare(A)
50+
mapreduce(x -> (log(abs(x)), sign(x)), ((l1, s1), (l2, s2)) -> (l1 + l2, s1 * s2),
51+
diag(A))
52+
end
53+
4754
function logdet(F::LU)
4855
d, s = logabsdet(F.U)
4956
d + log(s * _parity(F.p))

0 commit comments

Comments
 (0)