Mercurial > repos > public > sbplib_julia
comparison src/LazyTensors/lazy_array.jl @ 1118:6104db60b7a3 feature/lazy_arrays
Export binary operations for LazyArrays and scalars
author | Vidar Stiernström <vidar.stiernstrom@it.uu.se> |
---|---|
date | Fri, 15 Jul 2022 15:23:16 +0200 |
parents | 4dd3c2312d9e |
children | c78c9a95024a |
comparison
equal
deleted
inserted
replaced
1111:5b3d4a8ec3ab | 1118:6104db60b7a3 |
---|---|
91 Base.@propagate_inbounds *̃(a::T, b::AbstractArray{T,D}) where {T,D} = LazyElementwiseOperation{T,D,:*}(a,b) | 91 Base.@propagate_inbounds *̃(a::T, b::AbstractArray{T,D}) where {T,D} = LazyElementwiseOperation{T,D,:*}(a,b) |
92 Base.@propagate_inbounds /̃(a::T, b::AbstractArray{T,D}) where {T,D} = LazyElementwiseOperation{T,D,:/}(a,b) | 92 Base.@propagate_inbounds /̃(a::T, b::AbstractArray{T,D}) where {T,D} = LazyElementwiseOperation{T,D,:/}(a,b) |
93 | 93 |
94 | 94 |
95 | 95 |
96 # NOTE: Är det knas att vi har till exempel * istället för .* ?? | 96 # Overload +,-,*,/ for LazyArrays |
97 # Oklart om det ens går att lösa.. | 97 # Element wise operation for `*` and `/` are not overloaded for due to conflicts with the behavior |
98 # of regular `*` and `/` for AbstractArrays. Use tilde versions instead. | |
99 # TODO: Try to make it work for `*` and `/` for e.g. *(::LazyArray{T},::T)? | |
98 Base.@propagate_inbounds Base.:+(a::LazyArray{T,D}, b::LazyArray{T,D}) where {T,D} = a +̃ b | 100 Base.@propagate_inbounds Base.:+(a::LazyArray{T,D}, b::LazyArray{T,D}) where {T,D} = a +̃ b |
101 Base.@propagate_inbounds Base.:-(a::LazyArray{T,D}, b::LazyArray{T,D}) where {T,D} = a -̃ b | |
102 | |
99 Base.@propagate_inbounds Base.:+(a::LazyArray{T,D}, b::AbstractArray{T,D}) where {T,D} = a +̃ b | 103 Base.@propagate_inbounds Base.:+(a::LazyArray{T,D}, b::AbstractArray{T,D}) where {T,D} = a +̃ b |
104 Base.@propagate_inbounds Base.:-(a::LazyArray{T,D}, b::AbstractArray{T,D}) where {T,D} = a -̃ b | |
105 | |
100 Base.@propagate_inbounds Base.:+(a::AbstractArray{T,D}, b::LazyArray{T,D}) where {T,D} = a +̃ b | 106 Base.@propagate_inbounds Base.:+(a::AbstractArray{T,D}, b::LazyArray{T,D}) where {T,D} = a +̃ b |
101 | |
102 Base.@propagate_inbounds Base.:-(a::LazyArray{T,D}, b::LazyArray{T,D}) where {T,D} = a -̃ b | |
103 Base.@propagate_inbounds Base.:-(a::LazyArray{T,D}, b::AbstractArray{T,D}) where {T,D} = a -̃ b | |
104 Base.@propagate_inbounds Base.:-(a::AbstractArray{T,D}, b::LazyArray{T,D}) where {T,D} = a -̃ b | 107 Base.@propagate_inbounds Base.:-(a::AbstractArray{T,D}, b::LazyArray{T,D}) where {T,D} = a -̃ b |
105 | 108 |
106 # Element wise operation for `*` and `\` are not overloaded due to conflicts with the behavior | 109 Base.@propagate_inbounds Base.:+(a::LazyArray{T,D}, b::T) where {T,D} = a +̃ b |
107 # of regular `*` and `/` for AbstractArrays. Use tilde versions instead. | 110 Base.@propagate_inbounds Base.:-(a::LazyArray{T,D}, b::T) where {T,D} = a -̃ b |
111 | |
112 Base.@propagate_inbounds Base.:+(a::T, b::LazyArray{T,D}) where {T,D} = a +̃ b | |
113 Base.@propagate_inbounds Base.:-(a::T, b::LazyArray{T,D}) where {T,D} = a -̃ b | |
108 | 114 |
109 export +̃, -̃, *̃, /̃ | 115 export +̃, -̃, *̃, /̃ |