poulpy_hal/api/
svp_ppol.rs

1use crate::layouts::{Backend, ScalarZnxToRef, SvpPPolOwned, SvpPPolToMut, SvpPPolToRef, VecZnxDftToMut, VecZnxDftToRef};
2
3/// Allocates as [crate::layouts::SvpPPol].
4pub trait SvpPPolAlloc<B: Backend> {
5    fn svp_ppol_alloc(&self, n: usize, cols: usize) -> SvpPPolOwned<B>;
6}
7
8/// Returns the size in bytes to allocate a [crate::layouts::SvpPPol].
9pub trait SvpPPolAllocBytes {
10    fn svp_ppol_alloc_bytes(&self, n: usize, cols: usize) -> usize;
11}
12
13/// Consume a vector of bytes into a [crate::layouts::MatZnx].
14/// User must ensure that bytes is memory aligned and that it length is equal to [SvpPPolAllocBytes].
15pub trait SvpPPolFromBytes<B: Backend> {
16    fn svp_ppol_from_bytes(&self, n: usize, cols: usize, bytes: Vec<u8>) -> SvpPPolOwned<B>;
17}
18
19/// Prepare a [crate::layouts::ScalarZnx] into an [crate::layouts::SvpPPol].
20pub trait SvpPrepare<B: Backend> {
21    fn svp_prepare<R, A>(&self, res: &mut R, res_col: usize, a: &A, a_col: usize)
22    where
23        R: SvpPPolToMut<B>,
24        A: ScalarZnxToRef;
25}
26
27/// Apply a scalar-vector product between `a[a_col]` and `b[b_col]` and stores the result on `res[res_col]`.
28pub trait SvpApply<B: Backend> {
29    fn svp_apply<R, A, C>(&self, res: &mut R, res_col: usize, a: &A, a_col: usize, b: &C, b_col: usize)
30    where
31        R: VecZnxDftToMut<B>,
32        A: SvpPPolToRef<B>,
33        C: VecZnxDftToRef<B>;
34}
35
36/// Apply a scalar-vector product between `res[res_col]` and `a[a_col]` and stores the result on `res[res_col]`.
37pub trait SvpApplyInplace<B: Backend> {
38    fn svp_apply_inplace<R, A>(&self, res: &mut R, res_col: usize, a: &A, a_col: usize)
39    where
40        R: VecZnxDftToMut<B>,
41        A: SvpPPolToRef<B>;
42}