1use crate::{
2 layouts::{Backend, ScalarZnxToRef, Scratch, VecZnxToMut, VecZnxToRef},
3 source::Source,
4};
5
6pub trait VecZnxNormalizeTmpBytes {
7 fn vec_znx_normalize_tmp_bytes(&self) -> usize;
9}
10
11pub trait VecZnxZero {
12 fn vec_znx_zero<R>(&self, res: &mut R, res_col: usize)
13 where
14 R: VecZnxToMut;
15}
16
17pub trait VecZnxNormalize<B: Backend> {
18 #[allow(clippy::too_many_arguments)]
19 fn vec_znx_normalize<R, A>(
21 &self,
22 res_basek: usize,
23 res: &mut R,
24 res_col: usize,
25 a_basek: usize,
26 a: &A,
27 a_col: usize,
28 scratch: &mut Scratch<B>,
29 ) where
30 R: VecZnxToMut,
31 A: VecZnxToRef;
32}
33
34pub trait VecZnxNormalizeInplace<B: Backend> {
35 fn vec_znx_normalize_inplace<A>(&self, base2k: usize, a: &mut A, a_col: usize, scratch: &mut Scratch<B>)
37 where
38 A: VecZnxToMut;
39}
40
41pub trait VecZnxAdd {
42 fn vec_znx_add<R, A, B>(&self, res: &mut R, res_col: usize, a: &A, a_col: usize, b: &B, b_col: usize)
44 where
45 R: VecZnxToMut,
46 A: VecZnxToRef,
47 B: VecZnxToRef;
48}
49
50pub trait VecZnxAddInplace {
51 fn vec_znx_add_inplace<R, A>(&self, res: &mut R, res_col: usize, a: &A, a_col: usize)
53 where
54 R: VecZnxToMut,
55 A: VecZnxToRef;
56}
57
58pub trait VecZnxAddScalar {
59 #[allow(clippy::too_many_arguments)]
61 fn vec_znx_add_scalar<R, A, B>(&self, res: &mut R, res_col: usize, a: &A, a_col: usize, b: &B, b_col: usize, b_limb: usize)
62 where
63 R: VecZnxToMut,
64 A: ScalarZnxToRef,
65 B: VecZnxToRef;
66}
67
68pub trait VecZnxAddScalarInplace {
69 fn vec_znx_add_scalar_inplace<R, A>(&self, res: &mut R, res_col: usize, res_limb: usize, a: &A, a_col: usize)
71 where
72 R: VecZnxToMut,
73 A: ScalarZnxToRef;
74}
75
76pub trait VecZnxSub {
77 fn vec_znx_sub<R, A, B>(&self, res: &mut R, res_col: usize, a: &A, a_col: usize, b: &B, b_col: usize)
79 where
80 R: VecZnxToMut,
81 A: VecZnxToRef,
82 B: VecZnxToRef;
83}
84
85pub trait VecZnxSubInplace {
86 fn vec_znx_sub_inplace<R, A>(&self, res: &mut R, res_col: usize, a: &A, a_col: usize)
90 where
91 R: VecZnxToMut,
92 A: VecZnxToRef;
93}
94
95pub trait VecZnxSubNegateInplace {
96 fn vec_znx_sub_negate_inplace<R, A>(&self, res: &mut R, res_col: usize, a: &A, a_col: usize)
100 where
101 R: VecZnxToMut,
102 A: VecZnxToRef;
103}
104
105pub trait VecZnxSubScalar {
106 #[allow(clippy::too_many_arguments)]
108 fn vec_znx_sub_scalar<R, A, B>(&self, res: &mut R, res_col: usize, a: &A, a_col: usize, b: &B, b_col: usize, b_limb: usize)
109 where
110 R: VecZnxToMut,
111 A: ScalarZnxToRef,
112 B: VecZnxToRef;
113}
114
115pub trait VecZnxSubScalarInplace {
116 fn vec_znx_sub_scalar_inplace<R, A>(&self, res: &mut R, res_col: usize, res_limb: usize, a: &A, a_col: usize)
118 where
119 R: VecZnxToMut,
120 A: ScalarZnxToRef;
121}
122
123pub trait VecZnxNegate {
124 fn vec_znx_negate<R, A>(&self, res: &mut R, res_col: usize, a: &A, a_col: usize)
126 where
127 R: VecZnxToMut,
128 A: VecZnxToRef;
129}
130
131pub trait VecZnxNegateInplace {
132 fn vec_znx_negate_inplace<A>(&self, a: &mut A, a_col: usize)
134 where
135 A: VecZnxToMut;
136}
137
138pub trait VecZnxLshTmpBytes {
139 fn vec_znx_lsh_tmp_bytes(&self) -> usize;
140}
141
142pub trait VecZnxLsh<B: Backend> {
143 #[allow(clippy::too_many_arguments)]
145 fn vec_znx_lsh<R, A>(
146 &self,
147 base2k: usize,
148 k: usize,
149 r: &mut R,
150 res_col: usize,
151 a: &A,
152 a_col: usize,
153 scratch: &mut Scratch<B>,
154 ) where
155 R: VecZnxToMut,
156 A: VecZnxToRef;
157}
158
159pub trait VecZnxRshTmpBytes {
160 fn vec_znx_rsh_tmp_bytes(&self) -> usize;
161}
162
163pub trait VecZnxRsh<B: Backend> {
164 #[allow(clippy::too_many_arguments)]
166 fn vec_znx_rsh<R, A>(
167 &self,
168 base2k: usize,
169 k: usize,
170 r: &mut R,
171 res_col: usize,
172 a: &A,
173 a_col: usize,
174 scratch: &mut Scratch<B>,
175 ) where
176 R: VecZnxToMut,
177 A: VecZnxToRef;
178}
179
180pub trait VecZnxLshInplace<B: Backend> {
181 fn vec_znx_lsh_inplace<A>(&self, base2k: usize, k: usize, a: &mut A, a_col: usize, scratch: &mut Scratch<B>)
183 where
184 A: VecZnxToMut;
185}
186
187pub trait VecZnxRshInplace<B: Backend> {
188 fn vec_znx_rsh_inplace<A>(&self, base2k: usize, k: usize, a: &mut A, a_col: usize, scratch: &mut Scratch<B>)
190 where
191 A: VecZnxToMut;
192}
193
194pub trait VecZnxRotate {
195 fn vec_znx_rotate<R, A>(&self, p: i64, res: &mut R, res_col: usize, a: &A, a_col: usize)
197 where
198 R: VecZnxToMut,
199 A: VecZnxToRef;
200}
201
202pub trait VecZnxRotateInplaceTmpBytes {
203 fn vec_znx_rotate_inplace_tmp_bytes(&self) -> usize;
204}
205
206pub trait VecZnxRotateInplace<B: Backend> {
207 fn vec_znx_rotate_inplace<A>(&self, p: i64, a: &mut A, a_col: usize, scratch: &mut Scratch<B>)
209 where
210 A: VecZnxToMut;
211}
212
213pub trait VecZnxAutomorphism {
214 fn vec_znx_automorphism<R, A>(&self, k: i64, res: &mut R, res_col: usize, a: &A, a_col: usize)
216 where
217 R: VecZnxToMut,
218 A: VecZnxToRef;
219}
220
221pub trait VecZnxAutomorphismInplaceTmpBytes {
222 fn vec_znx_automorphism_inplace_tmp_bytes(&self) -> usize;
223}
224
225pub trait VecZnxAutomorphismInplace<B: Backend> {
226 fn vec_znx_automorphism_inplace<R>(&self, k: i64, res: &mut R, res_col: usize, scratch: &mut Scratch<B>)
228 where
229 R: VecZnxToMut;
230}
231
232pub trait VecZnxMulXpMinusOne {
233 fn vec_znx_mul_xp_minus_one<R, A>(&self, p: i64, res: &mut R, res_col: usize, a: &A, a_col: usize)
234 where
235 R: VecZnxToMut,
236 A: VecZnxToRef;
237}
238
239pub trait VecZnxMulXpMinusOneInplaceTmpBytes {
240 fn vec_znx_mul_xp_minus_one_inplace_tmp_bytes(&self) -> usize;
241}
242
243pub trait VecZnxMulXpMinusOneInplace<B: Backend> {
244 fn vec_znx_mul_xp_minus_one_inplace<R>(&self, p: i64, res: &mut R, res_col: usize, scratch: &mut Scratch<B>)
245 where
246 R: VecZnxToMut;
247}
248
249pub trait VecZnxSplitRingTmpBytes {
250 fn vec_znx_split_ring_tmp_bytes(&self) -> usize;
251}
252
253pub trait VecZnxSplitRing<B: Backend> {
254 fn vec_znx_split_ring<R, A>(&self, res: &mut [R], res_col: usize, a: &A, a_col: usize, scratch: &mut Scratch<B>)
261 where
262 R: VecZnxToMut,
263 A: VecZnxToRef;
264}
265
266pub trait VecZnxMergeRingsTmpBytes {
267 fn vec_znx_merge_rings_tmp_bytes(&self) -> usize;
268}
269
270pub trait VecZnxMergeRings<B: Backend> {
271 fn vec_znx_merge_rings<R, A>(&self, res: &mut R, res_col: usize, a: &[A], a_col: usize, scratch: &mut Scratch<B>)
278 where
279 R: VecZnxToMut,
280 A: VecZnxToRef;
281}
282
283pub trait VecZnxSwitchRing {
284 fn vec_znx_switch_ring<R, A>(&self, res: &mut R, res_col: usize, a: &A, col_a: usize)
285 where
286 R: VecZnxToMut,
287 A: VecZnxToRef;
288}
289
290pub trait VecZnxCopy {
291 fn vec_znx_copy<R, A>(&self, res: &mut R, res_col: usize, a: &A, a_col: usize)
292 where
293 R: VecZnxToMut,
294 A: VecZnxToRef;
295}
296
297pub trait VecZnxFillUniform {
298 fn vec_znx_fill_uniform<R>(&self, base2k: usize, res: &mut R, res_col: usize, source: &mut Source)
300 where
301 R: VecZnxToMut;
302}
303
304#[allow(clippy::too_many_arguments)]
305pub trait VecZnxFillNormal {
306 fn vec_znx_fill_normal<R>(
307 &self,
308 base2k: usize,
309 res: &mut R,
310 res_col: usize,
311 k: usize,
312 source: &mut Source,
313 sigma: f64,
314 bound: f64,
315 ) where
316 R: VecZnxToMut;
317}
318
319#[allow(clippy::too_many_arguments)]
320pub trait VecZnxAddNormal {
321 fn vec_znx_add_normal<R>(
323 &self,
324 base2k: usize,
325 res: &mut R,
326 res_col: usize,
327 k: usize,
328 source: &mut Source,
329 sigma: f64,
330 bound: f64,
331 ) where
332 R: VecZnxToMut;
333}