Mercurial > repos > public > sbplib_julia
comparison src/Grids/grid.jl @ 1279:1157f889bf50 refactor/grids
Clear out some TBDs
author | Jonatan Werpers <jonatan@werpers.com> |
---|---|
date | Sun, 26 Feb 2023 21:20:52 +0100 |
parents | dcd8654ca33b |
children | 7de1df0aad6a |
comparison
equal
deleted
inserted
replaced
1278:4a0570f325ce | 1279:1157f889bf50 |
---|---|
1 """ | 1 """ |
2 Grid{T,D} | 2 Grid{T,D} |
3 | 3 |
4 The top level type for grids. | 4 The top level type for grids. |
5 | 5 |
6 TODO: | |
6 Should implement | 7 Should implement |
7 # TBD: | 8 * interfaces for iteration and indexing |
8 """ | 9 """ |
9 #TBD: Should it be an AbstractArray? See notes in grid_refactor.md | |
10 # TODO: Document that grids should implement the interfaces for iteration and indexing. | |
11 abstract type Grid{T,D} end | 10 abstract type Grid{T,D} end |
12 | |
13 | 11 |
14 Base.ndims(::Grid{T,D}) where {T,D} = D | 12 Base.ndims(::Grid{T,D}) where {T,D} = D |
15 Base.eltype(::Type{<:Grid{T}}) where T = T | 13 Base.eltype(::Type{<:Grid{T}}) where T = T |
16 target_manifold_dim(::Grid{T}) where T = _ncomponents(T) # TBD: Name of this function?! | 14 target_manifold_dim(::Grid{T}) where T = _ncomponents(T) # TBD: Name of this function?! |
17 | 15 |
43 dims(grid::Grid) | 41 dims(grid::Grid) |
44 | 42 |
45 Enumerate the dimensions of the grid. | 43 Enumerate the dimensions of the grid. |
46 """ | 44 """ |
47 dims(grid::Grid) = 1:ndims(grid) | 45 dims(grid::Grid) = 1:ndims(grid) |
48 # TBD: Is this function needed? Where is it used? | 46 # TBD: Is this function needed? Where is it used |
49 | |
50 # TBD: New file grid_functions.jl? | |
51 """ | 47 """ |
52 TODO: | 48 TODO: |
53 | 49 |
54 * Mention map(f,g) if you want a concrete array | 50 * Mention map(f,g) if you want a concrete array |
55 """ | 51 """ |
61 return LazyTensors.LazyFunctionArray((I...)->f(g[I...]...), size(g)) | 57 return LazyTensors.LazyFunctionArray((I...)->f(g[I...]...), size(g)) |
62 end | 58 end |
63 end | 59 end |
64 | 60 |
65 | 61 |
66 # TODO: Explain how these are intended to be used | 62 # TODO: Explain how and where these are intended to be used |
67 _ncomponents(::Type{<:Number}) = 1 | 63 _ncomponents(::Type{<:Number}) = 1 |
68 _ncomponents(T::Type{<:SVector}) = length(T) | 64 _ncomponents(T::Type{<:SVector}) = length(T) |
69 | 65 |
70 _component_type(T::Type{<:Number}) = T | 66 _component_type(T::Type{<:Number}) = T |
71 _component_type(T::Type{<:SVector}) = eltype(T) | 67 _component_type(T::Type{<:SVector}) = eltype(T) |