Hi. I am using Julia 1.10.4. I am using the LinearAlgebra package to compute rank, nullspace, et cetera for matrices. My code is unexpectedly throwing some errors and it turns out it seems to be calculating matrix rank incorrectly. For instance, the 2x2 matrix below clearly has linearly dependent columns with one of the eigenvalues being 0. However, the LinearAlgebra package outputs a rank of 2 and nullspace with an empty array. These types of matrices, by definition, have at most rank N-1 where N is the size of the matrix due to the row-sum = 0 constraint. So I am not sure what is going on.
This is the kind of problem the Note in the docstring for rank warns about:
│ Note
│
│ Numerical rank can be a sensitive and imprecise characterization of ill-conditioned matrices
│ with singular values that are close to the threshold tolerance max(atol, rtol*σ₁). In such
│ cases, slight perturbations to the singular-value computation or to the matrix can change the
│ result of rank by pushing one or more singular values across the threshold. These variations can
│ even occur due to changes in floating-point errors between different Julia versions,
│ architectures, compilers, or operating systems.