Mercurial > repos > public > sbplib_julia
comparison src/Grids/equidistant_grid.jl @ 1152:bda0afcf8e52 refactor/grids
REVIEW: Give input on TBD comments, suggest name change of evalOn.
author | Vidar Stiernström <vidar.stiernstrom@it.uu.se> |
---|---|
date | Thu, 20 Oct 2022 20:59:56 +0200 |
parents | 31041ef8092a |
children | 50b008d2e937 |
comparison
equal
deleted
inserted
replaced
1146:31041ef8092a | 1152:bda0afcf8e52 |
---|---|
34 """ | 34 """ |
35 function EquidistantGrid(size, limit_lower, limit_upper) | 35 function EquidistantGrid(size, limit_lower, limit_upper) |
36 return EquidistantGrid{length(size), eltype(limit_lower)}(size, limit_lower, limit_upper) | 36 return EquidistantGrid{length(size), eltype(limit_lower)}(size, limit_lower, limit_upper) |
37 end | 37 end |
38 # TBD: Should it be an AbstractArray? | 38 # TBD: Should it be an AbstractArray? |
39 # Review: Do we need it to be? It could be nice to have an iterator for a grid, but are there any other | |
40 # functionalities we need? Adding two grids etc? If not, I suggest against subtyping AbstractArray. | |
39 | 41 |
40 """ | 42 """ |
41 EquidistantGrid{T}() | 43 EquidistantGrid{T}() |
42 | 44 |
43 Constructs a 0-dimensional grid. | 45 Constructs a 0-dimensional grid. |
67 return g.limit_lower .+ (I.-1).*h | 69 return g.limit_lower .+ (I.-1).*h |
68 end | 70 end |
69 | 71 |
70 Base.getindex(g::EquidistantGrid, I::CartesianIndex) = g[Tuple(I)...] | 72 Base.getindex(g::EquidistantGrid, I::CartesianIndex) = g[Tuple(I)...] |
71 # TBD: Can this method be removed if `EquidistantGrid` is an AbstractArray? | 73 # TBD: Can this method be removed if `EquidistantGrid` is an AbstractArray? |
72 | 74 # Review: See comment above. |
73 | 75 |
76 # Review: | |
77 # Is it not strange that evalOn(::Grid) is non-lazy while evalOn(::EquidistantGrid) is? | |
78 # Also: Change name to evalon or eval_on!!!!!! | |
74 function evalOn(grid::EquidistantGrid, f::Function) | 79 function evalOn(grid::EquidistantGrid, f::Function) |
75 F(I...) = f(grid[I...]...) | 80 F(I...) = f(grid[I...]...) |
76 | 81 |
77 return LazyFunctionArray(F, size(grid)) | 82 return LazyFunctionArray(F, size(grid)) |
78 end | 83 end |