1use crate::{
2 api::{
3 DFT, IDFT, IDFTConsume, IDFTTmpA, VecZnxDftAdd, VecZnxDftAddInplace, VecZnxDftAlloc, VecZnxDftAllocBytes, VecZnxDftCopy,
4 VecZnxDftFromBytes, VecZnxDftSub, VecZnxDftSubABInplace, VecZnxDftSubBAInplace, VecZnxDftZero, VecZnxIDFTTmpBytes,
5 },
6 layouts::{
7 Backend, Data, Module, Scratch, VecZnxBig, VecZnxBigToMut, VecZnxDft, VecZnxDftOwned, VecZnxDftToMut, VecZnxDftToRef,
8 VecZnxToRef,
9 },
10 oep::{
11 DFTImpl, IDFTConsumeImpl, IDFTImpl, IDFTTmpAImpl, VecZnxDftAddImpl, VecZnxDftAddInplaceImpl, VecZnxDftAllocBytesImpl,
12 VecZnxDftAllocImpl, VecZnxDftCopyImpl, VecZnxDftFromBytesImpl, VecZnxDftSubABInplaceImpl, VecZnxDftSubBAInplaceImpl,
13 VecZnxDftSubImpl, VecZnxDftZeroImpl, VecZnxIDFTTmpBytesImpl,
14 },
15};
16
17impl<B> VecZnxDftFromBytes<B> for Module<B>
18where
19 B: Backend + VecZnxDftFromBytesImpl<B>,
20{
21 fn vec_znx_dft_from_bytes(&self, cols: usize, size: usize, bytes: Vec<u8>) -> VecZnxDftOwned<B> {
22 B::vec_znx_dft_from_bytes_impl(self.n(), cols, size, bytes)
23 }
24}
25
26impl<B> VecZnxDftAllocBytes for Module<B>
27where
28 B: Backend + VecZnxDftAllocBytesImpl<B>,
29{
30 fn vec_znx_dft_alloc_bytes(&self, cols: usize, size: usize) -> usize {
31 B::vec_znx_dft_alloc_bytes_impl(self.n(), cols, size)
32 }
33}
34
35impl<B> VecZnxDftAlloc<B> for Module<B>
36where
37 B: Backend + VecZnxDftAllocImpl<B>,
38{
39 fn vec_znx_dft_alloc(&self, cols: usize, size: usize) -> VecZnxDftOwned<B> {
40 B::vec_znx_dft_alloc_impl(self.n(), cols, size)
41 }
42}
43
44impl<B> VecZnxIDFTTmpBytes for Module<B>
45where
46 B: Backend + VecZnxIDFTTmpBytesImpl<B>,
47{
48 fn vec_znx_idft_tmp_bytes(&self) -> usize {
49 B::vec_znx_idft_tmp_bytes_impl(self)
50 }
51}
52
53impl<B> IDFT<B> for Module<B>
54where
55 B: Backend + IDFTImpl<B>,
56{
57 fn idft<R, A>(&self, res: &mut R, res_col: usize, a: &A, a_col: usize, scratch: &mut Scratch<B>)
58 where
59 R: VecZnxBigToMut<B>,
60 A: VecZnxDftToRef<B>,
61 {
62 B::idft_impl(self, res, res_col, a, a_col, scratch);
63 }
64}
65
66impl<B> IDFTTmpA<B> for Module<B>
67where
68 B: Backend + IDFTTmpAImpl<B>,
69{
70 fn idft_tmp_a<R, A>(&self, res: &mut R, res_col: usize, a: &mut A, a_col: usize)
71 where
72 R: VecZnxBigToMut<B>,
73 A: VecZnxDftToMut<B>,
74 {
75 B::idft_tmp_a_impl(self, res, res_col, a, a_col);
76 }
77}
78
79impl<B> IDFTConsume<B> for Module<B>
80where
81 B: Backend + IDFTConsumeImpl<B>,
82{
83 fn vec_znx_idft_consume<D: Data>(&self, a: VecZnxDft<D, B>) -> VecZnxBig<D, B>
84 where
85 VecZnxDft<D, B>: VecZnxDftToMut<B>,
86 {
87 B::idft_consume_impl(self, a)
88 }
89}
90
91impl<B> DFT<B> for Module<B>
92where
93 B: Backend + DFTImpl<B>,
94{
95 fn dft<R, A>(&self, step: usize, offset: usize, res: &mut R, res_col: usize, a: &A, a_col: usize)
96 where
97 R: VecZnxDftToMut<B>,
98 A: VecZnxToRef,
99 {
100 B::dft_impl(self, step, offset, res, res_col, a, a_col);
101 }
102}
103
104impl<B> VecZnxDftAdd<B> for Module<B>
105where
106 B: Backend + VecZnxDftAddImpl<B>,
107{
108 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)
109 where
110 R: VecZnxDftToMut<B>,
111 A: VecZnxDftToRef<B>,
112 D: VecZnxDftToRef<B>,
113 {
114 B::vec_znx_dft_add_impl(self, res, res_col, a, a_col, b, b_col);
115 }
116}
117
118impl<B> VecZnxDftAddInplace<B> for Module<B>
119where
120 B: Backend + VecZnxDftAddInplaceImpl<B>,
121{
122 fn vec_znx_dft_add_inplace<R, A>(&self, res: &mut R, res_col: usize, a: &A, a_col: usize)
123 where
124 R: VecZnxDftToMut<B>,
125 A: VecZnxDftToRef<B>,
126 {
127 B::vec_znx_dft_add_inplace_impl(self, res, res_col, a, a_col);
128 }
129}
130
131impl<B> VecZnxDftSub<B> for Module<B>
132where
133 B: Backend + VecZnxDftSubImpl<B>,
134{
135 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)
136 where
137 R: VecZnxDftToMut<B>,
138 A: VecZnxDftToRef<B>,
139 D: VecZnxDftToRef<B>,
140 {
141 B::vec_znx_dft_sub_impl(self, res, res_col, a, a_col, b, b_col);
142 }
143}
144
145impl<B> VecZnxDftSubABInplace<B> for Module<B>
146where
147 B: Backend + VecZnxDftSubABInplaceImpl<B>,
148{
149 fn vec_znx_dft_sub_ab_inplace<R, A>(&self, res: &mut R, res_col: usize, a: &A, a_col: usize)
150 where
151 R: VecZnxDftToMut<B>,
152 A: VecZnxDftToRef<B>,
153 {
154 B::vec_znx_dft_sub_ab_inplace_impl(self, res, res_col, a, a_col);
155 }
156}
157
158impl<B> VecZnxDftSubBAInplace<B> for Module<B>
159where
160 B: Backend + VecZnxDftSubBAInplaceImpl<B>,
161{
162 fn vec_znx_dft_sub_ba_inplace<R, A>(&self, res: &mut R, res_col: usize, a: &A, a_col: usize)
163 where
164 R: VecZnxDftToMut<B>,
165 A: VecZnxDftToRef<B>,
166 {
167 B::vec_znx_dft_sub_ba_inplace_impl(self, res, res_col, a, a_col);
168 }
169}
170
171impl<B> VecZnxDftCopy<B> for Module<B>
172where
173 B: Backend + VecZnxDftCopyImpl<B>,
174{
175 fn vec_znx_dft_copy<R, A>(&self, step: usize, offset: usize, res: &mut R, res_col: usize, a: &A, a_col: usize)
176 where
177 R: VecZnxDftToMut<B>,
178 A: VecZnxDftToRef<B>,
179 {
180 B::vec_znx_dft_copy_impl(self, step, offset, res, res_col, a, a_col);
181 }
182}
183
184impl<B> VecZnxDftZero<B> for Module<B>
185where
186 B: Backend + VecZnxDftZeroImpl<B>,
187{
188 fn vec_znx_dft_zero<R>(&self, res: &mut R)
189 where
190 R: VecZnxDftToMut<B>,
191 {
192 B::vec_znx_dft_zero_impl(self, res);
193 }
194}