Mercurial > repos > public > sbplib_julia
comparison src/LazyTensors/lazy_tensor_operations.jl @ 1897:ed50eec18365 refactor/lazy_tensors/elementwise_ops
Change implementation of apply to use sum()
author | Jonatan Werpers <jonatan@werpers.com> |
---|---|
date | Fri, 31 Jan 2025 11:03:09 +0100 |
parents | 378002c78e86 |
children |
comparison
equal
deleted
inserted
replaced
1895:adc83961cfe9 | 1897:ed50eec18365 |
---|---|
97 D = domain_dim(ts[1]) | 97 D = domain_dim(ts[1]) |
98 return TensorSum{T,R,D}(ts) | 98 return TensorSum{T,R,D}(ts) |
99 end | 99 end |
100 | 100 |
101 function apply(tmBinOp::TensorSum{T,R,D}, v::AbstractArray{<:Any,D}, I::Vararg{Any,R}) where {T,R,D} | 101 function apply(tmBinOp::TensorSum{T,R,D}, v::AbstractArray{<:Any,D}, I::Vararg{Any,R}) where {T,R,D} |
102 vs = map(tmBinOp.tms) do tm | 102 return sum(tmBinOp.tms) do tm |
103 apply(tm,v,I...) | 103 apply(tm,v,I...) |
104 end | 104 end |
105 | |
106 return +(vs...) | |
107 end | 105 end |
108 | 106 |
109 function apply_transpose(tmBinOp::TensorSum{T,R,D}, v::AbstractArray{<:Any,D}, I::Vararg{Any,R}) where {T,R,D} | 107 function apply_transpose(tmBinOp::TensorSum{T,R,D}, v::AbstractArray{<:Any,D}, I::Vararg{Any,R}) where {T,R,D} |
110 vs = map(tmBinOp.tms) do tm | 108 return sum(tmBinOp.tms) do tm |
111 apply_transpose(tm,v,I...) | 109 apply_transpose(tm,v,I...) |
112 end | 110 end |
113 | |
114 return +(vs...) | |
115 end | 111 end |
116 | 112 |
117 range_size(tmBinOp::TensorSum) = range_size(tmBinOp.tms[1]) | 113 range_size(tmBinOp::TensorSum) = range_size(tmBinOp.tms[1]) |
118 domain_size(tmBinOp::TensorSum) = domain_size(tmBinOp.tms[1]) | 114 domain_size(tmBinOp::TensorSum) = domain_size(tmBinOp.tms[1]) |
119 | 115 |