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§
Trait Implementations§
Source§impl IntoIterator for MapDegree
impl IntoIterator for MapDegree
Source§impl Sequence for MapDegree
impl Sequence for MapDegree
Source§fn get(&self, index: usize) -> Option<usize>
fn get(&self, index: usize) -> Option<usize>
Returns the element at the given index or
None
. Read moreSource§fn rget(&self, rindex: usize) -> Option<Self::Item>
fn rget(&self, rindex: usize) -> Option<Self::Item>
Returns the element at the given index counting from the end or
None
. Read moreSource§fn first(&self) -> Option<Self::Item>
fn first(&self) -> Option<Self::Item>
Returns the first element or
None
if the sequence is empty. Read moreSource§fn last(&self) -> Option<Self::Item>
fn last(&self) -> Option<Self::Item>
Returns the last element or
None
if the sequence is empty. Read moreSource§fn min<'a>(&'a self) -> Option<Self::Item>
fn min<'a>(&'a self) -> Option<Self::Item>
Returns the minimum of the sequence or
None
if the sequence is empty. Read moreSource§fn max<'a>(&'a self) -> Option<Self::Item>
fn max<'a>(&'a self) -> Option<Self::Item>
Returns the maximum of the sequence or
None
if the sequence is empty. Read moreSource§fn copied<Item>(self) -> Copied<Self, Item>
fn copied<Item>(self) -> Copied<Self, Item>
Creates a sequence that copies all of its elements. Read more
Source§fn cloned<Item>(self) -> Cloned<Self, Item>
fn cloned<Item>(self) -> Cloned<Self, Item>
Creates a sequence that clones all of its elements. Read more
Source§fn map<B, F>(self, f: F) -> Map<Self, F>
fn map<B, F>(self, f: F) -> Map<Self, F>
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,
fn repeat(self, nreps: usize) -> Repeat<Self>where
Self: Sized,
Returns a sequence that repeats
nreps
times. Read moreSource§fn concat<Other>(self, other: Other) -> Option<Concat<Self, Other>>
fn concat<Other>(self, other: Other) -> Option<Concat<Self, Other>>
Returns the concatenation with another sequence. Read more
Source§fn select<Idx>(self, indices: Idx) -> Option<Select<Self, Idx>>
fn select<Idx>(self, indices: Idx) -> Option<Select<Self, Idx>>
Returns a selection of the sequence or
None
if any index is out of bounds. Read moreSource§impl<'this> SequenceTypes<'this> for MapDegree
impl<'this> SequenceTypes<'this> for MapDegree
impl Copy for MapDegree
impl Eq for MapDegree
impl StructuralPartialEq for MapDegree
impl UniqueSequence for MapDegree
Auto Trait Implementations§
impl Freeze for MapDegree
impl RefUnwindSafe for MapDegree
impl Send for MapDegree
impl Sync for MapDegree
impl Unpin for MapDegree
impl UnwindSafe for MapDegree
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<S> DerefSequence for S
impl<S> DerefSequence for S
Source§type Sequence = S
type Sequence = S
The return type of
DerefSequence::deref_sqnc()
.Source§fn deref_sqnc(&self) -> &<S as DerefSequence>::Sequence
fn deref_sqnc(&self) -> &<S as DerefSequence>::Sequence
Returns a reference to a type that implements
Sequence
.