pub enum ExpressionClass {
Integer,
Rational,
UnivariatePolynomial {
var: Symbol,
degree: i64,
},
MultivariatePolynomial {
vars: Vec<Symbol>,
total_degree: i64,
},
RationalFunction,
Transcendental,
Symbolic,
}Expand description
Classification of expression type for algorithm routing
Used to select optimal algorithms based on expression structure. The classification determines which specialized algorithms to use for operations like GCD, factorization, and simplification.
§Examples
use mathhook_core::core::expression::classification::ExpressionClass;
use mathhook_core::core::polynomial::PolynomialClassification;
use mathhook_core::{expr, symbol};
let x = symbol!(x);
let poly = expr!(x ^ 2);
match poly.classify() {
ExpressionClass::UnivariatePolynomial { var, degree } => {
assert_eq!(degree, 2);
}
_ => panic!("Expected univariate polynomial"),
}Variants§
Integer
Integer constant
Pure integer values like 0, 1, -5, 42. Fast-path for integer arithmetic.
Rational
Rational number
Fractions like 1/2, 3/4, -7/11. Uses rational arithmetic algorithms.
UnivariatePolynomial
Univariate polynomial in one variable
Polynomials like x^2 + 2x + 1, 3y^5 - y. Enables specialized univariate algorithms (Euclidean GCD, etc.).
MultivariatePolynomial
Multivariate polynomial in multiple variables
Polynomials like x^2 + xy + y^2, xyz + 1. Uses multivariate algorithms (Buchberger, etc.).
Fields
RationalFunction
Rational function (ratio of polynomials)
Expressions like (x+1)/(x-1), 1/(x^2+1). Requires special handling for simplification.
Transcendental
Contains transcendental functions (sin, cos, exp, log)
Expressions involving sin, cos, tan, exp, log, etc. Limited algebraic simplification possible.
Symbolic
Symbolic expression that doesn’t fit other categories
General symbolic expressions that don’t match any of the more specific classifications.
Trait Implementations§
Source§impl Clone for ExpressionClass
impl Clone for ExpressionClass
Source§fn clone(&self) -> ExpressionClass
fn clone(&self) -> ExpressionClass
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for ExpressionClass
impl Debug for ExpressionClass
Source§impl PartialEq for ExpressionClass
impl PartialEq for ExpressionClass
impl StructuralPartialEq for ExpressionClass
Auto Trait Implementations§
impl Freeze for ExpressionClass
impl RefUnwindSafe for ExpressionClass
impl Send for ExpressionClass
impl Sync for ExpressionClass
impl Unpin for ExpressionClass
impl UnwindSafe for ExpressionClass
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more