From e216f864718340e49533212046d9f4c6c5f7ed6b Mon Sep 17 00:00:00 2001 From: Frames White Date: Mon, 22 May 2023 11:37:05 +0800 Subject: [PATCH] Revert "Remove number / vector (#44358)" This reverts commit 24d526871d5203317fa17f93f9a4ef9fb34e8632. --- stdlib/LinearAlgebra/src/generic.jl | 3 +++ stdlib/LinearAlgebra/test/dense.jl | 8 ++++---- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/stdlib/LinearAlgebra/src/generic.jl b/stdlib/LinearAlgebra/src/generic.jl index c66f59838e8ba..9b07ac093add8 100644 --- a/stdlib/LinearAlgebra/src/generic.jl +++ b/stdlib/LinearAlgebra/src/generic.jl @@ -1155,6 +1155,9 @@ 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) diff --git a/stdlib/LinearAlgebra/test/dense.jl b/stdlib/LinearAlgebra/test/dense.jl index 1546f3247acf4..4bb2859f0100b 100644 --- a/stdlib/LinearAlgebra/test/dense.jl +++ b/stdlib/LinearAlgebra/test/dense.jl @@ -1129,12 +1129,12 @@ end end function test_rdiv_pinv_consistency(a, b) - @test a*(b/b) ≈ (a*b)*pinv(b) ≈ a*(b*pinv(b)) - @test typeof(a*(b/b)) == typeof((a*b)*pinv(b)) == typeof(a*(b*pinv(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 ≈ (pinv(a)*a)*b ≈ pinv(a)*(a*b) - @test typeof((a\a)*b) == typeof((pinv(a)*a)*b) == typeof(pinv(a)*(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)