diff 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
line wrap: on
line diff
--- a/src/Grids/equidistant_grid.jl	Wed Oct 19 23:14:00 2022 +0200
+++ b/src/Grids/equidistant_grid.jl	Wed Oct 19 23:23:36 2022 +0200
@@ -1,4 +1,3 @@
-
 """
     EquidistantGrid{Dim,T<:Real} <: Grid
 
@@ -72,7 +71,11 @@
 # TBD: Can this method be removed if `EquidistantGrid` is an AbstractArray?
 
 
+function evalOn(grid::EquidistantGrid, f::Function)
+    F(I...) = f(grid[I...]...)
 
+    return LazyFunctionArray(F, size(grid))
+end
 
 """
     spacing(grid::EquidistantGrid)