Mercurial > repos > public > sbplib_julia
changeset 206:7b0650021b36 boundary_conditions
Remove implementations of elementwise operation for * and /
author | Jonatan Werpers <jonatan@werpers.com> |
---|---|
date | Mon, 24 Jun 2019 14:57:17 +0200 |
parents | 70e1f3401d82 |
children | f85a0b38f3ff |
files | LazyTensors/src/lazy_operations.jl LazyTensors/test/runtests.jl |
diffstat | 2 files changed, 2 insertions(+), 19 deletions(-) [+] |
line wrap: on
line diff
--- a/LazyTensors/src/lazy_operations.jl Mon Jun 24 14:43:37 2019 +0200 +++ b/LazyTensors/src/lazy_operations.jl Mon Jun 24 14:57:17 2019 +0200 @@ -113,19 +113,8 @@ Base.@propagate_inbounds Base.:-(a::LazyArray{T,D}, b::AbstractArray{T,D}) where {T,D} = a -̃ b Base.@propagate_inbounds Base.:-(a::AbstractArray{T,D}, b::LazyArray{T,D}) where {T,D} = a -̃ b -Base.@propagate_inbounds Base.:*(a::LazyArray{T,D}, b::LazyArray{T,D}) where {T,D} = a *̃ b -Base.@propagate_inbounds Base.:*(a::LazyArray{T,D}, b::AbstractArray{T,D}) where {T,D} = a *̃ b -Base.@propagate_inbounds Base.:*(a::AbstractArray{T,D}, b::LazyArray{T,D}) where {T,D} = a *̃ b - -# TODO: / seems to be ambiguous -Base.@propagate_inbounds Base.:/(a::LazyArray{T,D}, b::LazyArray{T,D}) where {T,D} = a /̃ b -Base.@propagate_inbounds Base.:/(a::LazyArray{T,D}, b::AbstractArray{T,D}) where {T,D} = a /̃ b -Base.@propagate_inbounds Base.:/(a::AbstractArray{T,D}, b::LazyArray{T,D}) where {T,D} = a /̃ b - -# NOTE: Need to define (/) for AbstractVectorOrMat and Union of LazyArrays in order to avoid ambiguities -# with (/) in the LinearAlgebra package. Not sure if it actually could be usefull. -Base.@propagate_inbounds Base.:/(a::AbstractVecOrMat, b::Union{LazyArray{T,1}, LazyArray{T,2}}) where {T} = a /̃ b -Base.@propagate_inbounds Base.:/(a::Union{LazyArray{T,1}, LazyArray{T,2}}, b::AbstractVecOrMat) where {T} = a /̃ b +# Element wise operation for `*` and `\` are not overloaded due to conflicts with the behavior +# of regular `*` and `/` for AbstractArrays. Use tilde versions instead. export +̃, -̃, *̃, /̃
--- a/LazyTensors/test/runtests.jl Mon Jun 24 14:43:37 2019 +0200 +++ b/LazyTensors/test/runtests.jl Mon Jun 24 14:57:17 2019 +0200 @@ -96,15 +96,9 @@ @test isa(v2 + v1, LazyArray) @test isa(v1 - v2, LazyArray) @test isa(v2 - v1, LazyArray) - @test isa(v1 * v2, LazyArray) - @test isa(v2 * v1, LazyArray) - @test isa(v1 / v2, LazyArray) - @test isa(v2 / v1, LazyArray) for i ∈ eachindex(v2) @test (v1 + v2)[i] == (v2 + v1)[i] == r_add[i] @test (v1 - v2)[i] == -(v2 - v1)[i] == r_sub[i] - @test (v1 * v2)[i] == (v2 * v1)[i] == r_times[i] - @test (v1 / v2)[i] == 1/((v2 / v1)[i]) == r_div[i] end @test_throws BoundsError (v1 + v2)[4] v2 = [1., 2, 3, 4]