Mercurial > repos > public > sbplib_julia
comparison src/Grids/zero_dim_grid.jl @ 2057:8a2a0d678d6f feature/lazy_tensors/pretty_printing
Merge default
| author | Jonatan Werpers <jonatan@werpers.com> |
|---|---|
| date | Tue, 10 Feb 2026 22:41:19 +0100 |
| parents | 4ad1282f8bab |
| children |
comparison
equal
deleted
inserted
replaced
| 1110:c0bff9f6e0fb | 2057:8a2a0d678d6f |
|---|---|
| 1 """ | |
| 2 ZeroDimGrid{T} <: Grid{T,0} | |
| 3 | |
| 4 A zero dimensional grid consisting of a single point. | |
| 5 """ | |
| 6 struct ZeroDimGrid{T} <: Grid{T,0} | |
| 7 point::T | |
| 8 end | |
| 9 | |
| 10 # Indexing interface | |
| 11 Base.getindex(g::ZeroDimGrid) = g.point | |
| 12 Base.eachindex(g::ZeroDimGrid) = CartesianIndices(()) | |
| 13 | |
| 14 # Iteration interface | |
| 15 Base.iterate(g::ZeroDimGrid) = (g.point, nothing) | |
| 16 Base.iterate(g::ZeroDimGrid, ::Any) = nothing | |
| 17 | |
| 18 Base.IteratorSize(::Type{<:ZeroDimGrid}) = Base.HasShape{0}() | |
| 19 Base.length(g::ZeroDimGrid) = 1 | |
| 20 Base.size(g::ZeroDimGrid) = () | |
| 21 | |
| 22 | |
| 23 refine(g::ZeroDimGrid, ::Int) = g | |
| 24 coarsen(g::ZeroDimGrid, ::Int) = g | |
| 25 | |
| 26 boundary_identifiers(g::ZeroDimGrid) = () | |
| 27 boundary_grid(g::ZeroDimGrid, ::Any) = throw(ArgumentError("ZeroDimGrid has no boundaries")) | |
| 28 boundary_indices(g::ZeroDimGrid, ::Any) = throw(ArgumentError("ZeroDimGrid has no boundaries")) |
