Indeed, this looks weird.
At first I thought that you may have introduced some problems by using the name of the function cov from the standard Statistics library, but unless you import it, you are free to call your matrix cov
.
Do you think it is possible to share you matrix somehow? Do you generate it through a code? In general, it is really useful to share a minimum working example (including the imports/using
of the packages) because who knows where you take your function rank
from. I certainly cannot reproduce the problem with some randomly generated singular matrix.
julia> using LinearAlgebra: rank
julia> A = rand(13,138);
julia> X = A'*A
138×138 Matrix{Float64}:
6.37017 3.87032 3.7639 2.93673 3.90856 2.89665 … 3.58424 4.81491 2.77375 3.95746 4.24206
3.87032 4.4881 3.17356 3.16758 3.26719 2.35837 3.2946 4.02962 2.37569 3.14432 2.57209
3.7639 3.17356 4.64649 3.36158 2.97343 2.63004 4.15317 4.36145 3.35719 2.9598 4.12072
2.93673 3.16758 3.36158 3.80284 2.74161 2.42185 3.45357 3.46843 2.79067 2.18312 2.65219
3.90856 3.26719 2.97343 2.74161 3.84898 2.41936 3.0891 3.70304 2.32024 2.98657 3.03344
2.89665 2.35837 2.63004 2.42185 2.41936 2.40715 … 2.71721 3.39881 2.12739 2.21862 2.54849
5.21516 4.57535 4.43188 4.21679 3.69402 3.22894 4.32022 5.20635 3.58125 4.07824 4.01366
⋮ ⋮ ⋱ ⋮
4.42637 4.1324 3.98606 3.16609 3.45972 2.20833 3.65279 4.18168 2.93238 3.29186 3.46011
3.58424 3.2946 4.15317 3.45357 3.0891 2.71721 4.12401 4.17301 3.20623 2.70909 3.51342
4.81491 4.02962 4.36145 3.46843 3.70304 3.39881 4.17301 5.53489 3.24436 3.89468 4.29279
2.77375 2.37569 3.35719 2.79067 2.32024 2.12739 … 3.20623 3.24436 2.90164 2.27987 2.93651
3.95746 3.14432 2.9598 2.18312 2.98657 2.21862 2.70909 3.89468 2.27987 3.79522 3.11997
4.24206 2.57209 4.12072 2.65219 3.03344 2.54849 3.51342 4.29279 2.93651 3.11997 4.53387
julia> rank(X)
13
julia> rank(X[1:20,1:20])
13