File tree Expand file tree Collapse file tree 2 files changed +13
-1
lines changed Expand file tree Collapse file tree 2 files changed +13
-1
lines changed Original file line number Diff line number Diff line change @@ -1821,7 +1821,7 @@ julia> det(BigInt[1 0; 2 2]) # exact integer determinant
18211821function det (A:: AbstractMatrix{T} ) where {T}
18221822 if istriu (A) || istril (A)
18231823 S = promote_type (T, typeof ((one (T)* zero (T) + zero (T))/ one (T)))
1824- return convert (S, det ( UpperTriangular (A) ))
1824+ return prod (Base . Fix1 (convert, S), @view A[ diagind (A)]; init = one (S ))
18251825 end
18261826 return det (lu (A; check = false ))
18271827end
Original file line number Diff line number Diff line change @@ -103,6 +103,18 @@ n = 5 # should be odd
103103 @testset " det with nonstandard Number type" begin
104104 elty <: Real && @test det (Dual .(triu (A), zero (A))) isa Dual
105105 end
106+ if elty <: Int
107+ @testset " det no overflow - triangular" begin
108+ A = diagm ([typemax (elty), typemax (elty)])
109+ @test det (A) == det (float (A))
110+ end
111+ end
112+ @testset " det with units - triangular" begin
113+ for dim in 0 : 4
114+ A = diagm (Furlong .(ones (elty, dim)))
115+ @test det (A) == Furlong {dim} (one (elty))
116+ end
117+ end
106118end
107119
108120@testset " diag" begin
You can’t perform that action at this time.
0 commit comments