pub struct Roots<const N: usize> { /* private fields */ }Expand description
Tagged root container for N roots.
Types are packed 3 bits per root into a u64, identical to C++ Roots<N>.
For complex conjugate pairs, slot i holds the real part and slot i+1 holds
the imaginary part; both slots are tagged Complex.
Implementations§
Source§impl<const N: usize> Roots<N>
impl<const N: usize> Roots<N>
Sourcepub fn get(&self, i: usize) -> f64
pub fn get(&self, i: usize) -> f64
Value stored at slot i.
§Out of range reads NaN, and never panics
i >= N is a caller bug either way. Returning NaN rather than
panicking is what lets this type be lifted verbatim into petir, which
targets bare metal – there a panic is not a stack trace and a non-zero
exit, it is the end of the program. NaN still surfaces the bug, just
downstream of the read.
Source§impl Roots<2>
impl Roots<2>
Source§impl Roots<3>
impl Roots<3>
Sourcepub fn uniform(t: RootType, x: f64) -> Self
pub fn uniform(t: RootType, x: f64) -> Self
All three slots get the same type and value.
C++ Roots<3>(type, x).
Sourcepub fn concat_1_2(a: Roots<1>, b: Roots<2>) -> Self
pub fn concat_1_2(a: Roots<1>, b: Roots<2>) -> Self
Concatenate Roots<1> then Roots<2>.
C++ Roots<3>(Roots<1>, Roots<2>).
Sourcepub fn concat_2_1(a: Roots<2>, b: Roots<1>) -> Self
pub fn concat_2_1(a: Roots<2>, b: Roots<1>) -> Self
Concatenate Roots<2> then Roots<1>.
C++ Roots<3>(Roots<2>, Roots<1>).