diff --git a/stdlib/LinearAlgebra/src/generic.jl b/stdlib/LinearAlgebra/src/generic.jl index 36ced82eb6c7d..ac56cb191488a 100644 --- a/stdlib/LinearAlgebra/src/generic.jl +++ b/stdlib/LinearAlgebra/src/generic.jl @@ -978,7 +978,7 @@ function rank(A::AbstractMatrix; atol::Real = 0.0, rtol::Real = (min(size(A)...) tol = max(atol, rtol*s[1]) count(x -> x > tol, s) end -rank(x::Number) = iszero(x) ? 0 : 1 +rank(x::Union{Number,AbstractVector}) = iszero(x) ? 0 : 1 """ tr(M) diff --git a/stdlib/LinearAlgebra/test/generic.jl b/stdlib/LinearAlgebra/test/generic.jl index 805d9eddef8c8..25a89977bce54 100644 --- a/stdlib/LinearAlgebra/test/generic.jl +++ b/stdlib/LinearAlgebra/test/generic.jl @@ -235,6 +235,8 @@ end @test norm(NaN, 0) === NaN end +@test rank(zeros(4)) == 0 +@test rank(1:10) == 1 @test rank(fill(0, 0, 0)) == 0 @test rank([1.0 0.0; 0.0 0.9],0.95) == 1 @test rank([1.0 0.0; 0.0 0.9],rtol=0.95) == 1