use rand_distr::Distribution; use crate::{ api::{ VecZnxBigAdd, VecZnxBigAddDistF64, VecZnxBigAddInplace, VecZnxBigAddNormal, VecZnxBigAddSmall, VecZnxBigAddSmallInplace, VecZnxBigAlloc, VecZnxBigAllocBytes, VecZnxBigAutomorphism, VecZnxBigAutomorphismInplace, VecZnxBigFillDistF64, VecZnxBigFillNormal, VecZnxBigFromBytes, VecZnxBigNegateInplace, VecZnxBigNormalize, VecZnxBigNormalizeTmpBytes, VecZnxBigSub, VecZnxBigSubABInplace, VecZnxBigSubBAInplace, VecZnxBigSubSmallA, VecZnxBigSubSmallAInplace, VecZnxBigSubSmallB, VecZnxBigSubSmallBInplace, }, layouts::{Backend, Module, Scratch, VecZnxBigOwned, VecZnxBigToMut, VecZnxBigToRef, VecZnxToMut, VecZnxToRef}, oep::{ VecZnxBigAddDistF64Impl, VecZnxBigAddImpl, VecZnxBigAddInplaceImpl, VecZnxBigAddNormalImpl, VecZnxBigAddSmallImpl, VecZnxBigAddSmallInplaceImpl, VecZnxBigAllocBytesImpl, VecZnxBigAllocImpl, VecZnxBigAutomorphismImpl, VecZnxBigAutomorphismInplaceImpl, VecZnxBigFillDistF64Impl, VecZnxBigFillNormalImpl, VecZnxBigFromBytesImpl, VecZnxBigNegateInplaceImpl, VecZnxBigNormalizeImpl, VecZnxBigNormalizeTmpBytesImpl, VecZnxBigSubABInplaceImpl, VecZnxBigSubBAInplaceImpl, VecZnxBigSubImpl, VecZnxBigSubSmallAImpl, VecZnxBigSubSmallAInplaceImpl, VecZnxBigSubSmallBImpl, VecZnxBigSubSmallBInplaceImpl, }, source::Source, }; impl VecZnxBigAlloc for Module where B: Backend + VecZnxBigAllocImpl, { fn vec_znx_big_alloc(&self, n: usize, cols: usize, size: usize) -> VecZnxBigOwned { B::vec_znx_big_alloc_impl(n, cols, size) } } impl VecZnxBigFromBytes for Module where B: Backend + VecZnxBigFromBytesImpl, { fn vec_znx_big_from_bytes(&self, n: usize, cols: usize, size: usize, bytes: Vec) -> VecZnxBigOwned { B::vec_znx_big_from_bytes_impl(n, cols, size, bytes) } } impl VecZnxBigAllocBytes for Module where B: Backend + VecZnxBigAllocBytesImpl, { fn vec_znx_big_alloc_bytes(&self, n: usize, cols: usize, size: usize) -> usize { B::vec_znx_big_alloc_bytes_impl(n, cols, size) } } impl VecZnxBigAddDistF64 for Module where B: Backend + VecZnxBigAddDistF64Impl, { fn vec_znx_big_add_dist_f64, D: Distribution>( &self, basek: usize, res: &mut R, res_col: usize, k: usize, source: &mut Source, dist: D, bound: f64, ) { B::add_dist_f64_impl(self, basek, res, res_col, k, source, dist, bound); } } impl VecZnxBigAddNormal for Module where B: Backend + VecZnxBigAddNormalImpl, { fn vec_znx_big_add_normal>( &self, basek: usize, res: &mut R, res_col: usize, k: usize, source: &mut Source, sigma: f64, bound: f64, ) { B::add_normal_impl(self, basek, res, res_col, k, source, sigma, bound); } } impl VecZnxBigFillDistF64 for Module where B: Backend + VecZnxBigFillDistF64Impl, { fn vec_znx_big_fill_dist_f64, D: Distribution>( &self, basek: usize, res: &mut R, res_col: usize, k: usize, source: &mut Source, dist: D, bound: f64, ) { B::fill_dist_f64_impl(self, basek, res, res_col, k, source, dist, bound); } } impl VecZnxBigFillNormal for Module where B: Backend + VecZnxBigFillNormalImpl, { fn vec_znx_big_fill_normal>( &self, basek: usize, res: &mut R, res_col: usize, k: usize, source: &mut Source, sigma: f64, bound: f64, ) { B::fill_normal_impl(self, basek, res, res_col, k, source, sigma, bound); } } impl VecZnxBigAdd for Module where B: Backend + VecZnxBigAddImpl, { fn vec_znx_big_add(&self, res: &mut R, res_col: usize, a: &A, a_col: usize, b: &C, b_col: usize) where R: VecZnxBigToMut, A: VecZnxBigToRef, C: VecZnxBigToRef, { B::vec_znx_big_add_impl(self, res, res_col, a, a_col, b, b_col); } } impl VecZnxBigAddInplace for Module where B: Backend + VecZnxBigAddInplaceImpl, { fn vec_znx_big_add_inplace(&self, res: &mut R, res_col: usize, a: &A, a_col: usize) where R: VecZnxBigToMut, A: VecZnxBigToRef, { B::vec_znx_big_add_inplace_impl(self, res, res_col, a, a_col); } } impl VecZnxBigAddSmall for Module where B: Backend + VecZnxBigAddSmallImpl, { fn vec_znx_big_add_small(&self, res: &mut R, res_col: usize, a: &A, a_col: usize, b: &C, b_col: usize) where R: VecZnxBigToMut, A: VecZnxBigToRef, C: VecZnxToRef, { B::vec_znx_big_add_small_impl(self, res, res_col, a, a_col, b, b_col); } } impl VecZnxBigAddSmallInplace for Module where B: Backend + VecZnxBigAddSmallInplaceImpl, { fn vec_znx_big_add_small_inplace(&self, res: &mut R, res_col: usize, a: &A, a_col: usize) where R: VecZnxBigToMut, A: VecZnxToRef, { B::vec_znx_big_add_small_inplace_impl(self, res, res_col, a, a_col); } } impl VecZnxBigSub for Module where B: Backend + VecZnxBigSubImpl, { fn vec_znx_big_sub(&self, res: &mut R, res_col: usize, a: &A, a_col: usize, b: &C, b_col: usize) where R: VecZnxBigToMut, A: VecZnxBigToRef, C: VecZnxBigToRef, { B::vec_znx_big_sub_impl(self, res, res_col, a, a_col, b, b_col); } } impl VecZnxBigSubABInplace for Module where B: Backend + VecZnxBigSubABInplaceImpl, { fn vec_znx_big_sub_ab_inplace(&self, res: &mut R, res_col: usize, a: &A, a_col: usize) where R: VecZnxBigToMut, A: VecZnxBigToRef, { B::vec_znx_big_sub_ab_inplace_impl(self, res, res_col, a, a_col); } } impl VecZnxBigSubBAInplace for Module where B: Backend + VecZnxBigSubBAInplaceImpl, { fn vec_znx_big_sub_ba_inplace(&self, res: &mut R, res_col: usize, a: &A, a_col: usize) where R: VecZnxBigToMut, A: VecZnxBigToRef, { B::vec_znx_big_sub_ba_inplace_impl(self, res, res_col, a, a_col); } } impl VecZnxBigSubSmallA for Module where B: Backend + VecZnxBigSubSmallAImpl, { fn vec_znx_big_sub_small_a(&self, res: &mut R, res_col: usize, a: &A, a_col: usize, b: &C, b_col: usize) where R: VecZnxBigToMut, A: VecZnxToRef, C: VecZnxBigToRef, { B::vec_znx_big_sub_small_a_impl(self, res, res_col, a, a_col, b, b_col); } } impl VecZnxBigSubSmallAInplace for Module where B: Backend + VecZnxBigSubSmallAInplaceImpl, { fn vec_znx_big_sub_small_a_inplace(&self, res: &mut R, res_col: usize, a: &A, a_col: usize) where R: VecZnxBigToMut, A: VecZnxToRef, { B::vec_znx_big_sub_small_a_inplace_impl(self, res, res_col, a, a_col); } } impl VecZnxBigSubSmallB for Module where B: Backend + VecZnxBigSubSmallBImpl, { fn vec_znx_big_sub_small_b(&self, res: &mut R, res_col: usize, a: &A, a_col: usize, b: &C, b_col: usize) where R: VecZnxBigToMut, A: VecZnxBigToRef, C: VecZnxToRef, { B::vec_znx_big_sub_small_b_impl(self, res, res_col, a, a_col, b, b_col); } } impl VecZnxBigSubSmallBInplace for Module where B: Backend + VecZnxBigSubSmallBInplaceImpl, { fn vec_znx_big_sub_small_b_inplace(&self, res: &mut R, res_col: usize, a: &A, a_col: usize) where R: VecZnxBigToMut, A: VecZnxToRef, { B::vec_znx_big_sub_small_b_inplace_impl(self, res, res_col, a, a_col); } } impl VecZnxBigNegateInplace for Module where B: Backend + VecZnxBigNegateInplaceImpl, { fn vec_znx_big_negate_inplace(&self, a: &mut A, a_col: usize) where A: VecZnxBigToMut, { B::vec_znx_big_negate_inplace_impl(self, a, a_col); } } impl VecZnxBigNormalizeTmpBytes for Module where B: Backend + VecZnxBigNormalizeTmpBytesImpl, { fn vec_znx_big_normalize_tmp_bytes(&self, n: usize) -> usize { B::vec_znx_big_normalize_tmp_bytes_impl(self, n) } } impl VecZnxBigNormalize for Module where B: Backend + VecZnxBigNormalizeImpl, { fn vec_znx_big_normalize( &self, basek: usize, res: &mut R, res_col: usize, a: &A, a_col: usize, scratch: &mut Scratch, ) where R: VecZnxToMut, A: VecZnxBigToRef, { B::vec_znx_big_normalize_impl(self, basek, res, res_col, a, a_col, scratch); } } impl VecZnxBigAutomorphism for Module where B: Backend + VecZnxBigAutomorphismImpl, { fn vec_znx_big_automorphism(&self, k: i64, res: &mut R, res_col: usize, a: &A, a_col: usize) where R: VecZnxBigToMut, A: VecZnxBigToRef, { B::vec_znx_big_automorphism_impl(self, k, res, res_col, a, a_col); } } impl VecZnxBigAutomorphismInplace for Module where B: Backend + VecZnxBigAutomorphismInplaceImpl, { fn vec_znx_big_automorphism_inplace(&self, k: i64, a: &mut A, a_col: usize) where A: VecZnxBigToMut, { B::vec_znx_big_automorphism_inplace_impl(self, k, a, a_col); } }