Skip to content

Commit

Permalink
Generic fallback for logdet (with numbers in mind) (JuliaLang#22629)
Browse files Browse the repository at this point in the history
  • Loading branch information
mschauer authored and andreasnoack committed Jul 7, 2017
1 parent 3a5d19a commit ad9f5de
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 0 deletions.
2 changes: 2 additions & 0 deletions base/linalg/generic.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1261,6 +1261,8 @@ function logdet(A::AbstractMatrix)
return d + log(s)
end

logdet(A) = log(det(A))

const NumberArray{T<:Number} = AbstractArray{T}

"""
Expand Down
1 change: 1 addition & 0 deletions test/linalg/generic.jl
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ for elty in (Int, Rational{BigInt}, Float32, Float64, BigFloat, Complex{Float32}

debug && println("element type: $elty")

@test logdet(A[1,1]) == log(det(A[1,1]))
@test logdet(A) log(det(A))
@test logabsdet(A)[1] log(abs(det(A)))
@test logabsdet(convert(Matrix{elty}, -eye(n)))[2] == -1
Expand Down

0 comments on commit ad9f5de

Please sign in to comment.