arnaucube
arnaucube/poulpyPublic Self-hosted repository
poulpy/poulpy-hal/src/delegates/zn.rs
poulpy-hal/src/delegates/zn.rsRaw
  1use crate::{
  2    api::{ZnAddDistF64, ZnAddNormal, ZnFillDistF64, ZnFillNormal, ZnFillUniform, ZnNormalizeInplace},
  3    layouts::{Backend, Module, Scratch, ZnToMut},
  4    oep::{ZnAddDistF64Impl, ZnAddNormalImpl, ZnFillDistF64Impl, ZnFillNormalImpl, ZnFillUniformImpl, ZnNormalizeInplaceImpl},
  5    source::Source,
  6};
  7
  8impl<B> ZnNormalizeInplace<B> for Module<B>
  9where
 10    B: Backend + ZnNormalizeInplaceImpl<B>,
 11{
 12    fn zn_normalize_inplace<A>(&self, n: usize, basek: usize, a: &mut A, a_col: usize, scratch: &mut Scratch<B>)
 13    where
 14        A: ZnToMut,
 15    {
 16        B::zn_normalize_inplace_impl(n, basek, a, a_col, scratch)
 17    }
 18}
 19
 20impl<B> ZnFillUniform for Module<B>
 21where
 22    B: Backend + ZnFillUniformImpl<B>,
 23{
 24    fn zn_fill_uniform<R>(&self, n: usize, basek: usize, res: &mut R, res_col: usize, k: usize, source: &mut Source)
 25    where
 26        R: ZnToMut,
 27    {
 28        B::zn_fill_uniform_impl(n, basek, res, res_col, k, source);
 29    }
 30}
 31
 32impl<B> ZnFillDistF64 for Module<B>
 33where
 34    B: Backend + ZnFillDistF64Impl<B>,
 35{
 36    fn zn_fill_dist_f64<R, D: rand::prelude::Distribution<f64>>(
 37        &self,
 38        n: usize,
 39        basek: usize,
 40        res: &mut R,
 41        res_col: usize,
 42        k: usize,
 43        source: &mut Source,
 44        dist: D,
 45        bound: f64,
 46    ) where
 47        R: ZnToMut,
 48    {
 49        B::zn_fill_dist_f64_impl(n, basek, res, res_col, k, source, dist, bound);
 50    }
 51}
 52
 53impl<B> ZnAddDistF64 for Module<B>
 54where
 55    B: Backend + ZnAddDistF64Impl<B>,
 56{
 57    fn zn_add_dist_f64<R, D: rand::prelude::Distribution<f64>>(
 58        &self,
 59        n: usize,
 60        basek: usize,
 61        res: &mut R,
 62        res_col: usize,
 63        k: usize,
 64        source: &mut Source,
 65        dist: D,
 66        bound: f64,
 67    ) where
 68        R: ZnToMut,
 69    {
 70        B::zn_add_dist_f64_impl(n, basek, res, res_col, k, source, dist, bound);
 71    }
 72}
 73
 74impl<B> ZnFillNormal for Module<B>
 75where
 76    B: Backend + ZnFillNormalImpl<B>,
 77{
 78    fn zn_fill_normal<R>(
 79        &self,
 80        n: usize,
 81        basek: usize,
 82        res: &mut R,
 83        res_col: usize,
 84        k: usize,
 85        source: &mut Source,
 86        sigma: f64,
 87        bound: f64,
 88    ) where
 89        R: ZnToMut,
 90    {
 91        B::zn_fill_normal_impl(n, basek, res, res_col, k, source, sigma, bound);
 92    }
 93}
 94
 95impl<B> ZnAddNormal for Module<B>
 96where
 97    B: Backend + ZnAddNormalImpl<B>,
 98{
 99    fn zn_add_normal<R>(
100        &self,
101        n: usize,
102        basek: usize,
103        res: &mut R,
104        res_col: usize,
105        k: usize,
106        source: &mut Source,
107        sigma: f64,
108        bound: f64,
109    ) where
110        R: ZnToMut,
111    {
112        B::zn_add_normal_impl(n, basek, res, res_col, k, source, sigma, bound);
113    }
114}