Skip to main content

PiecewiseLegendrePolyVector

Struct PiecewiseLegendrePolyVector 

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

Vector of piecewise Legendre polynomials

Implementations§

Source§

impl PiecewiseLegendrePolyVector

Source

pub fn new(polyvec: Vec<PiecewiseLegendrePoly>) -> Result<Self, Error>

Constructor with a vector of PiecewiseLegendrePoly

§Errors
  • Error::EmptyInput if polyvec is empty
  • Error::InvalidParameter if a polynomial has other knots or another data shape than the first: the accessors of the vector (get_knots, get_data, …) describe all of them by the first
Source

pub fn polys(&self) -> &[PiecewiseLegendrePoly]

The polynomials

Source

pub fn from_3d_data( data3d: Mat3<f64>, knots: Vec<f64>, symm: Option<Vec<i32>>, ) -> Result<Self, Error>

Constructor with a 3D array, knots, and symmetry vector

data3d has the shape (polyorder, nsegments, npolys); polynomial i gets l = i and the symmetry symm[i] (0 if symm is None).

§Errors
Source

pub fn len(&self) -> usize

Number of polynomials

Source

pub fn is_empty(&self) -> bool

Whether there is no polynomial

Source

pub fn rescale_domain( &self, new_knots: Vec<f64>, new_delta_x: Option<Vec<f64>>, new_symm: Option<Vec<i32>>, ) -> Result<Self, Error>

Rescale domain for all polynomials in the vector

Creates a new PiecewiseLegendrePolyVector where each polynomial has the same data but new knots and delta_x.

§Arguments
  • new_knots - New knot points (same for all polynomials)
  • new_delta_x - Optional new segment widths
  • new_symm - Optional vector of new symmetry parameters (one per polynomial)
§Returns

New vector with rescaled domains

§Errors
Source

pub fn scale_data(&self, factor: f64) -> Self

Scale all data values by a constant factor

Multiplies the data of all polynomials by the same factor.

§Arguments
  • factor - Scaling factor to multiply all data by
§Returns

New vector with scaled data

Source

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

Get polynomial by index (immutable)

Source

pub fn get_mut(&mut self, index: usize) -> Option<&mut PiecewiseLegendrePoly>

👎Deprecated:

PiecewiseLegendrePolyVector is designed to be immutable. Use get() and create new instances for modifications.

Get polynomial by index (mutable) - deprecated, use immutable design instead

Source

pub fn slice_single(&self, index: usize) -> Option<Self>

Extract a single polynomial as a vector

Source

pub fn slice_multi(&self, indices: &[usize]) -> Result<Self, Error>

Extract multiple polynomials by indices, in the order of indices

§Errors
Source

pub fn evaluate_at(&self, x: f64) -> Vec<f64>

Evaluate all polynomials at a single point

§Panics

Panics if x is outside the domain of a polynomial or NaN; see Self::try_evaluate_at.

Source

pub fn try_evaluate_at(&self, x: f64) -> Result<Vec<f64>, Error>

Self::evaluate_at returning an error instead of panicking

§Errors

Error::OutOfDomain if x is outside the domain of a polynomial or NaN

Source

pub fn evaluate_at_many(&self, xs: &[f64]) -> Mat<f64>

Evaluate all polynomials at multiple points

The result has the shape (size, xs.len()).

§Panics

Panics if a point is outside the domain of a polynomial or NaN; see Self::try_evaluate_at_many.

Source

pub fn try_evaluate_at_many(&self, xs: &[f64]) -> Result<Mat<f64>, Error>

Self::evaluate_at_many returning an error instead of panicking

§Errors

Error::OutOfDomain for the first point of xs that is outside the domain of a polynomial or NaN; every point is checked before any is evaluated

Source

pub fn xmin(&self) -> f64

Source

pub fn xmax(&self) -> f64

Source

pub fn knots(&self, tolerance: Option<f64>) -> Vec<f64>

The knots of all the polynomials, merged where closer than tolerance (1e-10 by default)

Source

pub fn delta_x(&self) -> Vec<f64>

Segment lengths of the first polynomial

Source

pub fn polyorder(&self) -> usize

Number of Legendre coefficients per segment (degree + 1)

Source

pub fn norms(&self) -> &[f64]

Normalization of the Legendre polynomials on each segment

Source

pub fn symm(&self) -> Vec<i32>

Parity of each polynomial: 1 even, -1 odd, 0 none

Source

pub fn data(&self) -> Mat3<f64>

Legendre coefficients as an nsegments × polyorder × npolys array: element [s, l, i] is the coefficient of degree l on segment s of polynomial i

The first two axes are in the opposite order to those of PiecewiseLegendrePoly::data and of the array that Self::from_3d_data takes.

Source

pub fn roots(&self, tolerance: Option<f64>) -> Vec<f64>

Find roots of all polynomials

Source

pub fn last(&self) -> &PiecewiseLegendrePoly

Get reference to last polynomial

C++ equivalent: u.polyvec.back()

Source

pub fn nroots(&self, tolerance: Option<f64>) -> usize

Get the number of roots

Trait Implementations§

Source§

impl Clone for PiecewiseLegendrePolyVector

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 Debug for PiecewiseLegendrePolyVector

Source§

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

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

impl Index<usize> for PiecewiseLegendrePolyVector

Source§

type Output = PiecewiseLegendrePoly

The returned type after indexing.
Source§

fn index(&self, index: usize) -> &Self::Output

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

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

impl<SS, SP> SupersetOf<SS> for SP
where SS: SubsetOf<SP>,

§

fn to_subset(&self) -> Option<SS>

The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more
§

fn is_in_subset(&self) -> bool

Checks if self is actually part of its subset T (and can be converted to it).
§

fn to_subset_unchecked(&self) -> SS

Use with care! Same as self.to_subset but without any property checks. Always succeeds.
§

fn from_subset(element: &SS) -> SP

The inclusion map: converts self to the equivalent element of its superset.
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.