vmp & svp doc

This commit is contained in:
Jean-Philippe Bossuat
2025-02-04 10:51:11 +01:00
parent 12004c426a
commit e4a976ec9e
11 changed files with 759 additions and 500 deletions

View File

@@ -1,4 +1,5 @@
use base2k::{Matrix3D, Module, VecZnx, VecZnxBig, VecZnxDft, VmpPMat, FFT64};
use base2k::vmp::VectorMatrixProduct;
use base2k::{Free, Matrix3D, Module, VecZnx, VecZnxBig, VecZnxDft, VmpPMat, FFT64};
use std::cmp::min;
fn main() {
@@ -22,9 +23,9 @@ fn main() {
let mut a_values: Vec<i64> = vec![i64::default(); n];
a_values[1] = (1 << log_base2k) + 1;
let mut a: VecZnx = module.new_vec_znx(log_base2k, limbs);
a.from_i64(&a_values, 32, log_k);
a.normalize(&mut buf);
let mut a: VecZnx = module.new_vec_znx(limbs);
a.from_i64(log_base2k, &a_values, 32, log_k);
a.normalize(log_base2k, &mut buf);
(0..a.limbs()).for_each(|i| println!("{}: {:?}", i, a.at(i)));
@@ -34,41 +35,26 @@ fn main() {
b_mat.at_mut(i, i)[1] = 1 as i64;
});
println!();
(0..rows).for_each(|i| {
(0..cols).for_each(|j| println!("{} {}: {:?}", i, j, b_mat.at(i, j)));
println!();
});
let mut vmp_pmat: VmpPMat = module.new_vmp_pmat(rows, cols);
module.vmp_prepare_contiguous(&mut vmp_pmat, &b_mat.data, &mut buf);
/*
(0..cols).for_each(|i| {
(0..rows).for_each(|j| println!("{} {}: {:?}", i, j, vmp_pmat.at(i, j)));
println!();
});
*/
//println!("{:?}", vmp_pmat.as_f64());
let mut c_dft: VecZnxDft = module.new_vec_znx_dft(cols);
module.vmp_apply_dft(&mut c_dft, &a, &vmp_pmat, &mut buf);
let mut c_big: VecZnxBig = c_dft.as_vec_znx_big();
module.vec_znx_idft_tmp_a(&mut c_big, &mut c_dft, cols);
let mut res: VecZnx = module.new_vec_znx(log_base2k, cols);
module.vec_znx_big_normalize(&mut res, &c_big, &mut buf);
let mut res: VecZnx = module.new_vec_znx(cols);
module.vec_znx_big_normalize(log_base2k, &mut res, &c_big, &mut buf);
let mut values_res: Vec<i64> = vec![i64::default(); n];
res.to_i64(&mut values_res, log_k);
res.to_i64(log_base2k, &mut values_res, log_k);
(0..res.limbs()).for_each(|i| println!("{}: {:?}", i, res.at(i)));
module.delete();
c_dft.delete();
vmp_pmat.delete();
module.free();
c_dft.free();
vmp_pmat.free();
//println!("{:?}", values_res)
}