From d31de3f45fdeb84a3d2e59a9099c26c8d9a9ed10 Mon Sep 17 00:00:00 2001 From: Antoine Levitt Date: Sun, 9 May 2021 09:18:33 +0200 Subject: [PATCH 1/3] Remove implicit pinvs of vectors --- stdlib/LinearAlgebra/src/generic.jl | 4 ---- 1 file changed, 4 deletions(-) diff --git a/stdlib/LinearAlgebra/src/generic.jl b/stdlib/LinearAlgebra/src/generic.jl index 676e965652e8f..4dceae1ebc91e 100644 --- a/stdlib/LinearAlgebra/src/generic.jl +++ b/stdlib/LinearAlgebra/src/generic.jl @@ -1113,7 +1113,6 @@ function (\)(A::AbstractMatrix, B::AbstractVecOrMat) return qr(A, ColumnNorm()) \ B end -(\)(a::AbstractVector, b::AbstractArray) = pinv(a) * b """ A / B @@ -1142,9 +1141,6 @@ function (/)(A::AbstractVecOrMat, B::AbstractVecOrMat) size(A,2) != size(B,2) && throw(DimensionMismatch("Both inputs should have the same number of columns")) return copy(adjoint(adjoint(B) \ adjoint(A))) end -# \(A::StridedMatrix,x::Number) = inv(A)*x Should be added at some point when the old elementwise version has been deprecated long enough -# /(x::Number,A::StridedMatrix) = x*inv(A) -/(x::Number, v::AbstractVector) = x*pinv(v) cond(x::Number) = iszero(x) ? Inf : 1.0 cond(x::Number, p) = cond(x) From 52b38dbcf8826cb5b858506bbbd245004fe98b31 Mon Sep 17 00:00:00 2001 From: Antoine Levitt Date: Sun, 9 May 2021 17:56:40 +0200 Subject: [PATCH 2/3] fix tests --- stdlib/LinearAlgebra/test/bidiag.jl | 2 +- stdlib/LinearAlgebra/test/dense.jl | 38 ----------------------------- 2 files changed, 1 insertion(+), 39 deletions(-) diff --git a/stdlib/LinearAlgebra/test/bidiag.jl b/stdlib/LinearAlgebra/test/bidiag.jl index 422984d84eb6b..c561e15cf0a92 100644 --- a/stdlib/LinearAlgebra/test/bidiag.jl +++ b/stdlib/LinearAlgebra/test/bidiag.jl @@ -261,7 +261,7 @@ Random.seed!(1) b = bb c = cc else - b = view(bb, 1:n) + b = view(bb, 1:n, 1:1) c = view(cc, 1:n, 1:2) end end diff --git a/stdlib/LinearAlgebra/test/dense.jl b/stdlib/LinearAlgebra/test/dense.jl index f03bf4a953ac6..c9d902382867c 100644 --- a/stdlib/LinearAlgebra/test/dense.jl +++ b/stdlib/LinearAlgebra/test/dense.jl @@ -85,7 +85,6 @@ bimg = randn(n,2)/2 @test_throws DimensionMismatch b'\b @test_throws DimensionMismatch b\b' @test norm(a*x - b, 1)/norm(b) < ε*κ*n*2 # Ad hoc, revisit! - @test zeros(eltya,n)\fill(eltya(1),n) ≈ (zeros(eltya,n,1)\fill(eltya(1),n,1))[1,1] end @testset "Test nullspace" begin @@ -1107,43 +1106,6 @@ end end end -function test_rdiv_pinv_consistency(a, b) - @test (a*b)/b ≈ a*(b/b) ≈ (a*b)*pinv(b) ≈ a*(b*pinv(b)) - @test typeof((a*b)/b) == typeof(a*(b/b)) == typeof((a*b)*pinv(b)) == typeof(a*(b*pinv(b))) -end -function test_ldiv_pinv_consistency(a, b) - @test a\(a*b) ≈ (a\a)*b ≈ (pinv(a)*a)*b ≈ pinv(a)*(a*b) - @test typeof(a\(a*b)) == typeof((a\a)*b) == typeof((pinv(a)*a)*b) == typeof(pinv(a)*(a*b)) -end -function test_div_pinv_consistency(a, b) - test_rdiv_pinv_consistency(a, b) - test_ldiv_pinv_consistency(a, b) -end - -@testset "/ and \\ consistency with pinv for vectors" begin - @testset "Tests for type $elty" for elty in (Float32, Float64, ComplexF32, ComplexF64) - c = rand(elty, 5) - r = (elty <: Complex ? adjoint : transpose)(rand(elty, 5)) - cm = rand(elty, 5, 1) - rm = rand(elty, 1, 5) - @testset "dot products" begin - test_div_pinv_consistency(r, c) - test_div_pinv_consistency(rm, c) - test_div_pinv_consistency(r, cm) - test_div_pinv_consistency(rm, cm) - end - @testset "outer products" begin - test_div_pinv_consistency(c, r) - test_div_pinv_consistency(cm, rm) - end - @testset "matrix/vector" begin - m = rand(5, 5) - test_ldiv_pinv_consistency(m, c) - test_rdiv_pinv_consistency(r, m) - end - end -end - @testset "test ops on Numbers for $elty" for elty in [Float32,Float64,ComplexF32,ComplexF64] a = rand(elty) @test isposdef(one(elty)) From 23c0b746893ffce3ea42556d027948f898dc4084 Mon Sep 17 00:00:00 2001 From: Antoine Levitt Date: Sun, 9 May 2021 18:36:49 +0200 Subject: [PATCH 3/3] missed one --- stdlib/LinearAlgebra/test/qr.jl | 9 --------- 1 file changed, 9 deletions(-) diff --git a/stdlib/LinearAlgebra/test/qr.jl b/stdlib/LinearAlgebra/test/qr.jl index f9acbdb376465..13c69e026425b 100644 --- a/stdlib/LinearAlgebra/test/qr.jl +++ b/stdlib/LinearAlgebra/test/qr.jl @@ -234,15 +234,6 @@ end end end -@testset "QR on Ints" begin - # not sure what to do about this edge case now that we build decompositions - # for qr(...), so for now just commenting this out - # @test qr(Int[]) == (Int[],1) - - B = rand(7,2) - @test (1:7)\B ≈ Vector(1:7)\B -end - @testset "Issue 16520" begin @test_throws DimensionMismatch Matrix{Float64}(undef,3,2)\(1:5) end