Struct dzahui::solvers::fem::basis::single_variable::piecewise_polynomials_1degree::PiecewiseFirstDegreePolynomial
source · pub struct PiecewiseFirstDegreePolynomial {
polynomials: Vec<FirstDegreePolynomial>,
interval_breakpoints: Vec<f64>,
}
Expand description
General Information
A piecewise definition of a first-degree polynomial function. Carries both a vector of functions and the intervals on which each must be evaluated. It is always supposed the points in the interval are in ascending order. Giving the function in any other order will result in erratic behaviour.
Fields
polynomials
- A vector of first-degree polynomials. Must be the same length asinterval_breakpoints + 1
.interval_breakpoints
- A vector of 1D points in ascending order to know which function to evaluate. Must be the same length aspolynomials - 1
Fields§
§polynomials: Vec<FirstDegreePolynomial>
§interval_breakpoints: Vec<f64>
Implementations§
source§impl PiecewiseFirstDegreePolynomial
impl PiecewiseFirstDegreePolynomial
sourcepub fn from_values<A: IntoIterator<Item = f64>, B: IntoIterator<Item = f64>>(
coefficients: A,
independent_terms: A,
interval_breakpoints: B
) -> Result<Self, Error>
pub fn from_values<A: IntoIterator<Item = f64>, B: IntoIterator<Item = f64>>(
coefficients: A,
independent_terms: A,
interval_breakpoints: B
) -> Result<Self, Error>
General Information
Creates a new instance from raw values for coefficients and independent terms.
Parameters
coefficients
- Values that multiply variable.independent_terms
- Values that are added to variable.interval_breakpoints
- Points in ascending order to know which function to evaluate.
sourcepub fn from_constants<A: IntoIterator<Item = f64>, B: IntoIterator<Item = f64>>(
independent_terms: A,
interval_breakpoints: B
) -> Result<Self, Error>
pub fn from_constants<A: IntoIterator<Item = f64>, B: IntoIterator<Item = f64>>(
independent_terms: A,
interval_breakpoints: B
) -> Result<Self, Error>
General Information
Creates a step-like function given a vector of constants.
Parameters
independent_terms
- Vector of constants to create function.interval_breakpoints
- Points in ascending order to know which constant to return.
sourcepub fn from_polynomials<A: IntoIterator<Item = FirstDegreePolynomial>, B: IntoIterator<Item = f64>>(
polynomials: A,
interval_breakpoints: B
) -> Result<Self, Error>
pub fn from_polynomials<A: IntoIterator<Item = FirstDegreePolynomial>, B: IntoIterator<Item = f64>>(
polynomials: A,
interval_breakpoints: B
) -> Result<Self, Error>
General Information
Given a vector of polynomials, creates a piecewise function with all of them.
Parameters
polynomials
- A vector with all the polynomials to use for piecewise definition.interval_breakpoints
- Points in ascending order to know which function to evaluate.
Trait Implementations§
source§impl Differentiable1D<PiecewiseFirstDegreePolynomial> for PiecewiseFirstDegreePolynomial
impl Differentiable1D<PiecewiseFirstDegreePolynomial> for PiecewiseFirstDegreePolynomial
source§fn differentiate(&self) -> Result<PiecewiseFirstDegreePolynomial, Error>
fn differentiate(&self) -> Result<PiecewiseFirstDegreePolynomial, Error>
Specific implementation
The derivative of a piecewise first degree polynomial is a step-like function. Resulting function is obtained via differentiation of every linear polynomial in instance.
source§impl Differentiable1D<PiecewiseFirstDegreePolynomial> for PiecewiseSecondDegreePolynomial
impl Differentiable1D<PiecewiseFirstDegreePolynomial> for PiecewiseSecondDegreePolynomial
source§fn differentiate(&self) -> Result<PiecewiseFirstDegreePolynomial, Error>
fn differentiate(&self) -> Result<PiecewiseFirstDegreePolynomial, Error>
Specific implementation
The derivative of a piecewise second degree polynomial is a pieewise first degree polynomial. Resulting function is obtained via differentiation of every second degree polynomial in instance.
source§impl Function1D for PiecewiseFirstDegreePolynomial
impl Function1D for PiecewiseFirstDegreePolynomial
source§fn evaluate(&self, x: f64) -> f64
fn evaluate(&self, x: f64) -> f64
Specific implementation
Remember that number of functions = number of breakpoints + 1.
Evaluates the function supposing that interval_breakpoints
is in ascending order.
Every breakpoint coincides with a function (except for the last one). That is, given the breakpoint vector index i,
breakpoint i coincides with function i.
Evaluation is made via checking if variable x
is less than current breakpoint. If x is bigger than every breakpoint, then the last function is
evaluated.