Mercurial > repos > public > sbplib_julia
comparison src/Grids/grid.jl @ 1273:7fab13c07412 refactor/grids
Allow multi-argument functions in eval_on
| author | Jonatan Werpers <jonatan@werpers.com> |
|---|---|
| date | Sat, 25 Feb 2023 22:57:00 +0100 |
| parents | 3637daad71e8 |
| children | dcd8654ca33b |
comparison
equal
deleted
inserted
replaced
| 1272:3637daad71e8 | 1273:7fab13c07412 |
|---|---|
| 52 TODO: | 52 TODO: |
| 53 | 53 |
| 54 * Mention map(f,g) if you want a concrete array | 54 * Mention map(f,g) if you want a concrete array |
| 55 """ | 55 """ |
| 56 eval_on(g::Grid, f) = eval_on(g, f, Base.IteratorSize(g)) # TBD: Borde f vara först som i alla map, sum, och dylikt | 56 eval_on(g::Grid, f) = eval_on(g, f, Base.IteratorSize(g)) # TBD: Borde f vara först som i alla map, sum, och dylikt |
| 57 eval_on(g::Grid, f, ::Base.HasShape) = LazyTensors.LazyFunctionArray((I...)->f(g[I...]), size(g)) | 57 function eval_on(g::Grid, f, ::Base.HasShape) |
| 58 | 58 if hasmethod(f, (Any,)) |
| 59 return LazyTensors.LazyFunctionArray((I...)->f(g[I...]), size(g)) | |
| 60 else | |
| 61 return LazyTensors.LazyFunctionArray((I...)->f(g[I...]...), size(g)) | |
| 62 end | |
| 63 end | |
| 59 | 64 |
| 60 """ | 65 """ |
| 61 getcomponent(gfun, I::Vararg{Int}) | 66 getcomponent(gfun, I::Vararg{Int}) |
| 62 | 67 |
| 63 Return one of the components of gfun as a grid function. | 68 Return one of the components of gfun as a grid function. |
