Mercurial > repos > public > sbplib_julia
diff src/Grids/manifolds.jl @ 1780:8ecdc5bb46be feature/grids/manifolds
Allow mixed types in constructors for HyperBox and Simplex
author | Jonatan Werpers <jonatan@werpers.com> |
---|---|
date | Mon, 16 Sep 2024 08:58:12 +0200 |
parents | 2a8a2b52a112 |
children | a73838c9ef94 |
line wrap: on
line diff
--- a/src/Grids/manifolds.jl Mon Sep 16 08:33:43 2024 +0200 +++ b/src/Grids/manifolds.jl Mon Sep 16 08:58:12 2024 +0200 @@ -42,7 +42,8 @@ end function HyperBox(a,b) - T = SVector{length(a)} + ET = promote_type(eltype(a),eltype(b)) + T = SVector{length(a),ET} HyperBox(convert(T,a), convert(T,b)) end @@ -62,7 +63,12 @@ verticies::NTuple{NV,SVector{D,T}} end -Simplex(verticies::Vararg{AbstractArray}) = Simplex(Tuple(SVector(v...) for v ∈ verticies)) +function Simplex(verticies::Vararg{AbstractArray}) + ET = mapreduce(eltype,promote_type,verticies) + T = SVector{length(verticies[1]),ET} + + return Simplex(Tuple(convert(T,v) for v ∈ verticies)) +end verticies(s::Simplex) = s.verticies