Determining if a matrix is singular or not is an inherently unstable computation. Different orders of operations of cut-offs on the condition number will give different results.
julia> using AppleAccelerate
julia> A = [1 2 3; 4 5 6; 7 8 9]
3×3 Matrix{Int64}:
1 2 3
4 5 6
7 8 9
julia> using LinearAlgebra
julia> cond(A) # condition number
5.015946803014265e16
julia> inv(A) # an unstable approximation to the inverse
3×3 Matrix{Float64}:
3.15252e15 -6.30504e15 3.15252e15
-6.30504e15 1.26101e16 -6.30504e15
3.15252e15 -6.30504e15 3.15252e15
julia> versioninfo()
Julia Version 1.10.2
Commit bd47eca2c8a (2024-03-01 10:14 UTC)
Build Info:
Official https://julialang.org/ release
Platform Info:
OS: macOS (arm64-apple-darwin22.4.0)
CPU: 8 × Apple M1 Pro
WORD_SIZE: 64
LIBM: libopenlibm
LLVM: libLLVM-15.0.7 (ORCJIT, apple-m1)
Threads: 6 default, 0 interactive, 3 GC (on 6 virtual cores)
Environment:
JULIA_EDITOR = code
This matrix is singular in theory but not computationally singular in the tolerances used here.