poulpy_hal/delegates/
vec_znx_big.rs

1use crate::{
2    api::{
3        VecZnxBigAdd, VecZnxBigAddInplace, VecZnxBigAddNormal, VecZnxBigAddSmall, VecZnxBigAddSmallInplace, VecZnxBigAlloc,
4        VecZnxBigAllocBytes, VecZnxBigAutomorphism, VecZnxBigAutomorphismInplace, VecZnxBigAutomorphismInplaceTmpBytes,
5        VecZnxBigFromBytes, VecZnxBigFromSmall, VecZnxBigNegate, VecZnxBigNegateInplace, VecZnxBigNormalize,
6        VecZnxBigNormalizeTmpBytes, VecZnxBigSub, VecZnxBigSubABInplace, VecZnxBigSubBAInplace, VecZnxBigSubSmallA,
7        VecZnxBigSubSmallAInplace, VecZnxBigSubSmallB, VecZnxBigSubSmallBInplace,
8    },
9    layouts::{Backend, Module, Scratch, VecZnxBigOwned, VecZnxBigToMut, VecZnxBigToRef, VecZnxToMut, VecZnxToRef},
10    oep::{
11        VecZnxBigAddImpl, VecZnxBigAddInplaceImpl, VecZnxBigAddNormalImpl, VecZnxBigAddSmallImpl, VecZnxBigAddSmallInplaceImpl,
12        VecZnxBigAllocBytesImpl, VecZnxBigAllocImpl, VecZnxBigAutomorphismImpl, VecZnxBigAutomorphismInplaceImpl,
13        VecZnxBigAutomorphismInplaceTmpBytesImpl, VecZnxBigFromBytesImpl, VecZnxBigFromSmallImpl, VecZnxBigNegateImpl,
14        VecZnxBigNegateInplaceImpl, VecZnxBigNormalizeImpl, VecZnxBigNormalizeTmpBytesImpl, VecZnxBigSubABInplaceImpl,
15        VecZnxBigSubBAInplaceImpl, VecZnxBigSubImpl, VecZnxBigSubSmallAImpl, VecZnxBigSubSmallAInplaceImpl,
16        VecZnxBigSubSmallBImpl, VecZnxBigSubSmallBInplaceImpl,
17    },
18    source::Source,
19};
20
21impl<B> VecZnxBigFromSmall<B> for Module<B>
22where
23    B: Backend + VecZnxBigFromSmallImpl<B>,
24{
25    fn vec_znx_big_from_small<R, A>(&self, res: &mut R, res_col: usize, a: &A, a_col: usize)
26    where
27        R: VecZnxBigToMut<B>,
28        A: VecZnxToRef,
29    {
30        B::vec_znx_big_from_small_impl(res, res_col, a, a_col);
31    }
32}
33
34impl<B> VecZnxBigAlloc<B> for Module<B>
35where
36    B: Backend + VecZnxBigAllocImpl<B>,
37{
38    fn vec_znx_big_alloc(&self, cols: usize, size: usize) -> VecZnxBigOwned<B> {
39        B::vec_znx_big_alloc_impl(self.n(), cols, size)
40    }
41}
42
43impl<B> VecZnxBigFromBytes<B> for Module<B>
44where
45    B: Backend + VecZnxBigFromBytesImpl<B>,
46{
47    fn vec_znx_big_from_bytes(&self, cols: usize, size: usize, bytes: Vec<u8>) -> VecZnxBigOwned<B> {
48        B::vec_znx_big_from_bytes_impl(self.n(), cols, size, bytes)
49    }
50}
51
52impl<B> VecZnxBigAllocBytes for Module<B>
53where
54    B: Backend + VecZnxBigAllocBytesImpl<B>,
55{
56    fn vec_znx_big_alloc_bytes(&self, cols: usize, size: usize) -> usize {
57        B::vec_znx_big_alloc_bytes_impl(self.n(), cols, size)
58    }
59}
60
61impl<B> VecZnxBigAddNormal<B> for Module<B>
62where
63    B: Backend + VecZnxBigAddNormalImpl<B>,
64{
65    fn vec_znx_big_add_normal<R: VecZnxBigToMut<B>>(
66        &self,
67        basek: usize,
68        res: &mut R,
69        res_col: usize,
70        k: usize,
71        source: &mut Source,
72        sigma: f64,
73        bound: f64,
74    ) {
75        B::add_normal_impl(self, basek, res, res_col, k, source, sigma, bound);
76    }
77}
78
79impl<B> VecZnxBigAdd<B> for Module<B>
80where
81    B: Backend + VecZnxBigAddImpl<B>,
82{
83    fn vec_znx_big_add<R, A, C>(&self, res: &mut R, res_col: usize, a: &A, a_col: usize, b: &C, b_col: usize)
84    where
85        R: VecZnxBigToMut<B>,
86        A: VecZnxBigToRef<B>,
87        C: VecZnxBigToRef<B>,
88    {
89        B::vec_znx_big_add_impl(self, res, res_col, a, a_col, b, b_col);
90    }
91}
92
93impl<B> VecZnxBigAddInplace<B> for Module<B>
94where
95    B: Backend + VecZnxBigAddInplaceImpl<B>,
96{
97    fn vec_znx_big_add_inplace<R, A>(&self, res: &mut R, res_col: usize, a: &A, a_col: usize)
98    where
99        R: VecZnxBigToMut<B>,
100        A: VecZnxBigToRef<B>,
101    {
102        B::vec_znx_big_add_inplace_impl(self, res, res_col, a, a_col);
103    }
104}
105
106impl<B> VecZnxBigAddSmall<B> for Module<B>
107where
108    B: Backend + VecZnxBigAddSmallImpl<B>,
109{
110    fn vec_znx_big_add_small<R, A, C>(&self, res: &mut R, res_col: usize, a: &A, a_col: usize, b: &C, b_col: usize)
111    where
112        R: VecZnxBigToMut<B>,
113        A: VecZnxBigToRef<B>,
114        C: VecZnxToRef,
115    {
116        B::vec_znx_big_add_small_impl(self, res, res_col, a, a_col, b, b_col);
117    }
118}
119
120impl<B> VecZnxBigAddSmallInplace<B> for Module<B>
121where
122    B: Backend + VecZnxBigAddSmallInplaceImpl<B>,
123{
124    fn vec_znx_big_add_small_inplace<R, A>(&self, res: &mut R, res_col: usize, a: &A, a_col: usize)
125    where
126        R: VecZnxBigToMut<B>,
127        A: VecZnxToRef,
128    {
129        B::vec_znx_big_add_small_inplace_impl(self, res, res_col, a, a_col);
130    }
131}
132
133impl<B> VecZnxBigSub<B> for Module<B>
134where
135    B: Backend + VecZnxBigSubImpl<B>,
136{
137    fn vec_znx_big_sub<R, A, C>(&self, res: &mut R, res_col: usize, a: &A, a_col: usize, b: &C, b_col: usize)
138    where
139        R: VecZnxBigToMut<B>,
140        A: VecZnxBigToRef<B>,
141        C: VecZnxBigToRef<B>,
142    {
143        B::vec_znx_big_sub_impl(self, res, res_col, a, a_col, b, b_col);
144    }
145}
146
147impl<B> VecZnxBigSubABInplace<B> for Module<B>
148where
149    B: Backend + VecZnxBigSubABInplaceImpl<B>,
150{
151    fn vec_znx_big_sub_ab_inplace<R, A>(&self, res: &mut R, res_col: usize, a: &A, a_col: usize)
152    where
153        R: VecZnxBigToMut<B>,
154        A: VecZnxBigToRef<B>,
155    {
156        B::vec_znx_big_sub_ab_inplace_impl(self, res, res_col, a, a_col);
157    }
158}
159
160impl<B> VecZnxBigSubBAInplace<B> for Module<B>
161where
162    B: Backend + VecZnxBigSubBAInplaceImpl<B>,
163{
164    fn vec_znx_big_sub_ba_inplace<R, A>(&self, res: &mut R, res_col: usize, a: &A, a_col: usize)
165    where
166        R: VecZnxBigToMut<B>,
167        A: VecZnxBigToRef<B>,
168    {
169        B::vec_znx_big_sub_ba_inplace_impl(self, res, res_col, a, a_col);
170    }
171}
172
173impl<B> VecZnxBigSubSmallA<B> for Module<B>
174where
175    B: Backend + VecZnxBigSubSmallAImpl<B>,
176{
177    fn vec_znx_big_sub_small_a<R, A, C>(&self, res: &mut R, res_col: usize, a: &A, a_col: usize, b: &C, b_col: usize)
178    where
179        R: VecZnxBigToMut<B>,
180        A: VecZnxToRef,
181        C: VecZnxBigToRef<B>,
182    {
183        B::vec_znx_big_sub_small_a_impl(self, res, res_col, a, a_col, b, b_col);
184    }
185}
186
187impl<B> VecZnxBigSubSmallAInplace<B> for Module<B>
188where
189    B: Backend + VecZnxBigSubSmallAInplaceImpl<B>,
190{
191    fn vec_znx_big_sub_small_a_inplace<R, A>(&self, res: &mut R, res_col: usize, a: &A, a_col: usize)
192    where
193        R: VecZnxBigToMut<B>,
194        A: VecZnxToRef,
195    {
196        B::vec_znx_big_sub_small_a_inplace_impl(self, res, res_col, a, a_col);
197    }
198}
199
200impl<B> VecZnxBigSubSmallB<B> for Module<B>
201where
202    B: Backend + VecZnxBigSubSmallBImpl<B>,
203{
204    fn vec_znx_big_sub_small_b<R, A, C>(&self, res: &mut R, res_col: usize, a: &A, a_col: usize, b: &C, b_col: usize)
205    where
206        R: VecZnxBigToMut<B>,
207        A: VecZnxBigToRef<B>,
208        C: VecZnxToRef,
209    {
210        B::vec_znx_big_sub_small_b_impl(self, res, res_col, a, a_col, b, b_col);
211    }
212}
213
214impl<B> VecZnxBigSubSmallBInplace<B> for Module<B>
215where
216    B: Backend + VecZnxBigSubSmallBInplaceImpl<B>,
217{
218    fn vec_znx_big_sub_small_b_inplace<R, A>(&self, res: &mut R, res_col: usize, a: &A, a_col: usize)
219    where
220        R: VecZnxBigToMut<B>,
221        A: VecZnxToRef,
222    {
223        B::vec_znx_big_sub_small_b_inplace_impl(self, res, res_col, a, a_col);
224    }
225}
226
227impl<B> VecZnxBigNegate<B> for Module<B>
228where
229    B: Backend + VecZnxBigNegateImpl<B>,
230{
231    fn vec_znx_big_negate<R, A>(&self, res: &mut R, res_col: usize, a: &A, a_col: usize)
232    where
233        R: VecZnxBigToMut<B>,
234        A: VecZnxBigToRef<B>,
235    {
236        B::vec_znx_big_negate_impl(self, res, res_col, a, a_col);
237    }
238}
239
240impl<B> VecZnxBigNegateInplace<B> for Module<B>
241where
242    B: Backend + VecZnxBigNegateInplaceImpl<B>,
243{
244    fn vec_znx_big_negate_inplace<A>(&self, a: &mut A, a_col: usize)
245    where
246        A: VecZnxBigToMut<B>,
247    {
248        B::vec_znx_big_negate_inplace_impl(self, a, a_col);
249    }
250}
251
252impl<B> VecZnxBigNormalizeTmpBytes for Module<B>
253where
254    B: Backend + VecZnxBigNormalizeTmpBytesImpl<B>,
255{
256    fn vec_znx_big_normalize_tmp_bytes(&self) -> usize {
257        B::vec_znx_big_normalize_tmp_bytes_impl(self)
258    }
259}
260
261impl<B> VecZnxBigNormalize<B> for Module<B>
262where
263    B: Backend + VecZnxBigNormalizeImpl<B>,
264{
265    fn vec_znx_big_normalize<R, A>(
266        &self,
267        basek: usize,
268        res: &mut R,
269        res_col: usize,
270        a: &A,
271        a_col: usize,
272        scratch: &mut Scratch<B>,
273    ) where
274        R: VecZnxToMut,
275        A: VecZnxBigToRef<B>,
276    {
277        B::vec_znx_big_normalize_impl(self, basek, res, res_col, a, a_col, scratch);
278    }
279}
280
281impl<B> VecZnxBigAutomorphism<B> for Module<B>
282where
283    B: Backend + VecZnxBigAutomorphismImpl<B>,
284{
285    fn vec_znx_big_automorphism<R, A>(&self, k: i64, res: &mut R, res_col: usize, a: &A, a_col: usize)
286    where
287        R: VecZnxBigToMut<B>,
288        A: VecZnxBigToRef<B>,
289    {
290        B::vec_znx_big_automorphism_impl(self, k, res, res_col, a, a_col);
291    }
292}
293
294impl<B> VecZnxBigAutomorphismInplaceTmpBytes for Module<B>
295where
296    B: Backend + VecZnxBigAutomorphismInplaceTmpBytesImpl<B>,
297{
298    fn vec_znx_big_automorphism_inplace_tmp_bytes(&self) -> usize {
299        B::vec_znx_big_automorphism_inplace_tmp_bytes_impl(self)
300    }
301}
302
303impl<B> VecZnxBigAutomorphismInplace<B> for Module<B>
304where
305    B: Backend + VecZnxBigAutomorphismInplaceImpl<B>,
306{
307    fn vec_znx_big_automorphism_inplace<A>(&self, k: i64, a: &mut A, a_col: usize, scratch: &mut Scratch<B>)
308    where
309        A: VecZnxBigToMut<B>,
310    {
311        B::vec_znx_big_automorphism_inplace_impl(self, k, a, a_col, scratch);
312    }
313}