Struct MapDegree

Source
pub struct MapDegree { /* private fields */ }
Expand description

Index map relating coefficients from one degree to another.

For each coefficient for a polynomial in nvars variables and of degree from_degree, this sequence gives the index of the same coefficient (the same powers) for a polynomial with degree to_degree, where to_degree must be larger or equal to from_degree.

The indices are strict monotonic increasing.

§Example

The following example shows how to map a vector of coefficients from one degree to another.

use nutils_poly::{self, MapDegree};
use sqnc::traits::*;

// Coefficients for a polynomial in two variables and of degree one.
let coeffs1 = [4, 5, 6];
// Index map from degree two to degree three for a polynomial in one variable.
let map = MapDegree::new(2, 1, 2).unwrap();
// Apply the map to obtain a coefficients vector for a polynomial of degree two.
let mut coeffs2 = [0; nutils_poly::ncoeffs(2, 2)];
coeffs2.as_mut_sqnc().select(map).unwrap().assign(coeffs1);
assert_eq!(coeffs2, [0, 0, 4, 0, 5, 6]);
// Both polynomials evaluate to the same value.
assert_eq!(
    nutils_poly::eval(coeffs1, &[2, 3], 1)?,
    nutils_poly::eval(coeffs2, &[2, 3], 2)?,
);

Implementations§

Source§

impl MapDegree

Source

pub fn new(nvars: usize, from_degree: Power, to_degree: Power) -> Option<Self>

Returns an index map or None if to_degree is smaller than from_degree.

Trait Implementations§

Source§

impl Clone for MapDegree

Source§

fn clone(&self) -> MapDegree

Returns a duplicate of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for MapDegree

Source§

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

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

impl Hash for MapDegree

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl IntoIterator for MapDegree

Source§

type Item = usize

The type of the elements being iterated over.
Source§

type IntoIter = IntoIter<MapDegree>

Which kind of iterator are we turning this into?
Source§

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more
Source§

impl PartialEq for MapDegree

Source§

fn eq(&self, other: &MapDegree) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

const fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Sequence for MapDegree

Source§

fn len(&self) -> usize

Returns the length of the sequence. Read more
Source§

fn get(&self, index: usize) -> Option<usize>

Returns the element at the given index or None. Read more
Source§

fn iter(&self) -> Iter<'_, Self>

Returns an iterator that returns elements. Read more
Source§

fn is_empty(&self) -> bool

Returns true if the sequence is empty. Read more
Source§

fn rget(&self, rindex: usize) -> Option<Self::Item>

Returns the element at the given index counting from the end or None. Read more
Source§

fn first(&self) -> Option<Self::Item>

Returns the first element or None if the sequence is empty. Read more
Source§

fn last(&self) -> Option<Self::Item>

Returns the last element or None if the sequence is empty. Read more
Source§

fn min<'a>(&'a self) -> Option<Self::Item>
where Self::Item: Ord,

Returns the minimum of the sequence or None if the sequence is empty. Read more
Source§

fn max<'a>(&'a self) -> Option<Self::Item>
where Self::Item: Ord,

Returns the maximum of the sequence or None if the sequence is empty. Read more
Source§

fn copied<Item>(self) -> Copied<Self, Item>
where Self: Sized + for<'a> SequenceTypes<'a, Item = &'a Item>, Item: Copy,

Creates a sequence that copies all of its elements. Read more
Source§

fn cloned<Item>(self) -> Cloned<Self, Item>
where Self: Sized + for<'a> SequenceTypes<'a, Item = &'a Item>, Item: Clone,

Creates a sequence that clones all of its elements. Read more
Source§

fn map<B, F>(self, f: F) -> Map<Self, F>
where Self: Sized, F: for<'a> Fn(Self::Item) -> B,

Takes a closure and creates a sequence that calls the closure on each element. Read more
Source§

fn repeat(self, nreps: usize) -> Repeat<Self>
where Self: Sized,

Returns a sequence that repeats nreps times. Read more
Source§

fn rev(self) -> Rev<Self>
where Self: Sized,

Returns the reverted sequence. Read more
Source§

fn concat<Other>(self, other: Other) -> Option<Concat<Self, Other>>
where Self: Sized, Other: Sequence<Item = Self::Item> + for<'a> SequenceTypes<'a>,

Returns the concatenation with another sequence. Read more
Source§

fn select<Idx>(self, indices: Idx) -> Option<Select<Self, Idx>>
where Self: Sized, Idx: Sequence<Item = usize> + for<'a> SequenceTypes<'a>,

Returns a selection of the sequence or None if any index is out of bounds. Read more
Source§

fn zip<Other>(self, other: Other) -> Option<Zip<Self, Other>>
where Self: Sized, Other: Sequence,

‘Zips up’ two sequences into a single sequence of pairs. Read more
Source§

fn as_sqnc(&self) -> Wrapper<&Self, ((),)>

Returns a Sequence that references self. Read more
Source§

impl<'this> SequenceTypes<'this> for MapDegree

Source§

type Item = usize

The element type of a Sequence.
Source§

type Iter = Iter<'this, MapDegree>

The return type of Sequence::iter.
Source§

impl Copy for MapDegree

Source§

impl Eq for MapDegree

Source§

impl StructuralPartialEq for MapDegree

Source§

impl UniqueSequence for MapDegree

Auto Trait Implementations§

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<S> DerefSequence for S
where S: Sequence + ?Sized,

Source§

type Sequence = S

The return type of DerefSequence::deref_sqnc().
Source§

fn deref_sqnc(&self) -> &<S as DerefSequence>::Sequence

Returns a reference to a type that implements Sequence.
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<S, OwnedItem> SequenceOwned for S
where S: Sequence<Item = OwnedItem> + for<'a> SequenceTypes<'a> + ?Sized,

Source§

type OwnedItem = OwnedItem

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 = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.