[−][src]Trait concrete_lib::operators::math::polynomial_tensor::PolynomialTensor
Required methods
fn compute_binary_multisum(
t_res: &mut [Self],
t_torus: &[Self],
t_bool_key: &[Self],
polynomial_size: usize
)
t_res: &mut [Self],
t_torus: &[Self],
t_bool_key: &[Self],
polynomial_size: usize
)
fn sub_binary_multisum(
t_res: &mut [Self],
t_torus: &[Self],
t_bool: &[Self],
polynomial_size: usize
)
t_res: &mut [Self],
t_torus: &[Self],
t_bool: &[Self],
polynomial_size: usize
)
fn add_binary_multisum(
t_res: &mut [Self],
t_torus: &[Self],
t_bool: &[Self],
polynomial_size: usize
)
t_res: &mut [Self],
t_torus: &[Self],
t_bool: &[Self],
polynomial_size: usize
)
fn compute_binary_multisum_monome(
t_torus: &[Self],
t_bool_key: &[Self],
polynomial_size: usize,
dimension: usize,
monomial: usize
) -> Self
t_torus: &[Self],
t_bool_key: &[Self],
polynomial_size: usize,
dimension: usize,
monomial: usize
) -> Self
fn multiply_by_monomial(
res: &mut [Self],
monomial_degree: usize,
polynomial_size: usize
)
res: &mut [Self],
monomial_degree: usize,
polynomial_size: usize
)
fn divide_by_monomial(
res: &mut [Self],
monomial_degree: usize,
polynomial_size: usize
)
res: &mut [Self],
monomial_degree: usize,
polynomial_size: usize
)
fn print_torus(poly: &[Self], polynomial_size: usize)
fn to_string_torus(poly: &[Self], polynomial_size: usize) -> String
fn to_string_binary_representation(
poly: &[Self],
polynomial_size: usize
) -> String
poly: &[Self],
polynomial_size: usize
) -> String
fn named_print(poly: &[Self], polynomial_size: usize, name: String)
fn to_string_(poly: &[Self], polynomial_size: usize) -> String
fn signed_decompose_one_level(
sign_decomp: &mut [Self],
carries: &mut [Self],
polynomial: &[Self],
base_log: usize,
dec_level: usize
)
sign_decomp: &mut [Self],
carries: &mut [Self],
polynomial: &[Self],
base_log: usize,
dec_level: usize
)
Implementations on Foreign Types
impl PolynomialTensor for u32
[src]
fn compute_binary_multisum(
t_res: &mut [u32],
t_torus: &[u32],
t_bool_key: &[u32],
polynomial_size: usize
)
[src]
t_res: &mut [u32],
t_torus: &[u32],
t_bool_key: &[u32],
polynomial_size: usize
)
Compute the multisum between 2 Torus tensors but one is viewed as a boolean tensor
Arguments
t_res
- a torus slice (output)t_torus
- a torus slicet_bool_key
- a torus slice viewed as a boolean slicepolynomial_size
- the size of the polynomials
Example
use concrete_lib::operators::math::PolynomialTensor ; use concrete_lib::operators::crypto::SecretKey ; type Torus = u32; let n: usize = 100 ; let polynomial_size: usize = 1024 ; let mut t_torus: Vec<Torus> = vec![0; n * polynomial_size] ; // fill t_torus // ... let size_bool_key = <Torus as SecretKey>::get_secret_key_length(n, polynomial_size) ; let mut t_bool_key = vec![0; size_bool_key] ; // fill t_bool_key // ... // allocation for the result let mut t_res = vec![0; polynomial_size ] ; <Torus as PolynomialTensor>::compute_binary_multisum(&mut t_res, &t_torus, &t_bool_key, polynomial_size ) ;
fn sub_binary_multisum(
t_res: &mut [u32],
t_torus: &[u32],
t_bool: &[u32],
polynomial_size: usize
)
[src]
t_res: &mut [u32],
t_torus: &[u32],
t_bool: &[u32],
polynomial_size: usize
)
Subtract the multisum between 2 Torus tensors but one is viewed as a boolean tensor res = res - \Sigma_i t_torus_i * t_bool_i
Arguments
t_res
- the result (output)t_torus
- a Torus tensort_bool
- a Torus tensor viewed as a boolean tensorpolynomial_size
- the size of the polynomials
Example
use concrete_lib::operators::crypto::SecretKey; use concrete_lib::operators::math::PolynomialTensor; type Torus = u32; // settings let polynomial_size: usize = 256; let dimension: usize = 10; // allocate a tensor of polynomials let mut t_polynomials: Vec<Torus> = vec![0; polynomial_size * dimension]; // ... (fill the tensor) // allocate a tensor of boolean polynomials let mut t_bool: Vec<Torus> = vec![0; <Torus as SecretKey>::get_secret_key_length(dimension, polynomial_size)]; // ... (fill the tensor) // allocate the result let mut t_res: Vec<Torus> = vec![0; polynomial_size * dimension]; // subtract a binary sum PolynomialTensor::sub_binary_multisum( &mut t_res, &t_polynomials, &t_bool, polynomial_size, );
fn add_binary_multisum(
t_res: &mut [u32],
t_torus: &[u32],
t_bool: &[u32],
polynomial_size: usize
)
[src]
t_res: &mut [u32],
t_torus: &[u32],
t_bool: &[u32],
polynomial_size: usize
)
Add the multisum between 2 Torus tensors but one is viewed as a boolean tensor res = res + \Sigma_i t_torus_i * t_bool_i
Arguments
t_res
- the result (output)t_torus
- a Torus tensort_bool
- a Torus tensor viewed as a boolean tensorpolynomial_size
- the size of the polynomials
Example
use concrete_lib::operators::crypto::SecretKey; use concrete_lib::operators::math::PolynomialTensor; type Torus = u32; // settings let polynomial_size: usize = 256; let dimension: usize = 10; // allocate a tensor of polynomials let mut t_polynomials: Vec<Torus> = vec![0; polynomial_size * dimension]; // ... (fill the tensor) // allocate a tensor of boolean polynomials let mut t_bool: Vec<Torus> = vec![0; <Torus as SecretKey>::get_secret_key_length(dimension, polynomial_size)]; // ... (fill the tensor) // allocate the result let mut t_res: Vec<Torus> = vec![0; polynomial_size * dimension]; // add a binary sum PolynomialTensor::add_binary_multisum( &mut t_res, &t_polynomials, &t_bool, polynomial_size, );
fn compute_binary_multisum_monome(
t_torus: &[u32],
t_bool_key: &[u32],
polynomial_size: usize,
dimension: usize,
monomial: usize
) -> u32
[src]
t_torus: &[u32],
t_bool_key: &[u32],
polynomial_size: usize,
dimension: usize,
monomial: usize
) -> u32
Compute one monomial of a resulting multisum between 2 Torus tensors but one is viewed as a boolean tensor
Arguments
t_torus
- a torus slicet_bool_key
- a torus slice viewed as a boolean slicepolynomial_size
- the size of the polynomialsdimension
- size of the maskmonomial
- the index of the desired monomial
Output
the coefficient of the desired monomial
fn multiply_by_monomial(
res: &mut [u32],
monomial_degree: usize,
polynomial_size: usize
)
[src]
res: &mut [u32],
monomial_degree: usize,
polynomial_size: usize
)
Multiply several polynomial by a monomial in the ring Torus[X] / (X^polynomial_size + 1) Warning : this function is inplace (overwrite)
Arguments
res
- polynomials to multiply (output)monomial_degree
- degree of the monomialpolynomial_size
- nnumber of coefficients of the polynomials REFACTOR
Example
use concrete_lib::operators::math::PolynomialTensor; type Torus = u32; // settings let polynomial_size: usize = 256; let dimension: usize = 10; // allocate a tensor of polynomials let mut t_polynomials: Vec<Torus> = vec![0; polynomial_size * dimension]; // ... (fill the tensor) // define a monomial_degree let monomial_degree: usize = 5; // allocate the result let mut t_res: Vec<Torus> = vec![0; polynomial_size * dimension]; // add a binary sum PolynomialTensor::multiply_by_monomial(&mut t_res, monomial_degree, polynomial_size);
fn divide_by_monomial(
res: &mut [u32],
monomial_degree: usize,
polynomial_size: usize
)
[src]
res: &mut [u32],
monomial_degree: usize,
polynomial_size: usize
)
Divide several polynomial by a monomial in the ring Torus[X] / (X^polynomial_size + 1) Warning : this function is inplace (overwrite)
Arguments
res
- polynomials to multiply (output)monomial_degree
- degree of the monomialpolynomial_size
- nnumber of coefficients of the polynomials
Example
use concrete_lib::operators::math::PolynomialTensor; type Torus = u32; // settings let polynomial_size: usize = 256; let dimension: usize = 10; // allocate a tensor of polynomials let mut t_polynomials: Vec<Torus> = vec![0; polynomial_size * dimension]; // ... (fill the tensor) // define a monomial_degree let monomial_degree: usize = 5; // allocate the result let mut t_res: Vec<Torus> = vec![0; polynomial_size * dimension]; // add a binary sum PolynomialTensor::divide_by_monomial(&mut t_res, monomial_degree, polynomial_size);
fn print_torus(poly: &[u32], polynomial_size: usize)
[src]
Prints in a pretty way a tensor of polynomials over the Torus Torus elements are between 0 and TORUS_MAX
Arguments
poly
- Torus slicepolynomial_size
- the size of the polynomials
Example
use concrete_lib::operators::math::{PolynomialTensor, Tensor}; type Torus = u32; // settings let polynomial_size: usize = 6; // creation of a random polynomial let mut polynomial: Vec<Torus> = vec![0; polynomial_size]; Tensor::uniform_random_default(&mut polynomial); // print PolynomialTensor::print_torus(&polynomial, polynomial_size); // stdout: // [POLYNOMIAL] poly: 0011 1011 0110 1010 1000 0011 1100 0000 + 0011 0100 1011 1101 1100 1110 0010 0011 X + 1010 0001 1101 0110 0001 1101 1100 1000 X^2 + 1110 1101 0100 1110 0100 1101 0100 1000 X^3 + 1100 1111 1111 1001 0000 1111 1101 1011 X^4 + 1101 0000 0100 1010 0111 0000 1110 1100 X^5
fn to_string_torus(poly: &[u32], polynomial_size: usize) -> String
[src]
Generate a pretty string representing a tensor of polynomials over the Torus Torus elements are between 0 and TORUS_MAX
Arguments
poly
- Torus slicepolynomial_size
- the size of the polynomials
Arguments
poly
- Torus slicepolynomial_size
- the size of the polynomials
Example
use concrete_lib::operators::math::{PolynomialTensor, Tensor}; type Torus = u32; // settings let polynomial_size: usize = 6; // creation of a random polynomial let mut polynomial: Vec<Torus> = vec![0; polynomial_size]; Tensor::uniform_random_default(&mut polynomial); // to string let s = PolynomialTensor::to_string_torus(&polynomial, polynomial_size); // output: // s = "{}0.39626873028464615 + 0.8058619236107916 X + 0.8790576986502856 X^2 + 0.6840280669275671 X^3 + 0.5027693663723767 X^4 + 0.4896212250459939 X^5"
fn to_string_binary_representation(
poly: &[u32],
polynomial_size: usize
) -> String
[src]
poly: &[u32],
polynomial_size: usize
) -> String
Generate a pretty string representing a tensor of polynomials over the Torus Torus elements are displayed with their binary representations
Arguments
poly
- Torus slicepolynomial_size
- the size of the polynomials
Example
use concrete_lib::operators::math::{PolynomialTensor, Tensor}; type Torus = u32; // settings let polynomial_size: usize = 6; // creation of a random polynomial let mut polynomial: Vec<Torus> = vec![0; polynomial_size]; Tensor::uniform_random_default(&mut polynomial); // to string let s = PolynomialTensor::to_string_binary_representation(&polynomial, polynomial_size); // output: // s = "{}1110 1000 0100 1011 1011 1000 1011 1010 + 0110 0010 0010 1100 1011 1011 1011 0110 X + 0101 1010 1011 0111 0010 0111 1011 0101 X^2 + 1011 0101 1111 0100 1000 1001 1110 1100 X^3 + 1010 1000 0000 1010 0000 1100 0100 1100 X^4 + 1011 1010 0001 1101 1110 0100 0010 0001 X^5"
fn named_print(poly: &[u32], polynomial_size: usize, name: String)
[src]
Prints in a pretty way a tensor of polynomials over the Torus with a name before Torus elements are between -TORUS_MAX/2 and TORUS_MAX/2
Arguments
poly
- Torus slicepolynomial_size
- the size of the polynomials
Example
use concrete_lib::operators::math::{PolynomialTensor, Tensor}; type Torus = u32; // settings let polynomial_size: usize = 6; // creation of a random polynomial let mut polynomial: Vec<Torus> = vec![0; polynomial_size]; Tensor::uniform_random_default(&mut polynomial); // print PolynomialTensor::named_print(&polynomial, polynomial_size, "a cool name".to_string()); // stdout: // [a cool name] poly: - 1895869351 + 780181538 X - 1576488853 X^2 - 1962848027 X^3 + 1323215848 X^4 - 1070517654 X^5
fn to_string_(poly: &[u32], polynomial_size: usize) -> String
[src]
Generate a pretty string representing a tensor of polynomials over the Torus Torus elements are between -TORUS_MAX/2 and TORUS_MAX/2
Arguments
poly
- Torus slicepolynomial_size
- the size of the polynomials
Example
use concrete_lib::operators::math::{PolynomialTensor, Tensor}; type Torus = u32; // settings let polynomial_size: usize = 6; // creation of a random polynomial let mut polynomial: Vec<Torus> = vec![0; polynomial_size]; Tensor::uniform_random_default(&mut polynomial); // to string let s = PolynomialTensor::to_string_(&polynomial, polynomial_size); // output: // s = "{} - 327668133 - 1690174369 X - 1471456801 X^2 - 1820608313 X^3 - 688390573 X^4 + 281745273 X^5"
fn signed_decompose_one_level(
sign_decomp: &mut [u32],
carries: &mut [u32],
polynomial: &[u32],
base_log: usize,
dec_level: usize
)
[src]
sign_decomp: &mut [u32],
carries: &mut [u32],
polynomial: &[u32],
base_log: usize,
dec_level: usize
)
Compute the dec_level-th element of the signed decomposition of a Torus polynomials according to some parameters with the previous level's carries
Arguments
sign_decomp
- a Torus slice containing signed values of the decomposition (output)carries
- a Torus slice containing the previous level carries, and will contain the next carries (input AND output)polynomial
- a Torus slice containing a Torus polynomial to be decomposedbase_log
- number of bits for the base B (B=2^base_log)dec_level
- level of the decomposition wanted
Example
use concrete_lib::operators::math::PolynomialTensor; type Torus = u32; // settings let polynomial_size: usize = 256; let base_log: usize = 4; // allocate a polynomial to decompose let mut polynomial: Vec<Torus> = vec![0; polynomial_size]; // ... (fill the polynomial) // allocate the carry tensor let mut carries: Vec<Torus> = vec![0; polynomial_size]; // ... // allocate the output let mut sign_decomp: Vec<Torus> = vec![0; polynomial_size]; PolynomialTensor::signed_decompose_one_level( &mut sign_decomp, &mut carries, &polynomial, base_log, 2, );
impl PolynomialTensor for u64
[src]
fn compute_binary_multisum(
t_res: &mut [u64],
t_torus: &[u64],
t_bool_key: &[u64],
polynomial_size: usize
)
[src]
t_res: &mut [u64],
t_torus: &[u64],
t_bool_key: &[u64],
polynomial_size: usize
)
Compute the multisum between 2 Torus tensors but one is viewed as a boolean tensor
Arguments
t_res
- a torus slice (output)t_torus
- a torus slicet_bool_key
- a torus slice viewed as a boolean slicepolynomial_size
- the size of the polynomials
Example
use concrete_lib::operators::math::PolynomialTensor ; use concrete_lib::operators::crypto::SecretKey ; type Torus = u64; let n: usize = 100 ; let polynomial_size: usize = 1024 ; let mut t_torus: Vec<Torus> = vec![0; n * polynomial_size] ; // fill t_torus // ... let size_bool_key = <Torus as SecretKey>::get_secret_key_length(n, polynomial_size) ; let mut t_bool_key = vec![0; size_bool_key] ; // fill t_bool_key // ... // allocation for the result let mut t_res = vec![0; polynomial_size ] ; <Torus as PolynomialTensor>::compute_binary_multisum(&mut t_res, &t_torus, &t_bool_key, polynomial_size ) ;
fn sub_binary_multisum(
t_res: &mut [u64],
t_torus: &[u64],
t_bool: &[u64],
polynomial_size: usize
)
[src]
t_res: &mut [u64],
t_torus: &[u64],
t_bool: &[u64],
polynomial_size: usize
)
Subtract the multisum between 2 Torus tensors but one is viewed as a boolean tensor res = res - \Sigma_i t_torus_i * t_bool_i
Arguments
t_res
- the result (output)t_torus
- a Torus tensort_bool
- a Torus tensor viewed as a boolean tensorpolynomial_size
- the size of the polynomials
Example
use concrete_lib::operators::crypto::SecretKey; use concrete_lib::operators::math::PolynomialTensor; type Torus = u64; // settings let polynomial_size: usize = 256; let dimension: usize = 10; // allocate a tensor of polynomials let mut t_polynomials: Vec<Torus> = vec![0; polynomial_size * dimension]; // ... (fill the tensor) // allocate a tensor of boolean polynomials let mut t_bool: Vec<Torus> = vec![0; <Torus as SecretKey>::get_secret_key_length(dimension, polynomial_size)]; // ... (fill the tensor) // allocate the result let mut t_res: Vec<Torus> = vec![0; polynomial_size * dimension]; // subtract a binary sum PolynomialTensor::sub_binary_multisum( &mut t_res, &t_polynomials, &t_bool, polynomial_size, );
fn add_binary_multisum(
t_res: &mut [u64],
t_torus: &[u64],
t_bool: &[u64],
polynomial_size: usize
)
[src]
t_res: &mut [u64],
t_torus: &[u64],
t_bool: &[u64],
polynomial_size: usize
)
Add the multisum between 2 Torus tensors but one is viewed as a boolean tensor res = res + \Sigma_i t_torus_i * t_bool_i
Arguments
t_res
- the result (output)t_torus
- a Torus tensort_bool
- a Torus tensor viewed as a boolean tensorpolynomial_size
- the size of the polynomials
Example
use concrete_lib::operators::crypto::SecretKey; use concrete_lib::operators::math::PolynomialTensor; type Torus = u64; // settings let polynomial_size: usize = 256; let dimension: usize = 10; // allocate a tensor of polynomials let mut t_polynomials: Vec<Torus> = vec![0; polynomial_size * dimension]; // ... (fill the tensor) // allocate a tensor of boolean polynomials let mut t_bool: Vec<Torus> = vec![0; <Torus as SecretKey>::get_secret_key_length(dimension, polynomial_size)]; // ... (fill the tensor) // allocate the result let mut t_res: Vec<Torus> = vec![0; polynomial_size * dimension]; // add a binary sum PolynomialTensor::add_binary_multisum( &mut t_res, &t_polynomials, &t_bool, polynomial_size, );
fn compute_binary_multisum_monome(
t_torus: &[u64],
t_bool_key: &[u64],
polynomial_size: usize,
dimension: usize,
monomial: usize
) -> u64
[src]
t_torus: &[u64],
t_bool_key: &[u64],
polynomial_size: usize,
dimension: usize,
monomial: usize
) -> u64
Compute one monomial of a resulting multisum between 2 Torus tensors but one is viewed as a boolean tensor
Arguments
t_torus
- a torus slicet_bool_key
- a torus slice viewed as a boolean slicepolynomial_size
- the size of the polynomialsdimension
- size of the maskmonomial
- the index of the desired monomial
Output
the coefficient of the desired monomial
fn multiply_by_monomial(
res: &mut [u64],
monomial_degree: usize,
polynomial_size: usize
)
[src]
res: &mut [u64],
monomial_degree: usize,
polynomial_size: usize
)
Multiply several polynomial by a monomial in the ring Torus[X] / (X^polynomial_size + 1) Warning : this function is inplace (overwrite)
Arguments
res
- polynomials to multiply (output)monomial_degree
- degree of the monomialpolynomial_size
- nnumber of coefficients of the polynomials REFACTOR
Example
use concrete_lib::operators::math::PolynomialTensor; type Torus = u64; // settings let polynomial_size: usize = 256; let dimension: usize = 10; // allocate a tensor of polynomials let mut t_polynomials: Vec<Torus> = vec![0; polynomial_size * dimension]; // ... (fill the tensor) // define a monomial_degree let monomial_degree: usize = 5; // allocate the result let mut t_res: Vec<Torus> = vec![0; polynomial_size * dimension]; // add a binary sum PolynomialTensor::multiply_by_monomial(&mut t_res, monomial_degree, polynomial_size);
fn divide_by_monomial(
res: &mut [u64],
monomial_degree: usize,
polynomial_size: usize
)
[src]
res: &mut [u64],
monomial_degree: usize,
polynomial_size: usize
)
Divide several polynomial by a monomial in the ring Torus[X] / (X^polynomial_size + 1) Warning : this function is inplace (overwrite)
Arguments
res
- polynomials to multiply (output)monomial_degree
- degree of the monomialpolynomial_size
- nnumber of coefficients of the polynomials
Example
use concrete_lib::operators::math::PolynomialTensor; type Torus = u64; // settings let polynomial_size: usize = 256; let dimension: usize = 10; // allocate a tensor of polynomials let mut t_polynomials: Vec<Torus> = vec![0; polynomial_size * dimension]; // ... (fill the tensor) // define a monomial_degree let monomial_degree: usize = 5; // allocate the result let mut t_res: Vec<Torus> = vec![0; polynomial_size * dimension]; // add a binary sum PolynomialTensor::divide_by_monomial(&mut t_res, monomial_degree, polynomial_size);
fn print_torus(poly: &[u64], polynomial_size: usize)
[src]
Prints in a pretty way a tensor of polynomials over the Torus Torus elements are between 0 and TORUS_MAX
Arguments
poly
- Torus slicepolynomial_size
- the size of the polynomials
Example
use concrete_lib::operators::math::{PolynomialTensor, Tensor}; type Torus = u64; // settings let polynomial_size: usize = 6; // creation of a random polynomial let mut polynomial: Vec<Torus> = vec![0; polynomial_size]; Tensor::uniform_random_default(&mut polynomial); // print PolynomialTensor::print_torus(&polynomial, polynomial_size); // stdout: // [POLYNOMIAL] poly: 0011 1011 0110 1010 1000 0011 1100 0000 + 0011 0100 1011 1101 1100 1110 0010 0011 X + 1010 0001 1101 0110 0001 1101 1100 1000 X^2 + 1110 1101 0100 1110 0100 1101 0100 1000 X^3 + 1100 1111 1111 1001 0000 1111 1101 1011 X^4 + 1101 0000 0100 1010 0111 0000 1110 1100 X^5
fn to_string_torus(poly: &[u64], polynomial_size: usize) -> String
[src]
Generate a pretty string representing a tensor of polynomials over the Torus Torus elements are between 0 and TORUS_MAX
Arguments
poly
- Torus slicepolynomial_size
- the size of the polynomials
Arguments
poly
- Torus slicepolynomial_size
- the size of the polynomials
Example
use concrete_lib::operators::math::{PolynomialTensor, Tensor}; type Torus = u64; // settings let polynomial_size: usize = 6; // creation of a random polynomial let mut polynomial: Vec<Torus> = vec![0; polynomial_size]; Tensor::uniform_random_default(&mut polynomial); // to string let s = PolynomialTensor::to_string_torus(&polynomial, polynomial_size); // output: // s = "{}0.39626873028464615 + 0.8058619236107916 X + 0.8790576986502856 X^2 + 0.6840280669275671 X^3 + 0.5027693663723767 X^4 + 0.4896212250459939 X^5"
fn to_string_binary_representation(
poly: &[u64],
polynomial_size: usize
) -> String
[src]
poly: &[u64],
polynomial_size: usize
) -> String
Generate a pretty string representing a tensor of polynomials over the Torus Torus elements are displayed with their binary representations
Arguments
poly
- Torus slicepolynomial_size
- the size of the polynomials
Example
use concrete_lib::operators::math::{PolynomialTensor, Tensor}; type Torus = u64; // settings let polynomial_size: usize = 6; // creation of a random polynomial let mut polynomial: Vec<Torus> = vec![0; polynomial_size]; Tensor::uniform_random_default(&mut polynomial); // to string let s = PolynomialTensor::to_string_binary_representation(&polynomial, polynomial_size); // output: // s = "{}1110 1000 0100 1011 1011 1000 1011 1010 + 0110 0010 0010 1100 1011 1011 1011 0110 X + 0101 1010 1011 0111 0010 0111 1011 0101 X^2 + 1011 0101 1111 0100 1000 1001 1110 1100 X^3 + 1010 1000 0000 1010 0000 1100 0100 1100 X^4 + 1011 1010 0001 1101 1110 0100 0010 0001 X^5"
fn named_print(poly: &[u64], polynomial_size: usize, name: String)
[src]
Prints in a pretty way a tensor of polynomials over the Torus with a name before Torus elements are between -TORUS_MAX/2 and TORUS_MAX/2
Arguments
poly
- Torus slicepolynomial_size
- the size of the polynomials
Example
use concrete_lib::operators::math::{PolynomialTensor, Tensor}; type Torus = u64; // settings let polynomial_size: usize = 6; // creation of a random polynomial let mut polynomial: Vec<Torus> = vec![0; polynomial_size]; Tensor::uniform_random_default(&mut polynomial); // print PolynomialTensor::named_print(&polynomial, polynomial_size, "a cool name".to_string()); // stdout: // [a cool name] poly: - 1895869351 + 780181538 X - 1576488853 X^2 - 1962848027 X^3 + 1323215848 X^4 - 1070517654 X^5
fn to_string_(poly: &[u64], polynomial_size: usize) -> String
[src]
Generate a pretty string representing a tensor of polynomials over the Torus Torus elements are between -TORUS_MAX/2 and TORUS_MAX/2
Arguments
poly
- Torus slicepolynomial_size
- the size of the polynomials
Example
use concrete_lib::operators::math::{PolynomialTensor, Tensor}; type Torus = u64; // settings let polynomial_size: usize = 6; // creation of a random polynomial let mut polynomial: Vec<Torus> = vec![0; polynomial_size]; Tensor::uniform_random_default(&mut polynomial); // to string let s = PolynomialTensor::to_string_(&polynomial, polynomial_size); // output: // s = "{} - 327668133 - 1690174369 X - 1471456801 X^2 - 1820608313 X^3 - 688390573 X^4 + 281745273 X^5"
fn signed_decompose_one_level(
sign_decomp: &mut [u64],
carries: &mut [u64],
polynomial: &[u64],
base_log: usize,
dec_level: usize
)
[src]
sign_decomp: &mut [u64],
carries: &mut [u64],
polynomial: &[u64],
base_log: usize,
dec_level: usize
)
Compute the dec_level-th element of the signed decomposition of a Torus polynomials according to some parameters with the previous level's carries
Arguments
sign_decomp
- a Torus slice containing signed values of the decomposition (output)carries
- a Torus slice containing the previous level carries, and will contain the next carries (input AND output)polynomial
- a Torus slice containing a Torus polynomial to be decomposedbase_log
- number of bits for the base B (B=2^base_log)dec_level
- level of the decomposition wanted
Example
use concrete_lib::operators::math::PolynomialTensor; type Torus = u64; // settings let polynomial_size: usize = 256; let base_log: usize = 4; // allocate a polynomial to decompose let mut polynomial: Vec<Torus> = vec![0; polynomial_size]; // ... (fill the polynomial) // allocate the carry tensor let mut carries: Vec<Torus> = vec![0; polynomial_size]; // ... // allocate the output let mut sign_decomp: Vec<Torus> = vec![0; polynomial_size]; PolynomialTensor::signed_decompose_one_level( &mut sign_decomp, &mut carries, &polynomial, base_log, 2, );