# LinearAlgebra: rank

**URL:** https://discourse.julialang.org/t/linearalgebra-rank/67763
**Category:** General Usage
**Tags:** linearalgebra
**Created:** [September 6, 2021, 4:12pm UTC](https://discourse.julialang.org/t/linearalgebra-rank/67763 "2021-09-06T16:12:24Z")
**Posts on this page:** 1
**Showing post:** 2

<div class="post-metadata">

### Author: ![zdenek\_hurak](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/zdenek_hurak/32/53118_2.png) [@zdenek\_hurak](https://discourse.julialang.org/u/zdenek_hurak)
#### Post date: [September 6, 2021, 5:08pm UTC](https://discourse.julialang.org/t/linearalgebra-rank/67763/2 "2021-09-06T17:08:33Z")

</div>

Indeed, this looks weird.

At first I thought that you may have introduced some problems by using the name of the function [cov](https://docs.julialang.org/en/v1/stdlib/Statistics/#Statistics.cov) from the standard [Statistics](https://docs.julialang.org/en/v1/stdlib/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](https://discourse.julialang.org/t/please-read-make-it-easier-to-help-you/14757) (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
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

```

---

_[View the full topic](https://discourse.julialang.org/t/linearalgebra-rank/67763)._
