mirror of
https://github.com/arnaucube/poulpy.git
synced 2026-02-10 05:06:44 +01:00
Added LWE-GLWE conversion & LWE Keyswitch, improved LUT generation
This commit is contained in:
@@ -231,6 +231,23 @@ impl Scratch {
|
||||
)
|
||||
}
|
||||
|
||||
pub fn tmp_slice_vec_znx_dft<B: Backend>(
|
||||
&mut self,
|
||||
slice_size: usize,
|
||||
module: &Module<B>,
|
||||
cols: usize,
|
||||
size: usize,
|
||||
) -> (Vec<VecZnxDft<&mut [u8], B>>, &mut Self) {
|
||||
let mut scratch: &mut Scratch = self;
|
||||
let mut slice: Vec<VecZnxDft<&mut [u8], B>> = Vec::with_capacity(slice_size);
|
||||
for _ in 0..slice_size{
|
||||
let (znx, new_scratch) = scratch.tmp_vec_znx_dft(module, cols, size);
|
||||
scratch = new_scratch;
|
||||
slice.push(znx);
|
||||
};
|
||||
(slice, scratch)
|
||||
}
|
||||
|
||||
pub fn tmp_vec_znx_big<B: Backend>(
|
||||
&mut self,
|
||||
module: &Module<B>,
|
||||
@@ -253,6 +270,23 @@ impl Scratch {
|
||||
)
|
||||
}
|
||||
|
||||
pub fn tmp_slice_vec_znx<B: Backend>(
|
||||
&mut self,
|
||||
slice_size: usize,
|
||||
module: &Module<B>,
|
||||
cols: usize,
|
||||
size: usize,
|
||||
) -> (Vec<VecZnx<&mut [u8]>>, &mut Self) {
|
||||
let mut scratch: &mut Scratch = self;
|
||||
let mut slice: Vec<VecZnx<&mut [u8]>> = Vec::with_capacity(slice_size);
|
||||
for _ in 0..slice_size{
|
||||
let (znx, new_scratch) = scratch.tmp_vec_znx(module, cols, size);
|
||||
scratch = new_scratch;
|
||||
slice.push(znx);
|
||||
};
|
||||
(slice, scratch)
|
||||
}
|
||||
|
||||
pub fn tmp_mat_znx_dft<B: Backend>(
|
||||
&mut self,
|
||||
module: &Module<B>,
|
||||
|
||||
@@ -57,8 +57,8 @@ pub trait ZnxView: ZnxInfos + DataView<D: AsRef<[u8]>> {
|
||||
fn at_ptr(&self, i: usize, j: usize) -> *const Self::Scalar {
|
||||
#[cfg(debug_assertions)]
|
||||
{
|
||||
assert!(i < self.cols());
|
||||
assert!(j < self.size());
|
||||
assert!(i < self.cols(), "{} >= {}", i, self.cols());
|
||||
assert!(j < self.size(), "{} >= {}", j, self.size());
|
||||
}
|
||||
let offset: usize = self.n() * (j * self.cols() + i);
|
||||
unsafe { self.as_ptr().add(offset) }
|
||||
@@ -85,8 +85,8 @@ pub trait ZnxViewMut: ZnxView + DataViewMut<D: AsMut<[u8]>> {
|
||||
fn at_mut_ptr(&mut self, i: usize, j: usize) -> *mut Self::Scalar {
|
||||
#[cfg(debug_assertions)]
|
||||
{
|
||||
assert!(i < self.cols());
|
||||
assert!(j < self.size());
|
||||
assert!(i < self.cols(), "{} >= {}", i, self.cols());
|
||||
assert!(j < self.size(), "{} >= {}", j, self.size());
|
||||
}
|
||||
let offset: usize = self.n() * (j * self.cols() + i);
|
||||
unsafe { self.as_mut_ptr().add(offset) }
|
||||
|
||||
Reference in New Issue
Block a user