Skip to content

Commit

Permalink
Revert "Remove number / vector (#44358)" (#49915)
Browse files Browse the repository at this point in the history
(cherry picked from commit 503d5b4)
  • Loading branch information
oxinabox authored and KristofferC committed Aug 10, 2023
1 parent 1d2dd91 commit b9543ef
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
3 changes: 3 additions & 0 deletions stdlib/LinearAlgebra/src/generic.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1146,6 +1146,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)
Expand Down
8 changes: 4 additions & 4 deletions stdlib/LinearAlgebra/test/dense.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit b9543ef

Please sign in to comment.