Skip to content

Commit eb5f105

Browse files
committed
Fix det() return type for dimension N >= 4
1 parent abe95f4 commit eb5f105

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

src/det.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,13 @@ end
2424
return vecdot(x0, cross(x1, x2))
2525
end
2626

27-
@generated function _det{S,T}(::Size{S}, A::StaticMatrix{T})
27+
@generated function _det{S}(::Size{S}, A::StaticMatrix)
2828
if S[1] != S[2]
2929
throw(DimensionMismatch("matrix is not square"))
3030
end
3131
return quote # Implementation from Base
3232
@_inline_meta
33+
T = eltype(A)
3334
T2 = typeof((one(T)*zero(T) + zero(T))/one(T))
3435
if istriu(A) || istril(A)
3536
return convert(T2, det(UpperTriangular(A))) # Is this a Julia bug that a convert is not type stable??

test/det.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
#triu/tril
88
@test det(@SMatrix [1 2; 0 3]) === 3
99
@test det(@SMatrix [1 2 3 4; 0 5 6 7; 0 0 8 9; 0 0 0 10]) === 400.0
10+
@test @inferred(det(ones(SMatrix{10,10,Complex{Float64}}))) == 0
1011

1112
# Unsigned specializations
1213
@test det(@SMatrix [0x00 0x01; 0x01 0x00])::Int8 == -1

0 commit comments

Comments
 (0)