poulpy_hal/delegates/
vec_znx_dft.rs

1use crate::{
2    api::{
3        VecZnxDftAdd, VecZnxDftAddInplace, VecZnxDftAddScaledInplace, VecZnxDftAlloc, VecZnxDftApply, VecZnxDftBytesOf,
4        VecZnxDftCopy, VecZnxDftFromBytes, VecZnxDftSub, VecZnxDftSubInplace, VecZnxDftSubNegateInplace, VecZnxDftZero,
5        VecZnxIdftApply, VecZnxIdftApplyConsume, VecZnxIdftApplyTmpA, VecZnxIdftApplyTmpBytes,
6    },
7    layouts::{
8        Backend, Data, Module, Scratch, VecZnxBig, VecZnxBigToMut, VecZnxDft, VecZnxDftOwned, VecZnxDftToMut, VecZnxDftToRef,
9        VecZnxToRef,
10    },
11    oep::{
12        VecZnxDftAddImpl, VecZnxDftAddInplaceImpl, VecZnxDftAddScaledInplaceImpl, VecZnxDftAllocBytesImpl, VecZnxDftAllocImpl,
13        VecZnxDftApplyImpl, VecZnxDftCopyImpl, VecZnxDftFromBytesImpl, VecZnxDftSubImpl, VecZnxDftSubInplaceImpl,
14        VecZnxDftSubNegateInplaceImpl, VecZnxDftZeroImpl, VecZnxIdftApplyConsumeImpl, VecZnxIdftApplyImpl,
15        VecZnxIdftApplyTmpAImpl, VecZnxIdftApplyTmpBytesImpl,
16    },
17};
18
19impl<B> VecZnxDftFromBytes<B> for Module<B>
20where
21    B: Backend + VecZnxDftFromBytesImpl<B>,
22{
23    fn vec_znx_dft_from_bytes(&self, cols: usize, size: usize, bytes: Vec<u8>) -> VecZnxDftOwned<B> {
24        B::vec_znx_dft_from_bytes_impl(self.n(), cols, size, bytes)
25    }
26}
27
28impl<B> VecZnxDftBytesOf for Module<B>
29where
30    B: Backend + VecZnxDftAllocBytesImpl<B>,
31{
32    fn bytes_of_vec_znx_dft(&self, cols: usize, size: usize) -> usize {
33        B::vec_znx_dft_bytes_of_impl(self.n(), cols, size)
34    }
35}
36
37impl<B> VecZnxDftAlloc<B> for Module<B>
38where
39    B: Backend + VecZnxDftAllocImpl<B>,
40{
41    fn vec_znx_dft_alloc(&self, cols: usize, size: usize) -> VecZnxDftOwned<B> {
42        B::vec_znx_dft_alloc_impl(self.n(), cols, size)
43    }
44}
45
46impl<B> VecZnxIdftApplyTmpBytes for Module<B>
47where
48    B: Backend + VecZnxIdftApplyTmpBytesImpl<B>,
49{
50    fn vec_znx_idft_apply_tmp_bytes(&self) -> usize {
51        B::vec_znx_idft_apply_tmp_bytes_impl(self)
52    }
53}
54
55impl<B> VecZnxIdftApply<B> for Module<B>
56where
57    B: Backend + VecZnxIdftApplyImpl<B>,
58{
59    fn vec_znx_idft_apply<R, A>(&self, res: &mut R, res_col: usize, a: &A, a_col: usize, scratch: &mut Scratch<B>)
60    where
61        R: VecZnxBigToMut<B>,
62        A: VecZnxDftToRef<B>,
63    {
64        B::vec_znx_idft_apply_impl(self, res, res_col, a, a_col, scratch);
65    }
66}
67
68impl<B> VecZnxIdftApplyTmpA<B> for Module<B>
69where
70    B: Backend + VecZnxIdftApplyTmpAImpl<B>,
71{
72    fn vec_znx_idft_apply_tmpa<R, A>(&self, res: &mut R, res_col: usize, a: &mut A, a_col: usize)
73    where
74        R: VecZnxBigToMut<B>,
75        A: VecZnxDftToMut<B>,
76    {
77        B::vec_znx_idft_apply_tmpa_impl(self, res, res_col, a, a_col);
78    }
79}
80
81impl<B> VecZnxIdftApplyConsume<B> for Module<B>
82where
83    B: Backend + VecZnxIdftApplyConsumeImpl<B>,
84{
85    fn vec_znx_idft_apply_consume<D: Data>(&self, a: VecZnxDft<D, B>) -> VecZnxBig<D, B>
86    where
87        VecZnxDft<D, B>: VecZnxDftToMut<B>,
88    {
89        B::vec_znx_idft_apply_consume_impl(self, a)
90    }
91}
92
93impl<B> VecZnxDftApply<B> for Module<B>
94where
95    B: Backend + VecZnxDftApplyImpl<B>,
96{
97    fn vec_znx_dft_apply<R, A>(&self, step: usize, offset: usize, res: &mut R, res_col: usize, a: &A, a_col: usize)
98    where
99        R: VecZnxDftToMut<B>,
100        A: VecZnxToRef,
101    {
102        B::vec_znx_dft_apply_impl(self, step, offset, res, res_col, a, a_col);
103    }
104}
105
106impl<B> VecZnxDftAdd<B> for Module<B>
107where
108    B: Backend + VecZnxDftAddImpl<B>,
109{
110    fn vec_znx_dft_add<R, A, D>(&self, res: &mut R, res_col: usize, a: &A, a_col: usize, b: &D, b_col: usize)
111    where
112        R: VecZnxDftToMut<B>,
113        A: VecZnxDftToRef<B>,
114        D: VecZnxDftToRef<B>,
115    {
116        B::vec_znx_dft_add_impl(self, res, res_col, a, a_col, b, b_col);
117    }
118}
119
120impl<B> VecZnxDftAddInplace<B> for Module<B>
121where
122    B: Backend + VecZnxDftAddInplaceImpl<B>,
123{
124    fn vec_znx_dft_add_inplace<R, A>(&self, res: &mut R, res_col: usize, a: &A, a_col: usize)
125    where
126        R: VecZnxDftToMut<B>,
127        A: VecZnxDftToRef<B>,
128    {
129        B::vec_znx_dft_add_inplace_impl(self, res, res_col, a, a_col);
130    }
131}
132
133impl<B> VecZnxDftAddScaledInplace<B> for Module<B>
134where
135    B: Backend + VecZnxDftAddScaledInplaceImpl<B>,
136{
137    fn vec_znx_dft_add_scaled_inplace<R, A>(&self, res: &mut R, res_col: usize, a: &A, a_col: usize, a_scale: i64)
138    where
139        R: VecZnxDftToMut<B>,
140        A: VecZnxDftToRef<B>,
141    {
142        B::vec_znx_dft_add_scaled_inplace_impl(self, res, res_col, a, a_col, a_scale);
143    }
144}
145
146impl<B> VecZnxDftSub<B> for Module<B>
147where
148    B: Backend + VecZnxDftSubImpl<B>,
149{
150    fn vec_znx_dft_sub<R, A, D>(&self, res: &mut R, res_col: usize, a: &A, a_col: usize, b: &D, b_col: usize)
151    where
152        R: VecZnxDftToMut<B>,
153        A: VecZnxDftToRef<B>,
154        D: VecZnxDftToRef<B>,
155    {
156        B::vec_znx_dft_sub_impl(self, res, res_col, a, a_col, b, b_col);
157    }
158}
159
160impl<B> VecZnxDftSubInplace<B> for Module<B>
161where
162    B: Backend + VecZnxDftSubInplaceImpl<B>,
163{
164    fn vec_znx_dft_sub_inplace<R, A>(&self, res: &mut R, res_col: usize, a: &A, a_col: usize)
165    where
166        R: VecZnxDftToMut<B>,
167        A: VecZnxDftToRef<B>,
168    {
169        B::vec_znx_dft_sub_inplace_impl(self, res, res_col, a, a_col);
170    }
171}
172
173impl<B> VecZnxDftSubNegateInplace<B> for Module<B>
174where
175    B: Backend + VecZnxDftSubNegateInplaceImpl<B>,
176{
177    fn vec_znx_dft_sub_negate_inplace<R, A>(&self, res: &mut R, res_col: usize, a: &A, a_col: usize)
178    where
179        R: VecZnxDftToMut<B>,
180        A: VecZnxDftToRef<B>,
181    {
182        B::vec_znx_dft_sub_negate_inplace_impl(self, res, res_col, a, a_col);
183    }
184}
185
186impl<B> VecZnxDftCopy<B> for Module<B>
187where
188    B: Backend + VecZnxDftCopyImpl<B>,
189{
190    fn vec_znx_dft_copy<R, A>(&self, step: usize, offset: usize, res: &mut R, res_col: usize, a: &A, a_col: usize)
191    where
192        R: VecZnxDftToMut<B>,
193        A: VecZnxDftToRef<B>,
194    {
195        B::vec_znx_dft_copy_impl(self, step, offset, res, res_col, a, a_col);
196    }
197}
198
199impl<B> VecZnxDftZero<B> for Module<B>
200where
201    B: Backend + VecZnxDftZeroImpl<B>,
202{
203    fn vec_znx_dft_zero<R>(&self, res: &mut R)
204    where
205        R: VecZnxDftToMut<B>,
206    {
207        B::vec_znx_dft_zero_impl(self, res);
208    }
209}