From 4539de5991d34a32a1721046382da089f8223674 Mon Sep 17 00:00:00 2001 From: Neven Sajko Date: Fri, 24 Nov 2023 10:41:10 +0100 Subject: [PATCH] detx: don't catch exceptions and retry with wider type This puts `detx` in line with the common Julia conventions (the limited width of the input is the caller's responsibility), while improving performance and type stability. --- src/detx.jl | 15 ++------------- 1 file changed, 2 insertions(+), 13 deletions(-) diff --git a/src/detx.jl b/src/detx.jl index dc401a5..ca07010 100644 --- a/src/detx.jl +++ b/src/detx.jl @@ -9,22 +9,11 @@ Here `T` can be any kind of integer, rational, `Mod`, or `GF2`. I hope to expand this to `Polynomial`s. """ function detx(A::AbstractMatrix{T}) where {T<:IntegerX} - # @info "Using IntegerX detx{$T}" - try - return T(det(A // 1)) - catch - A = big.(A) - return detx(A) - end + det(A // true) end function detx(A::AbstractMatrix{T}) where {T<:RationalX} - # @info "Using RationalX detx{$T}" - try - return det(A) - catch - return det(big.(A)) - end + det(A) end function detx(A::AbstractMatrix{T}) where {T}