poulpy_ckks/delegates/
rescale.rs1use anyhow::Result;
2use poulpy_core::{
3 GLWEShift,
4 layouts::{GLWEToBackendMut, GLWEToBackendRef},
5};
6use poulpy_hal::layouts::{Backend, Module, ScratchArena};
7
8use crate::{CKKSCtBounds, SetCKKSInfos, api::CKKSRescaleOps, oep::CKKSRescaleImpl};
9
10impl<BE: Backend + CKKSRescaleImpl<BE>> CKKSRescaleOps<BE> for Module<BE>
11where
12 Module<BE>: GLWEShift<BE>,
13{
14 fn ckks_rescale_tmp_bytes(&self) -> usize {
15 BE::ckks_rescale_tmp_bytes(self)
16 }
17
18 fn ckks_rescale_assign<Dst>(&self, ct: &mut Dst, k: usize, scratch: &mut ScratchArena<'_, BE>) -> Result<()>
19 where
20 Dst: GLWEToBackendMut<BE> + CKKSCtBounds + SetCKKSInfos,
21 {
22 BE::ckks_rescale_assign(self, ct, k, scratch)
23 }
24
25 fn ckks_rescale_into<Dst, Src>(&self, dst: &mut Dst, k: usize, src: &Src, scratch: &mut ScratchArena<'_, BE>) -> Result<()>
26 where
27 Dst: GLWEToBackendMut<BE> + CKKSCtBounds + SetCKKSInfos,
28 Src: GLWEToBackendRef<BE> + CKKSCtBounds,
29 {
30 BE::ckks_rescale_into(self, dst, k, src, scratch)
31 }
32
33 fn ckks_align_pair<A, B>(&self, a: &mut A, b: &mut B, scratch: &mut ScratchArena<'_, BE>) -> Result<()>
34 where
35 A: GLWEToBackendMut<BE> + CKKSCtBounds + SetCKKSInfos,
36 B: GLWEToBackendMut<BE> + CKKSCtBounds + SetCKKSInfos,
37 {
38 BE::ckks_align_pair(self, a, b, scratch)
39 }
40
41 fn ckks_align_tmp_bytes(&self) -> usize {
42 BE::ckks_align_tmp_bytes(self)
43 }
44}