File tree Expand file tree Collapse file tree 2 files changed +17
-2
lines changed Expand file tree Collapse file tree 2 files changed +17
-2
lines changed Original file line number Diff line number Diff line change @@ -1678,8 +1678,12 @@ julia> logabsdet(B)
1678
1678
(0.6931471805599453, 1.0)
1679
1679
```
1680
1680
"""
1681
- logabsdet (A:: AbstractMatrix ) = logabsdet (lu (A, check= false ))
1682
-
1681
+ function logabsdet (A:: AbstractMatrix )
1682
+ if istriu (A) || istril (A)
1683
+ return logabsdet (UpperTriangular (A))
1684
+ end
1685
+ return logabsdet (lu (A, check= false ))
1686
+ end
1683
1687
logabsdet (a:: Number ) = log (abs (a)), sign (a)
1684
1688
1685
1689
"""
Original file line number Diff line number Diff line change @@ -77,6 +77,17 @@ n = 5 # should be odd
77
77
X = fill (x, 1 , 1 )
78
78
@test logabsdet (x)[1 ] ≈ logabsdet (X)[1 ]
79
79
@test logabsdet (x)[2 ] ≈ logabsdet (X)[2 ]
80
+ # Diagonal, upper, and lower triangular matrices
81
+ chksign (s1, s2) = if elty <: Real s1 == s2 else s1 ≈ s2 end
82
+ D = Matrix (Diagonal (A))
83
+ v, s = logabsdet (D)
84
+ @test v ≈ log (abs (det (D))) && chksign (s, sign (det (D)))
85
+ R = triu (A)
86
+ v, s = logabsdet (R)
87
+ @test v ≈ log (abs (det (R))) && chksign (s, sign (det (R)))
88
+ L = tril (A)
89
+ v, s = logabsdet (L)
90
+ @test v ≈ log (abs (det (L))) && chksign (s, sign (det (L)))
80
91
end
81
92
82
93
@testset " det with nonstandard Number type" begin
You can’t perform that action at this time.
0 commit comments