Mercurial > repos > public > sbplib_julia
diff src/Grids/grid.jl @ 1397:86026367a9ff feature/grids/scalar_eval_on
Support evaluating scalars on grids
author | Vidar Stiernström <vidar.stiernstrom@it.uu.se> |
---|---|
date | Tue, 15 Aug 2023 22:55:25 +0200 |
parents | 08f06bfacd5c |
children | dba1e8c95bbb |
line wrap: on
line diff
--- a/src/Grids/grid.jl Thu Jun 08 15:52:22 2023 +0200 +++ b/src/Grids/grid.jl Tue Aug 15 22:55:25 2023 +0200 @@ -74,7 +74,7 @@ """ eval_on(g::Grid, f) -Lazy evaluation `f` on the grid. `f` can either be on the form `f(x,y,...)` +Lazy evaluation of `f` on the grid. `f` can either be on the form `f(x,y,...)` with each coordinate as an argument, or on the form `f(x̄)` taking a coordinate vector. @@ -88,6 +88,14 @@ return LazyTensors.LazyFunctionArray((I...)->f(g[I...]...), size(g)) end end +""" + eval_on(g::Grid, f::Number) + +Lazy evaluation of a scalar `f` on the grid. ` + +For concrete array grid functions `map(f,g)` can be used instead. +""" +eval_on(g::Grid, f::Number) = return LazyTensors.LazyConstantArray(f, size(g)) _ncomponents(::Type{<:Number}) = 1 _ncomponents(T::Type{<:SVector}) = length(T)