Skip to main content

Poly

Struct Poly 

Source
pub struct Poly<C: Ring> { /* private fields */ }
Expand description

稀疏有序多项式。exps 长度恒为 nvars × nterms,第 i 项指数为 exps[i*nvars..(i+1)*nvars];项按环的项序严格升序,系数零的项不存在。

Implementations§

Source§

impl Poly<Rational>

Source

pub fn factor_univariate(&self) -> (Rational, Vec<(Poly<Rational>, u32)>)

一元 ℚ[x] 因式分解:返回(常数内容, [(本原因子, 重数)]), 满足 cont · Π 因子^重数 == self。因子本原、首项正;输出确定性。

Source§

impl Poly<Rational>

Source

pub fn factor(&self) -> (Rational, Vec<(Self, u32)>)

多变元因式分解:返回(ℚ 常数内容, [(本原因子, 重数)]), cont·Π 因子^重数 == self。1 变元完全;2 变元完全;≥3 变元 部分分解(内容 + 平方自由;因子可能仍可约)。

Source§

impl Poly<Rational>

Source

pub fn div_rem(&self, divs: &[&Self]) -> (Vec<Self>, Self)

主单项式除法。确定性:每步消去被除式当前最大主单项式, 多除子按给定次序匹配。

Source

pub fn exact_div(&self, g: &Self) -> Option<Self>

精确除法:g 整除 self 时返回商,否则 None。

Source

pub fn gcd(&self, other: &Self) -> Self

最大公因子(本原规范化:ℚ 内容归一、主项系数为正)。 gcd(0, g) = normalize(g);gcd(c₁, c₂) = 1(ℚ 上常数互素)。

Source

pub fn normalize_primitive(&self) -> Self

本原规范化:除以 ℚ 内容使分子整系、分子 gcd 为 1,主项(项序最大 项)系数取正。零多项式原样。

Source§

impl<C: Ring> Poly<C>

Source

pub fn from_terms<I: IntoIterator<Item = (Vec<u32>, C)>>( ring: Arc<PolyRing>, terms: I, ) -> Self

由(指数向量, 系数)序列构造,构造即规范化:合并同类项、去零、排序。

Source

pub fn zero(ring: Arc<PolyRing>) -> Self

Source

pub fn constant(ring: Arc<PolyRing>, c: C) -> Self

Source

pub fn ring(&self) -> &Arc<PolyRing>

Source

pub fn nterms(&self) -> usize

Source

pub fn is_zero(&self) -> bool

Source

pub fn is_constant(&self) -> bool

Source

pub fn degree(&self) -> u64

总次数(零多项式为 0)。

Source

pub fn terms(&self) -> impl Iterator<Item = (&[u32], &C)>

稳定项迭代器:次序 = 项序 = 序列化/打印/代码生成次序(D6)。

Source

pub fn add(&self, other: &Self) -> Self

Source

pub fn sub(&self, other: &Self) -> Self

Source

pub fn neg(&self) -> Self

Source

pub fn mul(&self, other: &Self) -> Self

Source

pub fn pow(&self, e: u32) -> Self

Source

pub fn deriv(&self, idx: usize) -> Self

对第 idx 个变元求偏导。

Source

pub fn eval(&self, vals: &[C]) -> C

在给定点求值(点分量按变元次序)。长度不符属编程错误。

Source§

impl Poly<Rational>

Source

pub fn eval_f64(&self, vals: &[f64]) -> f64

f64 求值(系数精确转 f64 后按项求和)——数值交叉验证用。

Trait Implementations§

Source§

impl<C: Clone + Ring> Clone for Poly<C>

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<C: Ring + Debug> Debug for Poly<C>

Source§

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

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

impl<C: Eq + Ring> Eq for Poly<C>

Source§

impl<C: PartialEq + Ring> PartialEq for Poly<C>

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl<C: PartialEq + Ring> StructuralPartialEq for Poly<C>

Auto Trait Implementations§

§

impl<C> Freeze for Poly<C>
where Vec<C>: Freeze,

§

impl<C> RefUnwindSafe for Poly<C>
where Vec<C>: RefUnwindSafe,

§

impl<C> Send for Poly<C>
where Vec<C>: Send,

§

impl<C> Sync for Poly<C>
where Vec<C>: Sync,

§

impl<C> Unpin for Poly<C>
where Vec<C>: Unpin,

§

impl<C> UnsafeUnpin for Poly<C>
where Vec<C>: UnsafeUnpin,

§

impl<C> UnwindSafe for Poly<C>
where Vec<C>: UnwindSafe,

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