Struct concrete_core::crypto::encoding::PlaintextList [−][src]
pub struct PlaintextList<Cont> { /* fields omitted */ }
Expand description
A list of plaintexts
Implementations
Allocates a new list of plaintexts.
Example
use concrete_commons::parameters::PlaintextCount;
use concrete_core::crypto::encoding::*;
let plain_list = PlaintextList::allocate(1 as u8, PlaintextCount(100));
assert_eq!(plain_list.count(), PlaintextCount(100));
Creates a plaintext list from a container of values.
Example
use concrete_commons::parameters::PlaintextCount;
use concrete_core::crypto::encoding::*;
let plain_list = PlaintextList::from_container(vec![1 as u8; 100]);
assert_eq!(plain_list.count(), PlaintextCount(100));
Returns the number of elements in the list.
Example
use concrete_commons::parameters::PlaintextCount;
use concrete_core::crypto::encoding::*;
let plain_list = PlaintextList::from_container(vec![1 as u8; 100]);
assert_eq!(plain_list.count(), PlaintextCount(100));
pub fn plaintext_iter(
&self
) -> impl Iterator<Item = &Plaintext<<Self as AsRefTensor>::Element>> where
Self: AsRefTensor,
<Self as AsRefTensor>::Element: Numeric,
pub fn plaintext_iter(
&self
) -> impl Iterator<Item = &Plaintext<<Self as AsRefTensor>::Element>> where
Self: AsRefTensor,
<Self as AsRefTensor>::Element: Numeric,
Creates an iterator over borrowed plaintexts.
Example
use concrete_core::crypto::encoding::*;
let plain_list = PlaintextList::from_container(vec![1 as u8; 100]);
plain_list.plaintext_iter().for_each(|a| assert_eq!(a.0, 1));
assert_eq!(plain_list.plaintext_iter().count(), 100);
pub fn plaintext_iter_mut(
&mut self
) -> impl Iterator<Item = &mut Plaintext<<Self as AsMutTensor>::Element>> where
Self: AsMutTensor,
<Self as AsMutTensor>::Element: Numeric,
pub fn plaintext_iter_mut(
&mut self
) -> impl Iterator<Item = &mut Plaintext<<Self as AsMutTensor>::Element>> where
Self: AsMutTensor,
<Self as AsMutTensor>::Element: Numeric,
Creates an iterator over mutably borrowed plaintexts.
Example
use concrete_core::crypto::encoding::*;
let mut plain_list = PlaintextList::from_container(vec![1 as u8; 100]);
plain_list
.plaintext_iter_mut()
.for_each(|a| *a = Plaintext(2));
plain_list.plaintext_iter().for_each(|a| assert_eq!(a.0, 2));
assert_eq!(plain_list.plaintext_iter_mut().count(), 100);
pub fn sublist_iter(
&self,
count: PlaintextCount
) -> impl Iterator<Item = PlaintextList<&[<Self as AsRefTensor>::Element]>> where
Self: AsRefTensor,
pub fn sublist_iter(
&self,
count: PlaintextCount
) -> impl Iterator<Item = PlaintextList<&[<Self as AsRefTensor>::Element]>> where
Self: AsRefTensor,
Creates an iterator over borrowed sub-lists.
Example
use concrete_commons::parameters::PlaintextCount;
use concrete_core::crypto::encoding::*;
let mut plain_list = PlaintextList::from_container(vec![1 as u8; 100]);
plain_list
.sublist_iter(PlaintextCount(10))
.for_each(|a| assert_eq!(a.count(), PlaintextCount(10)));
assert_eq!(plain_list.sublist_iter(PlaintextCount(10)).count(), 10);
pub fn sublist_iter_mut(
&mut self,
count: PlaintextCount
) -> impl Iterator<Item = PlaintextList<&mut [<Self as AsMutTensor>::Element]>> where
Self: AsMutTensor,
pub fn sublist_iter_mut(
&mut self,
count: PlaintextCount
) -> impl Iterator<Item = PlaintextList<&mut [<Self as AsMutTensor>::Element]>> where
Self: AsMutTensor,
Creates an iterator over mutably borrowed sub-lists.
Example
use concrete_commons::parameters::PlaintextCount;
use concrete_core::crypto::encoding::*;
let mut plain_list = PlaintextList::from_container(vec![1 as u8; 100]);
plain_list
.sublist_iter_mut(PlaintextCount(10))
.for_each(|mut a| a.plaintext_iter_mut().for_each(|b| *b = Plaintext(2)));
plain_list
.plaintext_iter()
.for_each(|a| assert_eq!(*a, Plaintext(2)));
assert_eq!(plain_list.sublist_iter_mut(PlaintextCount(10)).count(), 10);
pub fn as_polynomial(&self) -> Polynomial<&[<Self as AsRefTensor>::Element]> where
Self: AsRefTensor,
pub fn as_polynomial(&self) -> Polynomial<&[<Self as AsRefTensor>::Element]> where
Self: AsRefTensor,
Return a borrowed polynomial whose coefficients are the plaintexts of this list.
Example
use concrete_commons::parameters::PolynomialSize;
use concrete_core::crypto::encoding::*;
let plain_list = PlaintextList::from_container(vec![1 as u8; 100]);
let plain_poly = plain_list.as_polynomial();
assert_eq!(plain_poly.polynomial_size(), PolynomialSize(100));
pub fn as_mut_polynomial(
&mut self
) -> Polynomial<&mut [<Self as AsRefTensor>::Element]> where
Self: AsMutTensor,
pub fn as_mut_polynomial(
&mut self
) -> Polynomial<&mut [<Self as AsRefTensor>::Element]> where
Self: AsMutTensor,
Return a mutably borrowed polynomial whose coefficients are the plaintexts of this list.
Example
use concrete_commons::parameters::PolynomialSize;
use concrete_core::crypto::encoding::*;
let mut plain_list = PlaintextList::from_container(vec![1 as u8; 100]);
let mut plain_poly = plain_list.as_mut_polynomial();
assert_eq!(plain_poly.polynomial_size(), PolynomialSize(100));
Trait Implementations
impl<Element, Cont> AsMutTensor for PlaintextList<Cont> where
Cont: AsMutSlice<Element = Element>,
impl<Element, Cont> AsMutTensor for PlaintextList<Cont> where
Cont: AsMutSlice<Element = Element>,
impl<Element, Cont> AsRefTensor for PlaintextList<Cont> where
Cont: AsRefSlice<Element = Element>,
impl<Element, Cont> AsRefTensor for PlaintextList<Cont> where
Cont: AsRefSlice<Element = Element>,
type Element = <Cont as AsRefSlice>::Element
type Element = <Cont as AsRefSlice>::Element
The element type of the collection container.
type Container = Cont
type Container = Cont
The type of the collection container.
Consumes self
and returns an owned tensor.