comparison src/Grids/grid.jl @ 1234:8806f4cd6fee refactor/grids

Move ZeroDimGrid to its own file
author Jonatan Werpers <jonatan@werpers.com>
date Sun, 19 Feb 2023 22:20:44 +0100
parents 3924c1f6ec6d
children 917cb8acbc17
comparison
equal deleted inserted replaced
1233:3924c1f6ec6d 1234:8806f4cd6fee
53 Return one of the components of gfun as a grid function. 53 Return one of the components of gfun as a grid function.
54 """ 54 """
55 # Should it be lazy? Could it be a view? 55 # Should it be lazy? Could it be a view?
56 function getcomponent(gfun, I::Vararg{Int}) end 56 function getcomponent(gfun, I::Vararg{Int}) end
57 # function getcomponent(gfun, s::Symbol) end ? 57 # function getcomponent(gfun, s::Symbol) end ?
58
59 # TBD: New file zero_dim_grid.jl?
60 struct ZeroDimGrid{T,S,RD} <: Grid{T,0,RD}
61 p::S
62
63 function ZeroDimGrid(p)
64 T = eltype(p)
65 S = typeof(p)
66 RD = length(p)
67 return new{T,S,RD}(p)
68 end
69 end
70
71 Base.size(g::ZeroDimGrid) = ()
72 Base.getindex(g::ZeroDimGrid) = g.p
73 Base.eachindex(g::ZeroDimGrid) = CartesianIndices(())
74