Mercurial > repos > public > sbplib_julia
comparison src/Grids/tensor_grid.jl @ 1349:42ecd4b3e215 refactor/grids
Add support for cartesian indices on TensorGrid
author | Jonatan Werpers <jonatan@werpers.com> |
---|---|
date | Fri, 19 May 2023 14:53:49 +0200 |
parents | 08f06bfacd5c |
children | 4d628c83987e c0208286234e |
comparison
equal
deleted
inserted
replaced
1348:279179677040 | 1349:42ecd4b3e215 |
---|---|
23 Is = LazyTensors.split_tuple(I, szs) | 23 Is = LazyTensors.split_tuple(I, szs) |
24 ps = map((g,I)->SVector(g[I...]), g.grids, Is) | 24 ps = map((g,I)->SVector(g[I...]), g.grids, Is) |
25 | 25 |
26 return vcat(ps...) | 26 return vcat(ps...) |
27 end | 27 end |
28 | |
29 Base.getindex(g::TensorGrid, I::CartesianIndex) = g[Tuple(I)...] | |
28 | 30 |
29 function Base.eachindex(g::TensorGrid) | 31 function Base.eachindex(g::TensorGrid) |
30 szs = LazyTensors.concatenate_tuples(size.(g.grids)...) | 32 szs = LazyTensors.concatenate_tuples(size.(g.grids)...) |
31 return CartesianIndices(szs) | 33 return CartesianIndices(szs) |
32 end | 34 end |