poulpy/poulpy-hal/src/api/zn.rs
poulpy-hal/src/api/zn.rsRaw
1use crate::{
2 layouts::{Backend, Scratch, ZnToMut},
3 reference::zn::zn_normalize_tmp_bytes,
4 source::Source,
5};
6
7pub trait ZnNormalizeTmpBytes {
8 fn zn_normalize_tmp_bytes(&self, n: usize) -> usize {
9 zn_normalize_tmp_bytes(n)
10 }
11}
12
13pub trait ZnNormalizeInplace<B: Backend> {
14 /// Normalizes the selected column of `a`.
15 fn zn_normalize_inplace<R>(&self, n: usize, basek: usize, res: &mut R, res_col: usize, scratch: &mut Scratch<B>)
16 where
17 R: ZnToMut;
18}
19
20pub trait ZnFillUniform {
21 /// Fills the first `size` size with uniform values in \[-2^{basek-1}, 2^{basek-1}\]
22 fn zn_fill_uniform<R>(&self, n: usize, basek: usize, res: &mut R, res_col: usize, source: &mut Source)
23 where
24 R: ZnToMut;
25}
26
27#[allow(clippy::too_many_arguments)]
28pub trait ZnFillNormal {
29 fn zn_fill_normal<R>(
30 &self,
31 n: usize,
32 basek: usize,
33 res: &mut R,
34 res_col: usize,
35 k: usize,
36 source: &mut Source,
37 sigma: f64,
38 bound: f64,
39 ) where
40 R: ZnToMut;
41}
42
43#[allow(clippy::too_many_arguments)]
44pub trait ZnAddNormal {
45 /// Adds a discrete normal vector scaled by 2^{-k} with the provided standard deviation and bounded to \[-bound, bound\].
46 fn zn_add_normal<R>(
47 &self,
48 n: usize,
49 basek: usize,
50 res: &mut R,
51 res_col: usize,
52 k: usize,
53 source: &mut Source,
54 sigma: f64,
55 bound: f64,
56 ) where
57 R: ZnToMut;
58}