comparison src/Grids/equidistant_grid.jl @ 1146:31041ef8092a refactor/grids

Specialize evalOn for EquidistantGrid to return a LazyArray
author Jonatan Werpers <jonatan@werpers.com>
date Wed, 19 Oct 2022 23:23:36 +0200
parents 9275d95e2d90
children bda0afcf8e52
comparison
equal deleted inserted replaced
1145:4da66d6d7bed 1146:31041ef8092a
1
2 """ 1 """
3 EquidistantGrid{Dim,T<:Real} <: Grid 2 EquidistantGrid{Dim,T<:Real} <: Grid
4 3
5 `Dim`-dimensional equidistant grid with coordinates of type `T`. 4 `Dim`-dimensional equidistant grid with coordinates of type `T`.
6 """ 5 """
70 69
71 Base.getindex(g::EquidistantGrid, I::CartesianIndex) = g[Tuple(I)...] 70 Base.getindex(g::EquidistantGrid, I::CartesianIndex) = g[Tuple(I)...]
72 # TBD: Can this method be removed if `EquidistantGrid` is an AbstractArray? 71 # TBD: Can this method be removed if `EquidistantGrid` is an AbstractArray?
73 72
74 73
74 function evalOn(grid::EquidistantGrid, f::Function)
75 F(I...) = f(grid[I...]...)
75 76
77 return LazyFunctionArray(F, size(grid))
78 end
76 79
77 """ 80 """
78 spacing(grid::EquidistantGrid) 81 spacing(grid::EquidistantGrid)
79 82
80 The spacing between grid points. 83 The spacing between grid points.