poulpy_ckks/delegates/
pow2.rs1use anyhow::Result;
2use poulpy_core::{
3 GLWECopy, GLWEShift,
4 layouts::{GLWEToBackendMut, GLWEToBackendRef},
5};
6use poulpy_hal::layouts::{Backend, Module, ScratchArena};
7
8use crate::{CKKSCtBounds, SetCKKSInfos, oep::CKKSPow2Impl};
9
10use crate::api::CKKSPow2Ops;
11
12impl<BE: Backend + CKKSPow2Impl<BE>> CKKSPow2Ops<BE> for Module<BE>
13where
14 Module<BE>: GLWECopy<BE> + GLWEShift<BE>,
15{
16 fn ckks_mul_pow2_tmp_bytes(&self) -> usize {
17 BE::ckks_mul_pow2_tmp_bytes(self)
18 }
19
20 fn ckks_mul_pow2_into<Dst, Src>(
21 &self,
22 dst: &mut Dst,
23 src: &Src,
24 bits: usize,
25 scratch: &mut ScratchArena<'_, BE>,
26 ) -> Result<()>
27 where
28 Dst: GLWEToBackendMut<BE> + CKKSCtBounds + SetCKKSInfos,
29 Src: GLWEToBackendRef<BE> + CKKSCtBounds,
30 {
31 BE::ckks_mul_pow2_into(self, dst, src, bits, scratch)
32 }
33
34 fn ckks_mul_pow2_assign<Dst>(&self, dst: &mut Dst, bits: usize, scratch: &mut ScratchArena<'_, BE>) -> Result<()>
35 where
36 Dst: GLWEToBackendMut<BE> + CKKSCtBounds + SetCKKSInfos,
37 {
38 BE::ckks_mul_pow2_assign(self, dst, bits, scratch)
39 }
40
41 fn ckks_div_pow2_tmp_bytes(&self) -> usize {
42 BE::ckks_div_pow2_tmp_bytes(self)
43 }
44
45 fn ckks_div_pow2_into<Dst, Src>(
46 &self,
47 dst: &mut Dst,
48 src: &Src,
49 bits: usize,
50 scratch: &mut ScratchArena<'_, BE>,
51 ) -> Result<()>
52 where
53 Dst: GLWEToBackendMut<BE> + CKKSCtBounds + SetCKKSInfos,
54 Src: GLWEToBackendRef<BE> + CKKSCtBounds,
55 {
56 BE::ckks_div_pow2_into(self, dst, src, bits, scratch)
57 }
58
59 fn ckks_div_pow2_assign<Dst>(&self, dst: &mut Dst, bits: usize) -> Result<()>
60 where
61 Dst: GLWEToBackendMut<BE> + CKKSCtBounds + SetCKKSInfos,
62 {
63 BE::ckks_div_pow2_assign(self, dst, bits)
64 }
65}