From cc53913bf18ac275ece2a31fc09e50836e6e0848 Mon Sep 17 00:00:00 2001 From: "Steven G. Johnson" Date: Wed, 11 Jun 2014 16:40:16 -0400 Subject: [PATCH] =?UTF-8?q?restore=20broadcasting=20array=C2=B1scalar=20op?= =?UTF-8?q?erations=20(removed=20in=20#5810)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- NEWS.md | 4 +--- base/array.jl | 11 +++++++++++ base/deprecated.jl | 11 +---------- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/NEWS.md b/NEWS.md index 99fa80767c31f..ad6a54ebbca07 100644 --- a/NEWS.md +++ b/NEWS.md @@ -216,9 +216,7 @@ Library improvements the same length. This generalizes and replaces `normfro` ([#6057]), and `norm` is now type-stable ([#6056]). - * `+` and `-` now require the sizes of the arrays to be the - same: the operations no longer do broadcasting. New - `UniformScaling` matrix type and identity `I` constant (#5810). + * New `UniformScaling` matrix type and identity `I` constant (#5810). * None of the concrete matrix factorization types are exported from Base by default anymore. diff --git a/base/array.jl b/base/array.jl index d62dec5889920..95d752f06082b 100644 --- a/base/array.jl +++ b/base/array.jl @@ -767,6 +767,17 @@ for f in (:.+, :.-, :.*, :./, :.\, :.%, :div, :mod, :rem, :&, :|, :$) end end +# convenient and familiar aliases for broadcasting operations +# of array ± scalar: +(+)(A::StridedArray{Bool},x::Bool) = A .+ x +(+)(x::Bool,A::StridedArray{Bool}) = x .+ A +(-)(A::StridedArray{Bool},x::Bool) = A .- x +(-)(x::Bool,A::StridedArray{Bool}) = x .- A +(+)(A::StridedArray,x::Number) = A .+ x +(+)(x::Number,A::StridedArray) = x .+ A +(-)(A::StridedArray,x::Number) = A .- x +(-)(x::Number,A::StridedArray) = x .- A + # functions that should give an Int result for Bool arrays for f in (:.+, :.-) @eval begin diff --git a/base/deprecated.jl b/base/deprecated.jl index 7e830178a0171..dba6dda8e0cc5 100644 --- a/base/deprecated.jl +++ b/base/deprecated.jl @@ -185,16 +185,7 @@ end @deprecate svdfact(A,thin) svdfact(A,thin=thin) @deprecate svdfact!(A,thin) svdfact(A,thin=thin) @deprecate svd(A,thin) svd(A,thin=thin) -# Note: These methods need a more helpfull error message than a `NoMethodError`, -# when the deprecation is removed -@deprecate (+)(A::Array{Bool},x::Bool) A .+ x -@deprecate (+)(x::Bool,A::Array{Bool}) x .+ A -@deprecate (-)(A::Array{Bool},x::Bool) A .- x -@deprecate (-)(x::Bool,A::Array{Bool}) x .- A -@deprecate (+)(A::Array,x::Number) A .+ x -@deprecate (+)(x::Number,A::Array) x .+ A -@deprecate (-)(A::Array,x::Number) A .- x -@deprecate (-)(x::Number,A::Array) x .- A + @deprecate (/)(x::Number,A::Array) x ./ A @deprecate (\)(A::Array,x::Number) A .\ x