Skip to content

Commit

Permalink
document exact BigInt determinants (JuliaLang#53579)
Browse files Browse the repository at this point in the history
New users are commonly surprised that determinants of integer matrices
give an approximate floating-point answer (JuliaLang#40128), and are unaware that
an exact algorithm is implemented for `BigInt` matrices (JuliaLang#40868). This
PR comments on both of these facts in the `det` documentation.

(At some point, we may want to mark `LinearAlgebra.det_bareiss` as
`public`, and document it, but that can be done in a future PR.)
  • Loading branch information
stevengj authored and mkitti committed Apr 13, 2024
1 parent ace76dd commit 8516fce
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions stdlib/LinearAlgebra/src/generic.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1642,6 +1642,15 @@ julia> M = [1 0; 2 2]
julia> det(M)
2.0
```
Note that, in general, `det` computes a floating-point approximation of the
determinant, even for integer matrices, typically via Gaussian elimination.
Julia includes an exact algorithm for integer determinants (the Bareiss algorithm),
but only uses it by default for `BigInt` matrices (since determinants quickly
overflow any fixed integer precision):
```jldoctest
julia> det(BigInt[1 0; 2 2]) # exact integer determinant
2
```
"""
function det(A::AbstractMatrix{T}) where {T}
if istriu(A) || istril(A)
Expand Down

0 comments on commit 8516fce

Please sign in to comment.