pub trait Generic1DPoly<T>:
Sized
+ AddAssign<T>
+ Add<T, Output = Self>
+ Add<Self, Output = Self>
+ AddAssign<Self>
+ SubAssign<T>
+ Sub<T, Output = Self>
+ Sub<Self, Output = Self>
+ SubAssign<Self>
+ MulAssign<T>
+ Mul<T, Output = Self>
+ Neg<Output = Self>where
T: Clone + Neg<Output = T> + AddAssign<T> + Add<T, Output = T> + Mul<T, Output = T> + MulAssign<T> + From<SmallIntegers> + Sub<T, Output = T>,{
Show 17 methods
// Required methods
fn create_zero_poly() -> Self;
fn create_monomial(
degree: DegreeType,
zero_pred: &impl Fn(&T) -> bool,
surely_fits: bool,
) -> Result<Self, MonomialError>;
fn evaluate_at(&self, t: T) -> T;
fn is_zero_polynomial(&self, zero_pred: &impl Fn(&T) -> bool) -> bool;
fn is_constant_polynomial(&self, zero_pred: &impl Fn(&T) -> bool) -> bool;
fn polynomial_degree(
&self,
zero_pred: &impl Fn(&T) -> bool,
) -> Option<DegreeType>;
fn differentiate(self) -> Result<Self, DifferentiateError>;
fn truncating_product(
&self,
rhs: &Self,
zero_pred: &impl Fn(&T) -> bool,
sure_will_cancel: bool,
) -> Option<Self>;
fn all_basis_vectors(
up_to: BasisIndexingType,
) -> Result<Vec<Self>, SubspaceError>;
fn set_basis_vector_coeff(
&mut self,
which_coeff: BasisIndexingType,
new_coeff: T,
) -> Result<(), SubspaceError>;
// Provided methods
fn evaluate_at_many<const POINT_COUNT: usize>(
&self,
ts: [T; POINT_COUNT],
) -> [T; POINT_COUNT] { ... }
fn evaluate_at_zero(&self) -> T { ... }
fn evaluate_at_one(&self) -> T { ... }
fn evaluate_at_neg_one(&self) -> T { ... }
fn evaluate_at_specifier(&self, around_here: PointSpecifier<T>) -> T { ... }
fn linear_approx(
self,
around_here: PointSpecifier<T>,
) -> Result<(T, T), DifferentiateError> { ... }
fn linear_approx_poly(
self,
around_here: PointSpecifier<T>,
) -> Result<Self, Result<DifferentiateError, MonomialError>> { ... }
}
Expand description
a subspace of the vector space T[x] where T is some ring
the subspace does not have to be closed under derivative
the common way this subspace is chosen is if we have some
natural number indexed basis and we demand to only take the
first N of these basis vectors
that is the case with SymmetricalBasisPolynomial<N>
where the basis is (1-x),x,(1-x)x,xs,… with s=x*(1-x)
that is also the case with JacobiBasisPolynomial<N,TWICE_ALPHA_PLUS_OFFSET,TWICE_BETA_PLUS_OFFSET>
where the basis is P^{alpha,beta}_n
similarly for the specializations of alpha and beta to get the other special polynomials
Required Methods§
Sourcefn create_zero_poly() -> Self
fn create_zero_poly() -> Self
the zero polynomial as an element of the subspace
Sourcefn create_monomial(
degree: DegreeType,
zero_pred: &impl Fn(&T) -> bool,
surely_fits: bool,
) -> Result<Self, MonomialError>
fn create_monomial( degree: DegreeType, zero_pred: &impl Fn(&T) -> bool, surely_fits: bool, ) -> Result<Self, MonomialError>
create x^n
as an element of V \subseteq R[x]
§Errors
the monomial we are trying to create might not be in the subspace of R[X] specified
fn evaluate_at(&self, t: T) -> T
Sourcefn is_zero_polynomial(&self, zero_pred: &impl Fn(&T) -> bool) -> bool
fn is_zero_polynomial(&self, zero_pred: &impl Fn(&T) -> bool) -> bool
is this equal to the 0 polynomial
Sourcefn polynomial_degree(
&self,
zero_pred: &impl Fn(&T) -> bool,
) -> Option<DegreeType>
fn polynomial_degree( &self, zero_pred: &impl Fn(&T) -> bool, ) -> Option<DegreeType>
what is the degree
None for the 0 polynomial to signify - \infty
Sourcefn differentiate(self) -> Result<Self, DifferentiateError>
fn differentiate(self) -> Result<Self, DifferentiateError>
attempt to differentiate this polynomial
§Errors
it might fail because the subspace does not have to be closed under d/dx
operator
Sourcefn truncating_product(
&self,
rhs: &Self,
zero_pred: &impl Fn(&T) -> bool,
sure_will_cancel: bool,
) -> Option<Self>
fn truncating_product( &self, rhs: &Self, zero_pred: &impl Fn(&T) -> bool, sure_will_cancel: bool, ) -> Option<Self>
take the product of these two polynomials
the type of Self
constrains the allowed terms
if sure_will_cancel
then even if we seem to be breaking those constraints
then ignore that problem because we are told it will cancel out and that term
will be 0 anyway
Sourcefn all_basis_vectors(
up_to: BasisIndexingType,
) -> Result<Vec<Self>, SubspaceError>
fn all_basis_vectors( up_to: BasisIndexingType, ) -> Result<Vec<Self>, SubspaceError>
assuming there is some natural number indexed basis at work behind the scenes
give the first up_to
of them as long as they are all within this subspace
§Errors
this can fail when this implicit assumption does not hold in which case NotStoredAsCoefficients
or the up_to
being too large causing us to leave the subspace, NoSuchBasisVector
Sourcefn set_basis_vector_coeff(
&mut self,
which_coeff: BasisIndexingType,
new_coeff: T,
) -> Result<(), SubspaceError>
fn set_basis_vector_coeff( &mut self, which_coeff: BasisIndexingType, new_coeff: T, ) -> Result<(), SubspaceError>
assuming there is some natural number indexed basis at work behind the scenes set the coefficient of a particular basis polynomial
§Errors
this can fail when this implicit assumption does not hold in which case NotStoredAsCoefficients
or the which_coeff
being too large causing us to leave the subspace, NoSuchBasisVector
Provided Methods§
Sourcefn evaluate_at_many<const POINT_COUNT: usize>(
&self,
ts: [T; POINT_COUNT],
) -> [T; POINT_COUNT]
fn evaluate_at_many<const POINT_COUNT: usize>( &self, ts: [T; POINT_COUNT], ) -> [T; POINT_COUNT]
evaluate the self \in V \subseteq R[x]
at many values of x
override this if there is repeated computation that is common to evaluate
the polynomial at multiple points
the default implementation does them individually without reusing any work
Sourcefn evaluate_at_zero(&self) -> T
fn evaluate_at_zero(&self) -> T
override these because there is likely a better evaluation method for these special points
Sourcefn evaluate_at_one(&self) -> T
fn evaluate_at_one(&self) -> T
override these because there is likely a better evaluation method for these special points
Sourcefn evaluate_at_neg_one(&self) -> T
fn evaluate_at_neg_one(&self) -> T
override these because there is likely a better evaluation method for these special points
fn evaluate_at_specifier(&self, around_here: PointSpecifier<T>) -> T
Sourcefn linear_approx(
self,
around_here: PointSpecifier<T>,
) -> Result<(T, T), DifferentiateError>
fn linear_approx( self, around_here: PointSpecifier<T>, ) -> Result<(T, T), DifferentiateError>
first order approximation around the given point
see override in ordinary_polynomial
for a case
when can avoid the differentiation
both avoiding that extra work and the potential source of error
§Errors
it might fail because the subspace does not have to be closed under d/dx
operator
Sourcefn linear_approx_poly(
self,
around_here: PointSpecifier<T>,
) -> Result<Self, Result<DifferentiateError, MonomialError>>
fn linear_approx_poly( self, around_here: PointSpecifier<T>, ) -> Result<Self, Result<DifferentiateError, MonomialError>>
first order approximation around the given point
§Errors
it might fail because the subspace does not have to be closed under d/dx
operator
another possibility is that the subspace does not include the linear function x
that should be very unusual, because we typically truncate
by degree and 1 is too low of a degree to fall to the chopping block
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.