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));

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);

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);

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);

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);

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));

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

The element type.

The container used by the tensor.

Returns a mutable reference to the enclosed tensor.

The element type.

The container used by the tensor.

Returns a reference to the enclosed tensor.

The element type of the collection container.

The type of the collection container.

Consumes self and returns an owned tensor.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

Should always be Self

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.