Skip to content

Commit

Permalink
Remove number / vector (JuliaLang#44358)
Browse files Browse the repository at this point in the history
* Remove number / vector
* Fix test
  • Loading branch information
antoine-levitt committed Mar 12, 2022
1 parent e6c1525 commit 24d5268
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
3 changes: 3 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ Standard library changes

#### LinearAlgebra

* The methods `a / b` and `b \ a` with `a` a scalar and `b` a vector,
which were equivalent to `a * pinv(b)`, have been removed due to the
risk of confusion with elementwise division ([#44358]).
* We are now wholly reliant on libblastrampoline (LBT) for calling
BLAS and LAPACK. OpenBLAS is shipped by default, but building the
system image with other BLAS/LAPACK libraries is not
Expand Down
3 changes: 0 additions & 3 deletions stdlib/LinearAlgebra/src/generic.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1142,9 +1142,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)
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 @@ -1108,12 +1108,12 @@ 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)))
@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)))
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))
@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))
end
function test_div_pinv_consistency(a, b)
test_rdiv_pinv_consistency(a, b)
Expand Down

0 comments on commit 24d5268

Please sign in to comment.