1use crate::layouts::{
2 Backend, ScratchArena, VecZnxBackendMut, VecZnxBackendRef, VecZnxBigBackendMut, VecZnxDftBackendMut, VecZnxDftBackendRef,
3 VecZnxDftOwned,
4};
5
6pub trait VecZnxDftAlloc<B: Backend> {
8 fn vec_znx_dft_alloc(&self, cols: usize, size: usize) -> VecZnxDftOwned<B>;
9}
10
11pub trait VecZnxDftFromBytes<B: Backend> {
13 fn vec_znx_dft_from_bytes(&self, cols: usize, size: usize, bytes: Vec<u8>) -> VecZnxDftOwned<B>;
14}
15
16pub trait VecZnxDftBytesOf {
18 fn bytes_of_vec_znx_dft(&self, cols: usize, size: usize) -> usize;
19}
20
21pub trait VecZnxDftApply<B: Backend> {
27 fn vec_znx_dft_apply(
28 &self,
29 step: usize,
30 offset: usize,
31 res: &mut VecZnxDftBackendMut<'_, B>,
32 res_col: usize,
33 a: &VecZnxBackendRef<'_, B>,
34 a_col: usize,
35 );
36}
37
38pub trait VecZnxIdftApplyTmpBytes {
40 fn vec_znx_idft_apply_tmp_bytes(&self) -> usize;
41}
42
43pub trait VecZnxIdftApply<B: Backend> {
46 fn vec_znx_idft_apply(
47 &self,
48 res: &mut VecZnxBigBackendMut<'_, B>,
49 res_col: usize,
50 a: &VecZnxDftBackendRef<'_, B>,
51 a_col: usize,
52 scratch: &mut ScratchArena<'_, B>,
53 );
54}
55
56pub trait VecZnxIdftApplyTmpA<B: Backend> {
58 fn vec_znx_idft_apply_tmpa(
59 &self,
60 res: &mut VecZnxBigBackendMut<'_, B>,
61 res_col: usize,
62 a: &mut VecZnxDftBackendMut<'_, B>,
63 a_col: usize,
64 );
65}
66
67pub trait VecZnxIdftNormalizeConsumeTmpBytes {
69 fn vec_znx_idft_normalize_consume_tmp_bytes(&self, res_size: usize, a_size: usize) -> usize;
70}
71
72pub trait VecZnxIdftNormalizeConsume<B: Backend> {
75 #[allow(clippy::too_many_arguments)]
76 fn vec_znx_idft_normalize_consume(
77 &self,
78 res: &mut VecZnxBackendMut<'_, B>,
79 res_base2k: usize,
80 res_k: usize,
81 res_col: usize,
82 a: &mut VecZnxDftBackendMut<'_, B>,
83 a_col: usize,
84 a_base2k: usize,
85 addend: Option<(&VecZnxBackendRef<'_, B>, usize)>,
86 scratch: &mut ScratchArena<'_, B>,
87 );
88}
89
90pub trait VecZnxDftAddInto<B: Backend> {
92 fn vec_znx_dft_add_into(
93 &self,
94 res: &mut VecZnxDftBackendMut<'_, B>,
95 res_col: usize,
96 a: &VecZnxDftBackendRef<'_, B>,
97 a_col: usize,
98 b: &VecZnxDftBackendRef<'_, B>,
99 b_col: usize,
100 );
101}
102
103pub trait VecZnxDftAddAssign<B: Backend> {
105 fn vec_znx_dft_add_assign(
106 &self,
107 res: &mut VecZnxDftBackendMut<'_, B>,
108 res_col: usize,
109 a: &VecZnxDftBackendRef<'_, B>,
110 a_col: usize,
111 );
112}
113
114pub trait VecZnxDftAddScaledAssign<B: Backend> {
118 fn vec_znx_dft_add_scaled_assign(
119 &self,
120 res: &mut VecZnxDftBackendMut<'_, B>,
121 res_col: usize,
122 a: &VecZnxDftBackendRef<'_, B>,
123 a_col: usize,
124 a_scale: i64,
125 );
126}
127
128pub trait VecZnxDftSub<B: Backend> {
130 fn vec_znx_dft_sub(
131 &self,
132 res: &mut VecZnxDftBackendMut<'_, B>,
133 res_col: usize,
134 a: &VecZnxDftBackendRef<'_, B>,
135 a_col: usize,
136 b: &VecZnxDftBackendRef<'_, B>,
137 b_col: usize,
138 );
139}
140
141pub trait VecZnxDftSubAssign<B: Backend> {
143 fn vec_znx_dft_sub_assign(
144 &self,
145 res: &mut VecZnxDftBackendMut<'_, B>,
146 res_col: usize,
147 a: &VecZnxDftBackendRef<'_, B>,
148 a_col: usize,
149 );
150}
151
152pub trait VecZnxDftSubNegateAssign<B: Backend> {
154 fn vec_znx_dft_sub_negate_assign(
155 &self,
156 res: &mut VecZnxDftBackendMut<'_, B>,
157 res_col: usize,
158 a: &VecZnxDftBackendRef<'_, B>,
159 a_col: usize,
160 );
161}
162
163pub trait VecZnxDftCopy<B: Backend> {
167 fn vec_znx_dft_copy(
168 &self,
169 step: usize,
170 offset: usize,
171 res: &mut VecZnxDftBackendMut<'_, B>,
172 res_col: usize,
173 a: &VecZnxDftBackendRef<'_, B>,
174 a_col: usize,
175 );
176}
177
178pub trait VecZnxDftZero<B: Backend> {
180 fn vec_znx_dft_zero(&self, res: &mut VecZnxDftBackendMut<'_, B>, res_col: usize);
181}
182
183pub trait VecZnxDftAutomorphismPlan<B: Backend> {
193 type Plan;
194
195 fn vec_znx_dft_automorphism_plan(&self, p: i64) -> Self::Plan;
196}
197
198pub trait VecZnxDftAutomorphism<B: Backend>: VecZnxDftAutomorphismPlan<B> {
201 fn vec_znx_dft_automorphism_with_plan(
202 &self,
203 plan: &Self::Plan,
204 res: &mut VecZnxDftBackendMut<'_, B>,
205 res_col: usize,
206 a: &VecZnxDftBackendRef<'_, B>,
207 a_col: usize,
208 );
209
210 #[allow(clippy::too_many_arguments)]
212 fn vec_znx_dft_automorphism_add_with_plan(
213 &self,
214 plan: &Self::Plan,
215 res: &mut VecZnxDftBackendMut<'_, B>,
216 res_col: usize,
217 a: &VecZnxDftBackendRef<'_, B>,
218 a_col: usize,
219 );
220
221 fn vec_znx_dft_automorphism(
225 &self,
226 p: i64,
227 res: &mut VecZnxDftBackendMut<'_, B>,
228 res_col: usize,
229 a: &VecZnxDftBackendRef<'_, B>,
230 a_col: usize,
231 ) {
232 let plan = self.vec_znx_dft_automorphism_plan(p);
233 self.vec_znx_dft_automorphism_with_plan(&plan, res, res_col, a, a_col);
234 }
235}