Struct concrete::plaintext::Plaintext[][src]

pub struct Plaintext {
    pub encoders: Vec<Encoder>,
    pub plaintexts: Vec<Torus>,
    pub nb_plaintexts: usize,
}
Expand description

Structure describing a list of plaintext values with their respective Encoder

Attributes

  • encoder - the list of the encoders (one for each plaintext)
  • plaintexts - the list of plaintexts
  • nb_plaintexts - the size of both lists

Fields

encoders: Vec<Encoder>plaintexts: Vec<Torus>nb_plaintexts: usize

Implementations

Instantiate a new empty Plaintext (set to zero) of a certain size

Argument
  • nb_plaintexts - the number of plaintext that would be in the Plaintext instance
Output
  • a new instantiation of an empty Plaintext (set to zero) of a certain size
Example
use concrete::Plaintext;
let nb_ct: usize = 100;
let plaintexts = Plaintext::zero(nb_ct);

Instantiate a new Plaintext filled with plaintexts

Argument
  • messages- a list of messages as u64
  • encoder- an encoder
Output
  • a new instance of Plaintext containing the plaintext of each message with respect to encoder
Example
use concrete::{Encoder, Plaintext};

// create an Encoder instance where messages are in the interval [-5, 5[
let encoder = Encoder::new(-5., 5., 8, 0).unwrap();

// create a list of messages in our interval
let messages: Vec<f64> = vec![-3.2, 4.3, 0.12, -1.1, 2.78];

// create a new Plaintext instance filled with the plaintexts we want
let pt = Plaintext::encode(&messages, &encoder).unwrap();

// print the Plaintext
println!("ec = {}", pt);

Decode one single plaintext (from the list of plaintexts in this Plaintext instance) according to its own encoder

Arguments
  • nth - the index of the plaintext to decode
Output
  • the decoded value as a f64
Example
use concrete::{Encoder, Plaintext};

// create an Encoder instance where messages are in the interval [-5, 5[
let encoder = Encoder::new(-5., 5., 8, 0).unwrap();

// create a list of messages in our interval
let messages: Vec<f64> = vec![-3.2, 4.3, 0.12, -1.1, 2.78];

// create a new Plaintext instance filled with the plaintexts we want
let pt = Plaintext::encode(&messages, &encoder).unwrap();

let n: usize = 2;
let m = pt.decode_nth(n).unwrap();

Encode several messages according to the list of Encoders in this instance

Arguments
  • messages - a list of messages as f64
Example
use concrete::{Encoder, Plaintext};

// create a list of 5 Encoder instances where messages are in the interval [-5, 5[
let encoders = vec![Encoder::new(-5., 5., 8, 0).unwrap(); 5];

// create a list of messages in our interval
let messages: Vec<f64> = vec![-3.2, 4.3, 0.12, -1.1, 2.78];

// create a new Plaintext instance that can contain 5 plaintexts
let mut ec = Plaintext::zero(5);

// set the encoders
ec.set_encoders(&encoders);

// encode our messages
ec.encode_inplace(&messages);

Decode every plaintexts in this Plaintext instance according to its list of Encoders

Example
use concrete::{Encoder, Plaintext};

// create an Encoder instance where messages are in the interval [-5, 5[
let encoder = Encoder::new(-5., 5., 8, 0).unwrap();

// create a list of messages in our interval
let messages: Vec<f64> = vec![-3.2, 4.3, 0.12, -1.1, 2.78];

// create a new Plaintext instance filled with the plaintexts we want
let mut ec = Plaintext::encode(&messages, &encoder).unwrap();

let new_msgs: Vec<f64> = ec.decode().unwrap();

Set the encoder list of this instance from an input list of encoders

Argument
  • encoders - a list of Encoder elements
Example
use concrete::{Encoder, Plaintext};

let nb_ct = 100;
let mut pt = Plaintext::zero(nb_ct);
let encoders = vec![Encoder::zero(); nb_ct];
// setting the encoders
pt.set_encoders(&encoders);

Set the encoder list of this instance from a unique input encoder

Argument
  • encoder - an Encoder
Example
use concrete::{Encoder, Plaintext};

let nb_ct = 100;
let mut pt = Plaintext::zero(nb_ct);
let encoder = Encoder::zero();
// setting the encoders
pt.set_encoders_from_one(&encoder);

Set the nth encoder of the encoder list of this instance from an input encoder

Argument
  • encoder - an Encoder
Example
use concrete::{Encoder, Plaintext};

let nb_ct = 100;
let mut pt = Plaintext::zero(nb_ct);
let encoder_1 = Encoder::zero();
let encoder_2 = Encoder::zero();
let n: usize = 2;
// setting the encoders
pt.set_encoders_from_one(&encoder_1);
pt.set_nth_encoder(n, &encoder_2);

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Deserialize this value from the given Serde deserializer. Read more

Print needed pieces of information about this instance

Formats the value using the given formatter. Read more

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

Serialize this value into the given Serde serializer. Read more

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 resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

Uses borrowed data to replace owned data, usually by cloning. Read more

Converts the given value to a String. Read more

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.