[−][src]Struct rug_polynomial::ModPoly
Implementations
impl ModPoly
[src]
pub fn new(modulus: Integer) -> Self
[src]
A new polynomial, equal to zero.
pub fn with_capacity(modulus: Integer, n: usize) -> Self
[src]
A new polynomial, equal to zero, with room for n
coefficients.
pub fn interpolate_from_mul_subgroup(
ys: Vec<Integer>,
m: Integer,
w: &Integer
) -> Self
[src]
ys: Vec<Integer>,
m: Integer,
w: &Integer
) -> Self
Interpolate a polynomial which agrees with the given values over a multiplicative subgroup
of the prime field with modulus m
.
Let n
be a power of two and the order of the multiplicative subgroup generated by w
modulo m
. Let ys
be a vector of values at 1
, w
, w^2
, ...
Returns a polynomial f
, such that for i
in 0..n
, f(w^i) = ys[i] mod m
.
Panics
If n
is not a power of two, or if w
does not generate a subgroup of order n
.
Examples
use rug_polynomial::*; use rug::Integer; let m = Integer::from(5); let w = Integer::from(2); let ys: Vec<Integer> = vec![2, 3, 0, 4].into_iter().map(Integer::from).collect(); let p = ModPoly::interpolate_from_mul_subgroup(ys, m, &w); debug_assert_eq!(p.len(), 2); debug_assert_eq!(p.get_coefficient(0), Integer::from(1)); debug_assert_eq!(p.get_coefficient(1), Integer::from(1));
pub fn with_roots(xs: impl IntoIterator<Item = Integer>, m: &Integer) -> Self
[src]
Returns the minimal-degree monic polynomial with the given roots.
Example
use rug_polynomial::*; use rug::Integer; let p = ModPoly::with_roots(vec![0, 1].into_iter().map(Integer::from), &Integer::from(5)); debug_assert_eq!(p.len(), 3); debug_assert_eq!(p.get_coefficient(0), Integer::from(0)); debug_assert_eq!(p.get_coefficient(1), Integer::from(4)); debug_assert_eq!(p.get_coefficient(2), Integer::from(1));
pub fn reserve(&mut self, n: usize)
[src]
Reallocates the polynomial to have room for n
coefficients. Truncates the polynomial if
it has more than n
coefficients.
pub fn modulus(&self) -> &Integer
[src]
Get the modulus of this polynomial.
pub fn get_coefficient(&self, i: usize) -> Integer
[src]
Get the i
th coefficient
pub fn set_coefficient(&mut self, i: usize, c: &Integer)
[src]
Set the i
th coefficient to be c
pub fn set_coefficient_ui(&mut self, i: usize, c: usize)
[src]
Set the i
th coefficient to be c
pub fn len(&self) -> usize
[src]
The number of coefficients in the polynomial. One more than the degree.
pub fn neg(&mut self)
[src]
self = -self
pub fn add(&mut self, other: &Self)
[src]
self = self + other
pub fn sub(&mut self, other: &Self)
[src]
self = self - other
pub fn sub_from(&mut self, other: &Self)
[src]
self = other - self
pub fn mul(&mut self, other: &Self)
[src]
self = self * other
pub fn divrem(&self, other: &Self) -> (ModPoly, ModPoly)
[src]
pub fn div(&mut self, other: &Self)
[src]
self = self / other
pub fn div_from(&mut self, other: &Self)
[src]
self = other / self
pub fn rem(&mut self, other: &Self)
[src]
self = self % other
pub fn rem_from(&mut self, other: &Self)
[src]
self = other % self
pub fn sqr(&mut self)
[src]
self = self * self
Trait Implementations
impl<'_> Add<&'_ ModPoly> for ModPoly
[src]
type Output = ModPoly
The resulting type after applying the +
operator.
fn add(self, rhs: &ModPoly) -> ModPoly
[src]
impl Add<ModPoly> for ModPoly
[src]
type Output = ModPoly
The resulting type after applying the +
operator.
fn add(self, rhs: ModPoly) -> ModPoly
[src]
impl<'_> Add<ModPoly> for &'_ ModPoly
[src]
type Output = ModPoly
The resulting type after applying the +
operator.
fn add(self, rhs: ModPoly) -> ModPoly
[src]
impl<'_> AddAssign<&'_ ModPoly> for ModPoly
[src]
fn add_assign(&mut self, rhs: &ModPoly)
[src]
impl AddAssign<ModPoly> for ModPoly
[src]
fn add_assign(&mut self, rhs: ModPoly)
[src]
impl Clone for ModPoly
[src]
fn clone(&self) -> Self
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl Debug for ModPoly
[src]
impl Display for ModPoly
[src]
impl<'_> Div<&'_ ModPoly> for ModPoly
[src]
type Output = ModPoly
The resulting type after applying the /
operator.
fn div(self, rhs: &ModPoly) -> ModPoly
[src]
impl Div<ModPoly> for ModPoly
[src]
type Output = ModPoly
The resulting type after applying the /
operator.
fn div(self, rhs: ModPoly) -> ModPoly
[src]
impl<'_> Div<ModPoly> for &'_ ModPoly
[src]
type Output = ModPoly
The resulting type after applying the /
operator.
fn div(self, rhs: ModPoly) -> ModPoly
[src]
impl<'_> DivAssign<&'_ ModPoly> for ModPoly
[src]
fn div_assign(&mut self, rhs: &ModPoly)
[src]
impl DivAssign<ModPoly> for ModPoly
[src]
fn div_assign(&mut self, rhs: ModPoly)
[src]
impl Drop for ModPoly
[src]
impl Eq for ModPoly
[src]
impl<'_> Mul<&'_ ModPoly> for ModPoly
[src]
type Output = ModPoly
The resulting type after applying the *
operator.
fn mul(self, rhs: &ModPoly) -> ModPoly
[src]
impl Mul<ModPoly> for ModPoly
[src]
type Output = ModPoly
The resulting type after applying the *
operator.
fn mul(self, rhs: ModPoly) -> ModPoly
[src]
impl<'_> Mul<ModPoly> for &'_ ModPoly
[src]
type Output = ModPoly
The resulting type after applying the *
operator.
fn mul(self, rhs: ModPoly) -> ModPoly
[src]
impl<'_> MulAssign<&'_ ModPoly> for ModPoly
[src]
fn mul_assign(&mut self, rhs: &ModPoly)
[src]
impl MulAssign<ModPoly> for ModPoly
[src]
fn mul_assign(&mut self, rhs: ModPoly)
[src]
impl PartialEq<ModPoly> for ModPoly
[src]
impl<'_> Rem<&'_ ModPoly> for ModPoly
[src]
type Output = ModPoly
The resulting type after applying the %
operator.
fn rem(self, rhs: &ModPoly) -> ModPoly
[src]
impl Rem<ModPoly> for ModPoly
[src]
type Output = ModPoly
The resulting type after applying the %
operator.
fn rem(self, rhs: ModPoly) -> ModPoly
[src]
impl<'_> Rem<ModPoly> for &'_ ModPoly
[src]
type Output = ModPoly
The resulting type after applying the %
operator.
fn rem(self, rhs: ModPoly) -> ModPoly
[src]
impl<'_> RemAssign<&'_ ModPoly> for ModPoly
[src]
fn rem_assign(&mut self, rhs: &ModPoly)
[src]
impl RemAssign<ModPoly> for ModPoly
[src]
fn rem_assign(&mut self, rhs: ModPoly)
[src]
impl<'_> Sub<&'_ ModPoly> for ModPoly
[src]
type Output = ModPoly
The resulting type after applying the -
operator.
fn sub(self, rhs: &ModPoly) -> ModPoly
[src]
impl Sub<ModPoly> for ModPoly
[src]
type Output = ModPoly
The resulting type after applying the -
operator.
fn sub(self, rhs: ModPoly) -> ModPoly
[src]
impl<'_> Sub<ModPoly> for &'_ ModPoly
[src]
type Output = ModPoly
The resulting type after applying the -
operator.
fn sub(self, rhs: ModPoly) -> ModPoly
[src]
impl<'_> SubAssign<&'_ ModPoly> for ModPoly
[src]
fn sub_assign(&mut self, rhs: &ModPoly)
[src]
impl SubAssign<ModPoly> for ModPoly
[src]
fn sub_assign(&mut self, rhs: ModPoly)
[src]
Auto Trait Implementations
impl RefUnwindSafe for ModPoly
impl !Send for ModPoly
impl !Sync for ModPoly
impl Unpin for ModPoly
impl UnwindSafe for ModPoly
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Az for T
[src]
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> CheckedAs for T
[src]
fn checked_as<Dst>(self) -> Option<Dst> where
T: CheckedCast<Dst>,
[src]
T: CheckedCast<Dst>,
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> OverflowingAs for T
[src]
fn overflowing_as<Dst>(self) -> (Dst, bool) where
T: OverflowingCast<Dst>,
[src]
T: OverflowingCast<Dst>,
impl<T> SaturatingAs for T
[src]
fn saturating_as<Dst>(self) -> Dst where
T: SaturatingCast<Dst>,
[src]
T: SaturatingCast<Dst>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T> ToString for T where
T: Display + ?Sized,
[src]
T: Display + ?Sized,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> WrappingAs for T
[src]
fn wrapping_as<Dst>(self) -> Dst where
T: WrappingCast<Dst>,
[src]
T: WrappingCast<Dst>,