mirror of
https://github.com/arnaucube/poulpy.git
synced 2026-02-10 05:06:44 +01:00
fixed a typo & small optimization
This commit is contained in:
@@ -148,9 +148,6 @@ impl VecZnxDftOps<FFT64> for Module<FFT64> {
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
(min_size..res_mut.size()).for_each(|j| {
|
|
||||||
res_mut.zero_at(res_col, j);
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn vec_znx_dft_copy<R, A>(&self, res: &mut R, res_col: usize, a: &A, a_col: usize)
|
fn vec_znx_dft_copy<R, A>(&self, res: &mut R, res_col: usize, a: &A, a_col: usize)
|
||||||
|
|||||||
@@ -352,12 +352,12 @@ where
|
|||||||
pub fn keyswitch_inplace<DataRhs>(
|
pub fn keyswitch_inplace<DataRhs>(
|
||||||
&mut self,
|
&mut self,
|
||||||
module: &Module<FFT64>,
|
module: &Module<FFT64>,
|
||||||
rhs: &AutomorphismKey<DataRhs, FFT64>,
|
rhs: &GLWESwitchingKey<DataRhs, FFT64>,
|
||||||
scratch: &mut base2k::Scratch,
|
scratch: &mut base2k::Scratch,
|
||||||
) where
|
) where
|
||||||
MatZnxDft<DataRhs, FFT64>: MatZnxDftToRef<FFT64>,
|
MatZnxDft<DataRhs, FFT64>: MatZnxDftToRef<FFT64>,
|
||||||
{
|
{
|
||||||
self.key.keyswitch_inplace(module, &rhs.key, scratch);
|
self.key.keyswitch_inplace(module, &rhs, scratch);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn external_product<DataLhs, DataRhs>(
|
pub fn external_product<DataLhs, DataRhs>(
|
||||||
|
|||||||
@@ -141,11 +141,9 @@ impl GLWECiphertext<Vec<u8>> {
|
|||||||
let vmp: usize = module.vmp_apply_tmp_bytes(out_size, in_size, in_size, in_rank, out_rank + 1, ksk_size)
|
let vmp: usize = module.vmp_apply_tmp_bytes(out_size, in_size, in_size, in_rank, out_rank + 1, ksk_size)
|
||||||
+ module.bytes_of_vec_znx_dft(in_rank, in_size);
|
+ module.bytes_of_vec_znx_dft(in_rank, in_size);
|
||||||
|
|
||||||
let a0_big: usize = module.bytes_of_vec_znx_big(1, in_size) + module.vec_znx_idft_tmp_bytes();
|
|
||||||
|
|
||||||
let norm: usize = module.vec_znx_big_normalize_tmp_bytes();
|
let norm: usize = module.vec_znx_big_normalize_tmp_bytes();
|
||||||
|
|
||||||
res_dft + (vmp | a0_big | norm)
|
res_dft + (vmp | norm)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn keyswitch_inplace_scratch_space(module: &Module<FFT64>, out_size: usize, out_rank: usize, ksk_size: usize) -> usize {
|
pub fn keyswitch_inplace_scratch_space(module: &Module<FFT64>, out_size: usize, out_rank: usize, ksk_size: usize) -> usize {
|
||||||
@@ -362,15 +360,10 @@ where
|
|||||||
module.vmp_apply(&mut res_dft, &ai_dft, rhs, scratch2);
|
module.vmp_apply(&mut res_dft, &ai_dft, rhs, scratch2);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Switches result of VMP outside of DFT
|
module.vec_znx_dft_add_inplace(&mut res_dft, 0, lhs, 0);
|
||||||
let mut res_big: VecZnxBig<&mut [u8], FFT64> = module.vec_znx_idft_consume::<&mut [u8]>(res_dft);
|
|
||||||
|
|
||||||
{
|
// Switches result of VMP outside of DFT
|
||||||
// Switches lhs 0-th outside of DFT domain and adds on
|
let res_big: VecZnxBig<&mut [u8], FFT64> = module.vec_znx_idft_consume::<&mut [u8]>(res_dft);
|
||||||
let (mut a0_big, scratch2) = scratch1.tmp_vec_znx_big(module, 1, lhs.size());
|
|
||||||
module.vec_znx_idft(&mut a0_big, 0, lhs, 0, scratch2);
|
|
||||||
module.vec_znx_big_add_inplace(&mut res_big, 0, &a0_big, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
(0..cols_out).for_each(|i| {
|
(0..cols_out).for_each(|i| {
|
||||||
module.vec_znx_big_normalize(basek, self, i, &res_big, i, scratch1);
|
module.vec_znx_big_normalize(basek, self, i, &res_big, i, scratch1);
|
||||||
|
|||||||
Reference in New Issue
Block a user