Struct concrete_core::math::polynomial::PolynomialList[][src]

pub struct PolynomialList<Cont> { /* fields omitted */ }

A generic polynomial list type.

This type represents a set of polynomial of homogeneous degree.

Example

use concrete_core::math::polynomial::{PolynomialList, PolynomialSize, PolynomialCount};
let list = PolynomialList::from_container(vec![1u8,2,3,4,5,6,7,8], PolynomialSize(2));
assert_eq!(list.polynomial_count(), PolynomialCount(4));
assert_eq!(list.polynomial_size(), PolynomialSize(2));

Implementations

impl<Coef> PolynomialList<Vec<Coef>> where
    Coef: Copy
[src]

pub fn allocate(
    value: Coef,
    number: PolynomialCount,
    size: PolynomialSize
) -> Self
[src]

Allocates a new polynomial list.

Example

use concrete_core::math::polynomial::{PolynomialList, PolynomialSize, PolynomialCount};
let list = PolynomialList::allocate(1u8, PolynomialCount(10), PolynomialSize(2));
assert_eq!(list.polynomial_count(), PolynomialCount(10));
assert_eq!(list.polynomial_size(), PolynomialSize(2));

impl<Cont> PolynomialList<Cont>[src]

pub fn from_container(
    cont: Cont,
    poly_size: PolynomialSize
) -> PolynomialList<Cont> where
    Cont: AsRefSlice
[src]

Creates a polynomial list from a list of values.

Example

use concrete_core::math::polynomial::{PolynomialList, PolynomialSize, PolynomialCount};
let list = PolynomialList::from_container(vec![1u8,2,3,4,5,6,7,8], PolynomialSize(2));
assert_eq!(list.polynomial_count(), PolynomialCount(4));
assert_eq!(list.polynomial_size(), PolynomialSize(2));

pub fn polynomial_count(&self) -> PolynomialCount where
    Self: AsRefTensor
[src]

Returns the number of polynomials in the list.

Example

use concrete_core::math::polynomial::{PolynomialList, PolynomialSize, PolynomialCount};
let list = PolynomialList::allocate(1u8, PolynomialCount(10), PolynomialSize(2));
assert_eq!(list.polynomial_count(), PolynomialCount(10));

pub fn polynomial_size(&self) -> PolynomialSize[src]

Returns the size of the polynomials in the list.

Example

use concrete_core::math::polynomial::{PolynomialList, PolynomialSize, PolynomialCount};
let list = PolynomialList::allocate(1u8, PolynomialCount(10), PolynomialSize(2));
assert_eq!(list.polynomial_size(), PolynomialSize(2));

pub fn get_polynomial(&self, n: usize) -> Polynomial<&[Self::Element]> where
    Self: AsRefTensor
[src]

Returns a reference to the n-th polynomial of the list.

Example

use concrete_core::math::polynomial::{PolynomialList, PolynomialSize, PolynomialCount, MonomialDegree};
let list = PolynomialList::from_container(vec![1u8,2,3,4,5,6,7,8], PolynomialSize(2));
let poly = list.get_polynomial(2);
assert_eq!(*poly.get_monomial(MonomialDegree(0)).get_coefficient(), 5u8);
assert_eq!(*poly.get_monomial(MonomialDegree(1)).get_coefficient(), 6u8);

pub fn get_mut_polynomial(
    &mut self,
    n: usize
) -> Polynomial<&mut [Self::Element]> where
    Self: AsMutTensor
[src]

Returns a mutable reference to the n-th polynomial of the list.

Example

use concrete_core::math::polynomial::{PolynomialList, PolynomialSize, MonomialDegree};
let mut list = PolynomialList::from_container(vec![1u8,2,3,4,5,6,7,8], PolynomialSize(2));
let mut poly = list.get_mut_polynomial(2);
poly.get_mut_monomial(MonomialDegree(0)).set_coefficient(10u8);
poly.get_mut_monomial(MonomialDegree(1)).set_coefficient(11u8);
let poly = list.get_polynomial(2);
assert_eq!(*poly.get_monomial(MonomialDegree(0)).get_coefficient(), 10u8);
assert_eq!(*poly.get_monomial(MonomialDegree(1)).get_coefficient(), 11u8);

pub fn polynomial_iter(
    &self
) -> impl Iterator<Item = Polynomial<&[Self::Element]>> where
    Self: AsRefTensor
[src]

Returns an iterator over references to the polynomials contained in the list.

Example

use concrete_core::math::polynomial::{PolynomialList, PolynomialSize, MonomialDegree};
let mut list = PolynomialList::from_container(vec![1u8,2,3,4,5,6,7,8], PolynomialSize(2));
for polynomial in list.polynomial_iter(){
    assert_eq!(polynomial.polynomial_size(), PolynomialSize(2));
}
assert_eq!(list.polynomial_iter().count(), 4);

pub fn polynomial_iter_mut(
    &mut self
) -> impl Iterator<Item = Polynomial<&mut [Self::Element]>> where
    Self: AsMutTensor
[src]

Returns an iterator over mutable references to the polynomials contained in the list.

Example

use concrete_core::math::polynomial::{PolynomialList, PolynomialSize, MonomialDegree};
let mut list = PolynomialList::from_container(vec![1u8,2,3,4,5,6,7,8], PolynomialSize(2));
for mut polynomial in list.polynomial_iter_mut(){
    polynomial.get_mut_monomial(MonomialDegree(0)).set_coefficient(10u8);
    assert_eq!(polynomial.polynomial_size(), PolynomialSize(2));
}
for polynomial in list.polynomial_iter(){
    assert_eq!(*polynomial.get_monomial(MonomialDegree(0)).get_coefficient(), 10u8);
}
assert_eq!(list.polynomial_iter_mut().count(), 4);

pub fn update_with_wrapping_monic_monomial_mul<Coef>(
    &mut self,
    monomial_degree: MonomialDegree
) where
    Self: AsMutTensor<Element = Coef>,
    Coef: UnsignedInteger
[src]

Multiplies (mod $(X^N+1)$), all the polynomials of the list with a unit monomial of a given degree.

Examples

use concrete_core::math::polynomial::{MonomialDegree, PolynomialList, PolynomialSize};
let mut list = PolynomialList::from_container(vec![1u8,2,3,4,5,6], PolynomialSize(3));
list.update_with_wrapping_monic_monomial_mul(MonomialDegree(2));
let poly = list.get_polynomial(0);
assert_eq!(*poly.get_monomial(MonomialDegree(0)).get_coefficient(), 254);
assert_eq!(*poly.get_monomial(MonomialDegree(1)).get_coefficient(), 253);
assert_eq!(*poly.get_monomial(MonomialDegree(2)).get_coefficient(), 1);

pub fn update_with_wrapping_monic_monomial_div<Coef>(
    &mut self,
    monomial_degree: MonomialDegree
) where
    Self: AsMutTensor<Element = Coef>,
    Coef: UnsignedInteger
[src]

Divides (mod $(X^N+1)$), all the polynomials of the list with a unit monomial of a given degree.

Examples

use concrete_core::math::polynomial::{MonomialDegree, PolynomialList, PolynomialSize};
let mut list = PolynomialList::from_container(vec![1u8,2,3,4,5,6], PolynomialSize(3));
list.update_with_wrapping_monic_monomial_div(MonomialDegree(2));
let poly = list.get_polynomial(0);
assert_eq!(*poly.get_monomial(MonomialDegree(0)).get_coefficient(), 3);
assert_eq!(*poly.get_monomial(MonomialDegree(1)).get_coefficient(), 255);
assert_eq!(*poly.get_monomial(MonomialDegree(2)).get_coefficient(), 254);

Trait Implementations

impl<Element> AsMutTensor for PolynomialList<Vec<Element>>[src]

type Element = Element

The element type.

type Container = Vec<Element>

The container used by the tensor.

impl<Element> AsMutTensor for PolynomialList<[Element; 1]>[src]

type Element = Element

The element type.

type Container = [Element; 1]

The container used by the tensor.

impl<Element> AsMutTensor for PolynomialList<AlignedVec<Element>>[src]

type Element = Element

The element type.

type Container = AlignedVec<Element>

The container used by the tensor.

impl<'a, Element> AsMutTensor for PolynomialList<&'a mut [Element]>[src]

type Element = Element

The element type.

type Container = &'a mut [Element]

The container used by the tensor.

impl<Element> AsRefTensor for PolynomialList<Vec<Element>>[src]

type Element = Element

The element type.

type Container = Vec<Element>

The container used by the tensor.

impl<Element> AsRefTensor for PolynomialList<AlignedVec<Element>>[src]

type Element = Element

The element type.

type Container = AlignedVec<Element>

The container used by the tensor.

impl<Element> AsRefTensor for PolynomialList<[Element; 1]>[src]

type Element = Element

The element type.

type Container = [Element; 1]

The container used by the tensor.

impl<'a, Element> AsRefTensor for PolynomialList<&'a [Element]>[src]

type Element = Element

The element type.

type Container = &'a [Element]

The container used by the tensor.

impl<'a, Element> AsRefTensor for PolynomialList<&'a mut [Element]>[src]

type Element = Element

The element type.

type Container = &'a mut [Element]

The container used by the tensor.

impl<Element> IntoTensor for PolynomialList<Vec<Element>>[src]

type Element = Element

The element type of the collection container.

type Container = Vec<Element>

The type of the collection container.

impl<Element> IntoTensor for PolynomialList<AlignedVec<Element>>[src]

type Element = Element

The element type of the collection container.

type Container = AlignedVec<Element>

The type of the collection container.

impl<Element> IntoTensor for PolynomialList<[Element; 1]>[src]

type Element = Element

The element type of the collection container.

type Container = [Element; 1]

The type of the collection container.

impl<'a, Element> IntoTensor for PolynomialList<&'a [Element]>[src]

type Element = Element

The element type of the collection container.

type Container = &'a [Element]

The type of the collection container.

impl<'a, Element> IntoTensor for PolynomialList<&'a mut [Element]>[src]

type Element = Element

The element type of the collection container.

type Container = &'a mut [Element]

The type of the collection container.

impl<Cont: PartialEq> PartialEq<PolynomialList<Cont>> for PolynomialList<Cont>[src]

impl<Cont> StructuralPartialEq for PolynomialList<Cont>[src]

Auto Trait Implementations

impl<Cont> RefUnwindSafe for PolynomialList<Cont> where
    Cont: RefUnwindSafe

impl<Cont> Send for PolynomialList<Cont> where
    Cont: Send

impl<Cont> Sync for PolynomialList<Cont> where
    Cont: Sync

impl<Cont> Unpin for PolynomialList<Cont> where
    Cont: Unpin

impl<Cont> UnwindSafe for PolynomialList<Cont> where
    Cont: UnwindSafe

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<Input, Output> CastInto<Output> for Input where
    Output: CastFrom<Input>, 
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.