Mercurial > repos > public > sbplib_julia
comparison src/LazyTensors/lazy_tensor_operations.jl @ 531:36dfc57e8e0b feature/inflated_tensormapping_transpose
Write out some more documentation for split_index
author | Jonatan Werpers <jonatan@werpers.com> |
---|---|
date | Wed, 25 Nov 2020 22:03:26 +0100 |
parents | 7f969ea03a01 |
children | 588a843907de |
comparison
equal
deleted
inserted
replaced
530:7f969ea03a01 | 531:36dfc57e8e0b |
---|---|
282 return apply_transpose(itm.tm, v_inner, inner_index...) | 282 return apply_transpose(itm.tm, v_inner, inner_index...) |
283 end | 283 end |
284 | 284 |
285 | 285 |
286 """ | 286 """ |
287 split_index(:Val{A}, ::Val{B_view}, ::Val{B_middle}, ::Val{C}, I...) | 287 split_index(::Val{A}, ::Val{B_view}, ::Val{B_middle}, ::Val{C}, I...) |
288 | 288 |
289 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. | 289 Splits the multi-index `I` into two parts. One part which is expected to be used as a view, and one which is expected to be used as an index. |
290 Eg. | 290 Eg. |
291 ``` | 291 ``` |
292 (1,2,3,4) -> (1,:,:,:,4), (2,3) | 292 (1,2,3,4) -> (1,:,:,:,4), (2,3) |
293 ``` | 293 ``` |
294 | 294 |
295 `B_view` controls how many colons are in the view, and `B_middle` controls how many elements are extracted from the middle. | 295 `B_view` controls how many colons are in the view, and `B_middle` controls how many elements are extracted from the middle. |
296 `A` and `C` decides the length of the parts before and after the colons in the view index. | 296 `A` and `C` decides the length of the index parts before and after the colons in the view index. |
297 length(I) == A+B_domain+C | 297 |
298 length(I_middle) == B_domain | 298 Arguments should satisfy `length(I) == A+B_domain+C`. |
299 length(I_view) == A + B_range + C | 299 |
300 | 300 The returned values satisfy |
301 TODO: Finish documentation. | 301 * `length(view_index) == A + B_view + C` |
302 * `length(I_middle) == B_middle` | |
302 """ | 303 """ |
303 function split_index(::Val{A}, ::Val{B_view}, ::Val{B_middle}, ::Val{C}, I...) where {A,B_view, B_middle,C} | 304 function split_index(::Val{A}, ::Val{B_view}, ::Val{B_middle}, ::Val{C}, I...) where {A,B_view, B_middle,C} |
304 I_before = slice_tuple(I, Val(1), Val(A)) | 305 I_before = slice_tuple(I, Val(1), Val(A)) |
305 I_middle = slice_tuple(I, Val(A+1), Val(A+B_middle)) | 306 I_middle = slice_tuple(I, Val(A+1), Val(A+B_middle)) |
306 I_after = slice_tuple(I, Val(A+B_middle+1), Val(A+B_middle+C)) | 307 I_after = slice_tuple(I, Val(A+B_middle+1), Val(A+B_middle+C)) |