Struct Polynomial

Source
pub struct Polynomial<P: PrimeMod> { /* private fields */ }
Expand description

$\mathbb{F}_p$上の多項式

Implementations§

Source§

impl<P: PrimeMod> Polynomial<P>

Source

pub fn zero() -> Self

零多項式を得る。

Source

pub fn constant(a: ConstModInt<P>) -> Self

定数項のみをもつ多項式を生成する。

Source

pub fn coeff_of(&self, i: usize) -> ConstModInt<P>

$x^i$の係数を得る。

Source

pub fn eval(&self, p: ConstModInt<P>) -> ConstModInt<P>

多項式に値pを代入した結果を求める。

Source

pub fn len(&self) -> usize

内部のVecの長さを返す。

Source

pub fn is_empty(&self) -> bool

項数が0のときtrueを返す。

Source

pub fn shrink(&mut self)

係数が0の高次項を縮める。

Source

pub fn get_until(&self, t: usize) -> Self

len()を超えないように、先頭t項をもつ多項式を返す。

Source

pub fn deg(&self) -> Option<usize>

多項式の次数を返す。

selfが零多項式のときはNoneを返す。

Time complexity $O(n)$

Source

pub fn scale(&mut self, k: ConstModInt<P>)

多項式をk倍する。

Source

pub fn differentiate(&mut self)

多項式を微分する。

Source

pub fn integrate(&mut self)

多項式を積分する。

Source

pub fn shift_higher(&mut self, k: usize)

係数をk次だけ高次側にずらす。ただし、$x^n$の項以降は無視する。

$(a_0 + a_1 x + a_2 x^2 + \ldots + a_{n-1} x^{n-1}) \times x^k \pmod {x^n}$

Source

pub fn shift_lower(&mut self, k: usize)

係数をk次だけ低次側にずらす。ただし、負の次数の項は無視する。

Source

pub fn prod(a: Vec<Self>) -> Self

多項式の列の積を計算する。

Source

pub fn pow(self, p: u64) -> Self

多項式の$p$乗を計算する。

Source

pub fn sq(self) -> Self

多項式aの2乗を返す。

Source

pub fn inv(self, n: usize) -> Self

Source

pub fn divrem(self, b: Self) -> (Self, Self)

多項式aの多項式bによる商と剰余を返す。

Trait Implementations§

Source§

impl<P: PrimeMod> Add for Polynomial<P>

Source§

type Output = Polynomial<P>

The resulting type after applying the + operator.
Source§

fn add(self, b: Self) -> Self

Performs the + operation. Read more
Source§

impl<P: PrimeMod> AddAssign for Polynomial<P>

Source§

fn add_assign(&mut self, b: Self)

Performs the += operation. Read more
Source§

impl<P: PrimeMod> AsMut<Vec<ConstModInt<P>>> for Polynomial<P>

Source§

fn as_mut(&mut self) -> &mut Vec<ConstModInt<P>>

Converts this type into a mutable reference of the (usually inferred) input type.
Source§

impl<P: PrimeMod> AsRef<[ConstModInt<P>]> for Polynomial<P>

Source§

fn as_ref(&self) -> &[ConstModInt<P>]

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl<P: Clone + PrimeMod> Clone for Polynomial<P>

Source§

fn clone(&self) -> Polynomial<P>

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<P: Debug + PrimeMod> Debug for Polynomial<P>

Source§

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

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

impl<P: Default + PrimeMod> Default for Polynomial<P>

Source§

fn default() -> Polynomial<P>

Returns the “default value” for a type. Read more
Source§

impl<P: PrimeMod> Div for Polynomial<P>

Source§

type Output = Polynomial<P>

The resulting type after applying the / operator.
Source§

fn div(self, rhs: Self) -> Self::Output

Performs the / operation. Read more
Source§

impl<P: PrimeMod> DivAssign for Polynomial<P>

Source§

fn div_assign(&mut self, rhs: Self)

Performs the /= operation. Read more
Source§

impl<P: PrimeMod> FpsExp for Polynomial<P>

Source§

type Output = Polynomial<P>

戻り値の型
Source§

fn fps_exp(self) -> Result<Self::Output, &'static str>

$f(x) = \sum_0^{n-1} a_ix^i$について、$\exp (f(x))$の先頭$n$項を求める。
Source§

impl<P: PrimeMod> FpsInv for Polynomial<P>

Source§

type Output = Polynomial<P>

戻り値の型
Source§

fn fps_inv(self) -> Result<Self::Output, &'static str>

$f(x) = \sum_0^{n-1} a_ix^i$について、$\frac{1}{f(x)}$の先頭$n$項を求める。
Source§

impl<P: PrimeMod> FpsLog for Polynomial<P>

Source§

type Output = Polynomial<P>

戻り値の型
Source§

fn fps_log(self) -> Result<Self::Output, &'static str>

$f(x) = \sum_0^{n-1} a_ix^i$について、$\log (f(x))$の先頭$n$項を求める。
Source§

impl<P: PrimeMod> FpsPow for Polynomial<P>

Source§

type Output = Polynomial<P>

戻り値の型
Source§

fn fps_pow(self, m: u64) -> Result<Self::Output, &'static str>

$f(x) = \sum_0^{n-1} a_ix^i$について、$(f(x))^m$の先頭$n$項を求める。
Source§

impl<P: PrimeMod> FpsSqrt for Polynomial<P>

Source§

type Output = Polynomial<P>

戻り値の型
Source§

fn fps_sqrt(self) -> Result<Self::Output, &'static str>

$f(x) = \sum_0^{n-1} a_ix^i$について、$\sqrt{f(x)}$の先頭$n$項を求める。
Source§

impl<P: PrimeMod> From<Polynomial<P>> for Vec<ConstModInt<P>>

Source§

fn from(value: Polynomial<P>) -> Self

Converts to this type from the input type.
Source§

impl<T, P: PrimeMod> From<Vec<T>> for Polynomial<P>
where T: Into<ConstModInt<P>>,

Source§

fn from(value: Vec<T>) -> Self

Converts to this type from the input type.
Source§

impl<P: PrimeMod> Index<usize> for Polynomial<P>

Source§

type Output = ConstModInt<P>

The returned type after indexing.
Source§

fn index(&self, index: usize) -> &Self::Output

Performs the indexing (container[index]) operation. Read more
Source§

impl<P: PrimeMod> IndexMut<usize> for Polynomial<P>

Source§

fn index_mut(&mut self, index: usize) -> &mut Self::Output

Performs the mutable indexing (container[index]) operation. Read more
Source§

impl<P: PrimeMod> Mul for Polynomial<P>

Source§

type Output = Polynomial<P>

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: Self) -> Self::Output

Performs the * operation. Read more
Source§

impl<P: PrimeMod> MulAssign for Polynomial<P>

Source§

fn mul_assign(&mut self, rhs: Self)

Performs the *= operation. Read more
Source§

impl<P: PrimeMod> MultipointEval for Polynomial<P>

Source§

type Value = ConstModInt<P>

多項式の係数の型
Source§

fn multipoint_eval(self, p: Vec<Self::Value>) -> Vec<Self::Value>

多項式の多点評価 Read more
Source§

impl<P: PrimeMod> PartialEq for Polynomial<P>

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<P: PrimeMod> Rem for Polynomial<P>

Source§

type Output = Polynomial<P>

The resulting type after applying the % operator.
Source§

fn rem(self, rhs: Self) -> Self::Output

Performs the % operation. Read more
Source§

impl<P: PrimeMod> RemAssign for Polynomial<P>

Source§

fn rem_assign(&mut self, rhs: Self)

Performs the %= operation. Read more
Source§

impl<P: PrimeMod> Sub for Polynomial<P>

Source§

type Output = Polynomial<P>

The resulting type after applying the - operator.
Source§

fn sub(self, b: Self) -> Self

Performs the - operation. Read more
Source§

impl<P: PrimeMod> SubAssign for Polynomial<P>

Source§

fn sub_assign(&mut self, b: Self)

Performs the -= operation. Read more
Source§

impl<P: PrimeMod> TaylorShift for Polynomial<P>

Source§

type Value = ConstModInt<P>

多項式の係数の型
Source§

fn taylor_shift(self, c: Self::Value) -> Self

多項式 p = $f(x) = a_0 + a_1x + \cdots + a_nx^n$に対して、
多項式 $f(x + c) = a_0 + a_1(x + c) + \cdots + a_n(x + c)^n = b_0 + b_0x + \cdots + b_nx^n$ を満たす、数列{$b_i$}を求める。
Source§

impl<P: PrimeMod> Eq for Polynomial<P>

Auto Trait Implementations§

§

impl<P> Freeze for Polynomial<P>

§

impl<P> RefUnwindSafe for Polynomial<P>
where P: RefUnwindSafe,

§

impl<P> Send for Polynomial<P>
where P: Send,

§

impl<P> Sync for Polynomial<P>
where P: Sync,

§

impl<P> Unpin for Polynomial<P>
where P: Unpin,

§

impl<P> UnwindSafe for Polynomial<P>
where P: 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 = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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

impl<T> Arithmetic for T
where T: Add<Output = T> + Mul<Output = T> + Div<Output = T> + Sub<Output = T> + AddAssign + SubAssign + MulAssign + DivAssign,