Mercurial > repos > public > sbplib_julia
comparison src/LazyTensors/lazy_tensor_operations.jl @ 526:be152486d136 feature/inflated_tensormapping_transpose
Implement apply_transpose with tests
author | Jonatan Werpers <jonatan@werpers.com> |
---|---|
date | Wed, 25 Nov 2020 15:59:04 +0100 |
parents | 7e6250c51eb2 |
children | f9bc746f37da |
comparison
equal
deleted
inserted
replaced
525:7e6250c51eb2 | 526:be152486d136 |
---|---|
270 | 270 |
271 v_inner = view(v, view_index...) | 271 v_inner = view(v, view_index...) |
272 return apply(itm.tm, v_inner, inner_index...) | 272 return apply(itm.tm, v_inner, inner_index...) |
273 end | 273 end |
274 | 274 |
275 function apply_transpose(itm::InflatedTensorMapping{T,R,D}, v::AbstractArray{T,R}, I::Vararg{Any,D}) where {T,R,D} | |
276 A = range_dim(itm.before) | |
277 B_domain = domain_dim(itm.tm) | |
278 B_range = range_dim(itm.tm) | |
279 C = range_dim(itm.after) | |
280 | |
281 view_index, inner_index = split_index(Val(A), Val(B_range), Val(B_domain), Val(C), I...) | |
282 | |
283 v_inner = view(v, view_index...) | |
284 return apply_transpose(itm.tm, v_inner, inner_index...) | |
285 end | |
286 | |
275 | 287 |
276 """ | 288 """ |
277 split_index(:Val{A}, ::Val{B_view}, ::Val{B_middle}, ::Val{C}, I...) | 289 split_index(:Val{A}, ::Val{B_view}, ::Val{B_middle}, ::Val{C}, I...) |
278 | 290 |
279 Splits the multi-index `I` into two parts. One part which is expected to be used as a view, which is expected to be used as an index. | 291 Splits the multi-index `I` into two parts. One part which is expected to be used as a view, which is expected to be used as an index. |