pub trait PolynomialGcdOps: PolynomialClassification {
// Required methods
fn polynomial_gcd(
&self,
other: &Self,
) -> Result<Expression, PolynomialError>;
fn polynomial_lcm(
&self,
other: &Self,
) -> Result<Expression, PolynomialError>;
fn polynomial_cofactors(
&self,
other: &Self,
) -> Result<(Expression, Expression, Expression), PolynomialError>;
}Expand description
Trait for polynomial GCD operations
Provides methods for computing GCD, LCM, and cofactors of polynomial expressions. The implementation uses IntPoly fast-path when possible.
§Examples
ⓘ
use mathhook_core::core::polynomial::PolynomialGcdOps;
use mathhook_core::core::Expression;
use mathhook_core::{symbol, expr};
let x = symbol!(x);
// x^2 - 1 = (x-1)(x+1)
let p1 = expr!((x ^ 2) - 1);
// x - 1
let p2 = expr!(x - 1);
let gcd = p1.polynomial_gcd(&p2).unwrap();
// GCD divides both polynomialsRequired Methods§
Sourcefn polynomial_gcd(&self, other: &Self) -> Result<Expression, PolynomialError>
fn polynomial_gcd(&self, other: &Self) -> Result<Expression, PolynomialError>
Sourcefn polynomial_lcm(&self, other: &Self) -> Result<Expression, PolynomialError>
fn polynomial_lcm(&self, other: &Self) -> Result<Expression, PolynomialError>
Compute LCM of two polynomials
Returns the least common multiple of self and other.
Sourcefn polynomial_cofactors(
&self,
other: &Self,
) -> Result<(Expression, Expression, Expression), PolynomialError>
fn polynomial_cofactors( &self, other: &Self, ) -> Result<(Expression, Expression, Expression), PolynomialError>
Compute GCD and cofactors
Returns tuple (gcd, self/gcd, other/gcd).
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.