Mercurial > repos > public > sbplib_julia
comparison src/Grids/parameter_space.jl @ 1994:55e5d9f921ac feature/grids/parameter_spaces/in
White space
author | Jonatan Werpers <jonatan@werpers.com> |
---|---|
date | Fri, 25 Apr 2025 08:12:45 +0200 |
parents | 2912975ddc2f |
children | 889c18ad56bf |
comparison
equal
deleted
inserted
replaced
1993:2912975ddc2f | 1994:55e5d9f921ac |
---|---|
16 [`Simplex`](@ref). | 16 [`Simplex`](@ref). |
17 """ | 17 """ |
18 abstract type ParameterSpace{D} end | 18 abstract type ParameterSpace{D} end |
19 Base.ndims(::ParameterSpace{D}) where D = D | 19 Base.ndims(::ParameterSpace{D}) where D = D |
20 | 20 |
21 | |
22 @doc """ | 21 @doc """ |
23 in(x, S::ParameterSpace) | 22 in(x, S::ParameterSpace) |
24 ∈(x, S::ParameterSpace) | 23 ∈(x, S::ParameterSpace) |
25 | 24 |
26 Test if the point `x` is in the parameter space `S`. | 25 Test if the point `x` is in the parameter space `S`. |
163 T = SVector{length(verticies[1]),ET} | 162 T = SVector{length(verticies[1]),ET} |
164 | 163 |
165 return Simplex(Tuple(convert(T,v) for v ∈ verticies)) | 164 return Simplex(Tuple(convert(T,v) for v ∈ verticies)) |
166 end | 165 end |
167 | 166 |
168 | |
169 function Base.in(x, s::Simplex) | 167 function Base.in(x, s::Simplex) |
170 v₁ = s.verticies[1] | 168 v₁ = s.verticies[1] |
171 V = map(s.verticies) do v | 169 V = map(s.verticies) do v |
172 v - v₁ | 170 v - v₁ |
173 end | 171 end |
182 λ_full = (1 - sum(λ), λ...) # Tuple of length NV | 180 λ_full = (1 - sum(λ), λ...) # Tuple of length NV |
183 | 181 |
184 all(λᵢ -> zero(λᵢ) ≤ λᵢ ≤ one(λᵢ), λ_full) | 182 all(λᵢ -> zero(λᵢ) ≤ λᵢ ≤ one(λᵢ), λ_full) |
185 end | 183 end |
186 | 184 |
187 | |
188 """ | 185 """ |
189 verticies(s::Simplex) | 186 verticies(s::Simplex) |
190 | 187 |
191 Verticies of `s`. | 188 Verticies of `s`. |
192 """ | 189 """ |