Skip to main content

Roots

Struct Roots 

Source
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>

Source

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

pub fn root_type(&self, i: usize) -> RootType

Root type at slot i.

Source

pub fn set_type(&mut self, i: usize, t: RootType)

Overwrite the type at slot i.

Source§

impl Roots<1>

Source

pub fn new(t: RootType, x: f64) -> Self

Single root with the given type and value.

Source§

impl Roots<2>

Source

pub fn from_pair(a: Roots<1>, b: Roots<1>) -> Self

Concatenate two single roots. C++ Roots<2>(Roots<1>, Roots<1>).

Source

pub fn with_tail(head: Roots<1>, t: RootType, x: f64) -> Self

Roots<1> followed by one additional root. C++ Roots<2>(Roots<1>, type, x).

Source

pub fn both(r: Roots<1>) -> Self

Duplicate a single root into both slots. C++ Roots<2>(r, r).

Source§

impl Roots<3>

Source

pub fn uniform(t: RootType, x: f64) -> Self

All three slots get the same type and value. C++ Roots<3>(type, x).

Source

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>).

Source

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>).

Source

pub fn with_tail(head: Roots<2>, t: RootType, x: f64) -> Self

Roots<2> followed by one additional root. C++ Roots<3>(Roots<2>, type, x).

Trait Implementations§

Source§

impl<const N: usize> Clone for Roots<N>

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<const N: usize> Copy for Roots<N>

Source§

impl<const N: usize> Debug for Roots<N>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<const N: usize> Index<usize> for Roots<N>

Source§

type Output = f64

The returned type after indexing.
Source§

fn index(&self, i: usize) -> &f64

Performs the indexing (container[index]) operation. Read more

Auto Trait Implementations§

§

impl<const N: usize> Freeze for Roots<N>
where [f64; N]: Freeze,

§

impl<const N: usize> RefUnwindSafe for Roots<N>
where [f64; N]: RefUnwindSafe,

§

impl<const N: usize> Send for Roots<N>
where [f64; N]: Send,

§

impl<const N: usize> Sync for Roots<N>
where [f64; N]: Sync,

§

impl<const N: usize> Unpin for Roots<N>
where [f64; N]: Unpin,

§

impl<const N: usize> UnsafeUnpin for Roots<N>
where [f64; N]: UnsafeUnpin,

§

impl<const N: usize> UnwindSafe for Roots<N>
where [f64; N]: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.