Mercurial > repos > public > sbplib_julia
comparison src/Grids/grid.jl @ 1270:dcbac783e4c1 refactor/grids
Factor out functions for getting the type and number of components in a type
| author | Jonatan Werpers <jonatan@werpers.com> |
|---|---|
| date | Sat, 25 Feb 2023 22:42:16 +0100 |
| parents | 20f42cf0800c |
| children | 3637daad71e8 |
comparison
equal
deleted
inserted
replaced
| 1269:20f42cf0800c | 1270:dcbac783e4c1 |
|---|---|
| 62 Return one of the components of gfun as a grid function. | 62 Return one of the components of gfun as a grid function. |
| 63 """ | 63 """ |
| 64 # Should it be lazy? Could it be a view? | 64 # Should it be lazy? Could it be a view? |
| 65 function getcomponent(gfun, I::Vararg{Int}) end | 65 function getcomponent(gfun, I::Vararg{Int}) end |
| 66 # function getcomponent(gfun, s::Symbol) end ? | 66 # function getcomponent(gfun, s::Symbol) end ? |
| 67 | |
| 68 | |
| 69 # TODO: Explain how these are intended to be used | |
| 70 _ncomponents(::Type{<:Number}) = 1 | |
| 71 _ncomponents(T::Type{<:SVector}) = length(T) | |
| 72 | |
| 73 _component_type(T::Type{<:Number}) = T | |
| 74 _component_type(T::Type{<:SVector}) = eltype(T) |
