mirror of
https://github.com/arnaucube/poulpy.git
synced 2026-02-09 20:56:47 +01:00
89 lines
2.5 KiB
Rust
89 lines
2.5 KiB
Rust
use crate::hal::{
|
|
api::{
|
|
ScalarZnxAlloc, ScalarZnxAllocBytes, ScalarZnxAutomorphism, ScalarZnxAutomorphismInplace, ScalarZnxFromBytes,
|
|
ScalarZnxMulXpMinusOne, ScalarZnxMulXpMinusOneInplace,
|
|
},
|
|
layouts::{Backend, Module, ScalarZnxOwned, ScalarZnxToMut, ScalarZnxToRef},
|
|
oep::{
|
|
ScalarZnxAllocBytesImpl, ScalarZnxAllocImpl, ScalarZnxAutomorphismImpl, ScalarZnxAutomorphismInplaceIml,
|
|
ScalarZnxFromBytesImpl, ScalarZnxMulXpMinusOneImpl, ScalarZnxMulXpMinusOneInplaceImpl,
|
|
},
|
|
};
|
|
|
|
impl<B> ScalarZnxAllocBytes for Module<B>
|
|
where
|
|
B: Backend + ScalarZnxAllocBytesImpl<B>,
|
|
{
|
|
fn scalar_znx_alloc_bytes(&self, cols: usize) -> usize {
|
|
B::scalar_znx_alloc_bytes_impl(self.n(), cols)
|
|
}
|
|
}
|
|
|
|
impl<B> ScalarZnxAlloc for Module<B>
|
|
where
|
|
B: Backend + ScalarZnxAllocImpl<B>,
|
|
{
|
|
fn scalar_znx_alloc(&self, cols: usize) -> ScalarZnxOwned {
|
|
B::scalar_znx_alloc_impl(self.n(), cols)
|
|
}
|
|
}
|
|
|
|
impl<B> ScalarZnxFromBytes for Module<B>
|
|
where
|
|
B: Backend + ScalarZnxFromBytesImpl<B>,
|
|
{
|
|
fn scalar_znx_from_bytes(&self, cols: usize, bytes: Vec<u8>) -> ScalarZnxOwned {
|
|
B::scalar_znx_from_bytes_impl(self.n(), cols, bytes)
|
|
}
|
|
}
|
|
|
|
impl<B> ScalarZnxAutomorphism for Module<B>
|
|
where
|
|
B: Backend + ScalarZnxAutomorphismImpl<B>,
|
|
{
|
|
fn scalar_znx_automorphism<R, A>(&self, k: i64, res: &mut R, res_col: usize, a: &A, a_col: usize)
|
|
where
|
|
R: ScalarZnxToMut,
|
|
A: ScalarZnxToRef,
|
|
{
|
|
B::scalar_znx_automorphism_impl(self, k, res, res_col, a, a_col);
|
|
}
|
|
}
|
|
|
|
impl<B> ScalarZnxAutomorphismInplace for Module<B>
|
|
where
|
|
B: Backend + ScalarZnxAutomorphismInplaceIml<B>,
|
|
{
|
|
fn scalar_znx_automorphism_inplace<A>(&self, k: i64, a: &mut A, a_col: usize)
|
|
where
|
|
A: ScalarZnxToMut,
|
|
{
|
|
B::scalar_znx_automorphism_inplace_impl(self, k, a, a_col);
|
|
}
|
|
}
|
|
|
|
impl<B> ScalarZnxMulXpMinusOne for Module<B>
|
|
where
|
|
B: Backend + ScalarZnxMulXpMinusOneImpl<B>,
|
|
{
|
|
fn scalar_znx_mul_xp_minus_one<R, A>(&self, p: i64, r: &mut R, r_col: usize, a: &A, a_col: usize)
|
|
where
|
|
R: ScalarZnxToMut,
|
|
A: ScalarZnxToRef,
|
|
{
|
|
B::scalar_znx_mul_xp_minus_one_impl(self, p, r, r_col, a, a_col);
|
|
}
|
|
}
|
|
|
|
impl<B> ScalarZnxMulXpMinusOneInplace for Module<B>
|
|
where
|
|
B: Backend + ScalarZnxMulXpMinusOneInplaceImpl<B>,
|
|
{
|
|
fn scalar_znx_mul_xp_minus_one_inplace<R>(&self, p: i64, r: &mut R, r_col: usize)
|
|
where
|
|
R: ScalarZnxToMut,
|
|
{
|
|
B::scalar_znx_mul_xp_minus_one_inplace_impl(self, p, r, r_col);
|
|
}
|
|
}
|