Mercurial > repos > public > sbplib_julia
comparison src/Grids/grid.jl @ 1475:76b190ca9a27 feature/grids/componentview
Generalize component_type
author | Jonatan Werpers <jonatan@werpers.com> |
---|---|
date | Fri, 01 Dec 2023 13:36:47 +0100 |
parents | 276c38a48aac |
children | 62f9d0387a2a |
comparison
equal
deleted
inserted
replaced
1474:276c38a48aac | 1475:76b190ca9a27 |
---|---|
31 """ | 31 """ |
32 coordinate_size(::Type{<:Grid{T}}) where T = _ncomponents(T) | 32 coordinate_size(::Type{<:Grid{T}}) where T = _ncomponents(T) |
33 coordinate_size(g::Grid) = coordinate_size(typeof(g)) # TBD: Name of this function?! | 33 coordinate_size(g::Grid) = coordinate_size(typeof(g)) # TBD: Name of this function?! |
34 | 34 |
35 """ | 35 """ |
36 component_type(g) | 36 component_type(gf) |
37 | 37 |
38 The type of the components of the coordinate vector of `Grid` `g`. | 38 The type of the components of `gf`. |
39 """ | 39 """ |
40 component_type(::Type{<:Grid{T}}) where T = eltype(T) #TBD: removable? | |
41 component_type(g::Grid) = component_type(typeof(g)) | |
42 component_type(T::Type) = eltype(eltype(T)) | 40 component_type(T::Type) = eltype(eltype(T)) |
43 component_type(t) = component_type(typeof(t)) | 41 component_type(t) = component_type(typeof(t)) |
44 | 42 |
45 function componentview(gf, component_index...) | 43 function componentview(gf, component_index...) |
46 A = reinterpret(reshape, component_type(gf), gf) | 44 A = reinterpret(reshape, component_type(gf), gf) |