1 /*! |
1 /*! |
2 Second order polynomical (P2) models on real intervals and planar 2D simplices. |
2 Second order polynomical (P2) models on real intervals and planar 2D simplices. |
3 */ |
3 */ |
4 |
4 |
|
5 use serde::{Serialize, Deserialize}; |
5 use crate::types::*; |
6 use crate::types::*; |
6 use crate::loc::Loc; |
7 use crate::loc::Loc; |
7 use crate::sets::{Set,NPolygon,SpannedHalfspace}; |
8 use crate::sets::{Set,NPolygon,SpannedHalfspace}; |
8 use crate::linsolve::*; |
9 use crate::linsolve::*; |
9 use crate::euclidean::Euclidean; |
10 use crate::euclidean::Euclidean; |
14 |
15 |
15 /// Type for simplices of arbitrary dimension `N`. |
16 /// Type for simplices of arbitrary dimension `N`. |
16 /// |
17 /// |
17 /// The type parameter `D` indicates the number of nodes. (Rust's const generics do not currently |
18 /// The type parameter `D` indicates the number of nodes. (Rust's const generics do not currently |
18 /// allow its automatic calculation from `N`.) |
19 /// allow its automatic calculation from `N`.) |
|
20 #[derive(Debug, Clone, Serialize, Deserialize)] |
|
21 #[serde(bound( |
|
22 serialize = "[Loc<F, N>; D] : Serialize", |
|
23 deserialize = "[Loc<F, N>; D] : for<'a> Deserialize<'a>", |
|
24 ))] |
19 pub struct Simplex<F : Float, const N : usize, const D : usize>(pub [Loc<F, N>; D]); |
25 pub struct Simplex<F : Float, const N : usize, const D : usize>(pub [Loc<F, N>; D]); |
20 /// A two-dimensional planar simplex |
26 /// A two-dimensional planar simplex |
21 pub type PlanarSimplex<F> = Simplex<F, 2, 3>; |
27 pub type PlanarSimplex<F> = Simplex<F, 2, 3>; |
22 /// A real interval |
28 /// A real interval |
23 pub type RealInterval<F> = Simplex<F, 1, 2>; |
29 pub type RealInterval<F> = Simplex<F, 1, 2>; |
117 /// Generates a second order polynomial model of the function `g` on `Self`. |
123 /// Generates a second order polynomial model of the function `g` on `Self`. |
118 fn p2_model<G : Fn(&Loc<F, N>) -> F>(&self, g : G) -> Self::Model; |
124 fn p2_model<G : Fn(&Loc<F, N>) -> F>(&self, g : G) -> Self::Model; |
119 } |
125 } |
120 |
126 |
121 /// A local second order polynomical model of dimension `N` with `E` edges |
127 /// A local second order polynomical model of dimension `N` with `E` edges |
|
128 #[derive(Serialize, Deserialize, Debug, Clone)] |
|
129 #[serde(bound( |
|
130 serialize = "F : Serialize, |
|
131 Loc<F, N> : Serialize, |
|
132 Loc<F, E> : Serialize", |
|
133 deserialize = "F : for<'a> Deserialize<'a>, |
|
134 Loc<F, N> : for<'a> Deserialize<'a>, |
|
135 Loc<F, E> : for<'a> Deserialize<'a>", |
|
136 ))] |
122 pub struct P2LocalModel<F : Num, const N : usize, const E : usize/*, const V : usize, const Q : usize*/> { |
137 pub struct P2LocalModel<F : Num, const N : usize, const E : usize/*, const V : usize, const Q : usize*/> { |
123 a0 : F, |
138 a0 : F, |
124 a1 : Loc<F, N>, |
139 a1 : Loc<F, N>, |
125 a2 : Loc<F, E>, |
140 a2 : Loc<F, E>, |
126 //node_values : Loc<F, V>, |
141 //node_values : Loc<F, V>, |