mirror of
https://github.com/arnaucube/poulpy.git
synced 2026-02-10 21:26:41 +01:00
Updated vec_znx to stacked memory layout
This commit is contained in:
@@ -18,7 +18,7 @@ fn main() {
|
||||
let seed: [u8; 32] = [0; 32];
|
||||
let mut source: Source = Source::new(seed);
|
||||
|
||||
let mut res: VecZnx = module.new_vec_znx(cols);
|
||||
let mut res: VecZnx = module.new_vec_znx(1, cols);
|
||||
|
||||
// s <- Z_{-1, 0, 1}[X]/(X^{N}+1)
|
||||
let mut s: Scalar = Scalar::new(n);
|
||||
@@ -31,7 +31,7 @@ fn main() {
|
||||
module.svp_prepare(&mut s_ppol, &s);
|
||||
|
||||
// a <- Z_{2^prec}[X]/(X^{N}+1)
|
||||
let mut a: VecZnx = module.new_vec_znx(cols);
|
||||
let mut a: VecZnx = module.new_vec_znx(1, cols);
|
||||
module.fill_uniform(log_base2k, &mut a, cols, &mut source);
|
||||
|
||||
// Scratch space for DFT values
|
||||
@@ -46,21 +46,21 @@ fn main() {
|
||||
// buf_big <- IDFT(buf_dft) (not normalized)
|
||||
module.vec_znx_idft_tmp_a(&mut buf_big, &mut buf_dft);
|
||||
|
||||
let mut m: VecZnx = module.new_vec_znx(msg_cols);
|
||||
let mut m: VecZnx = module.new_vec_znx(1, msg_cols);
|
||||
|
||||
let mut want: Vec<i64> = vec![0; n];
|
||||
want.iter_mut()
|
||||
.for_each(|x| *x = source.next_u64n(16, 15) as i64);
|
||||
|
||||
// m
|
||||
m.encode_vec_i64(log_base2k, log_scale, &want, 4);
|
||||
m.encode_vec_i64(0, log_base2k, log_scale, &want, 4);
|
||||
m.normalize(log_base2k, &mut carry);
|
||||
|
||||
// buf_big <- m - buf_big
|
||||
module.vec_znx_big_sub_small_a_inplace(&mut buf_big, &m);
|
||||
|
||||
// b <- normalize(buf_big) + e
|
||||
let mut b: VecZnx = module.new_vec_znx(cols);
|
||||
let mut b: VecZnx = module.new_vec_znx(1, cols);
|
||||
module.vec_znx_big_normalize(log_base2k, &mut b, &buf_big, &mut carry);
|
||||
module.add_normal(
|
||||
log_base2k,
|
||||
@@ -85,7 +85,7 @@ fn main() {
|
||||
|
||||
// have = m * 2^{log_scale} + e
|
||||
let mut have: Vec<i64> = vec![i64::default(); n];
|
||||
res.decode_vec_i64(log_base2k, res.cols() * log_base2k, &mut have);
|
||||
res.decode_vec_i64(0, log_base2k, res.cols() * log_base2k, &mut have);
|
||||
|
||||
let scale: f64 = (1 << (res.cols() * log_base2k - log_scale)) as f64;
|
||||
izip!(want.iter(), have.iter())
|
||||
|
||||
Reference in New Issue
Block a user