poulpy/poulpy-cpu-ref/src/znx.rs
poulpy-cpu-ref/src/znx.rsRaw
1use poulpy_hal::reference::znx::{
2 ZnxAdd, ZnxAddInplace, ZnxAutomorphism, ZnxCopy, ZnxExtractDigitAddMul, ZnxMulAddPowerOfTwo, ZnxMulPowerOfTwo,
3 ZnxMulPowerOfTwoInplace, ZnxNegate, ZnxNegateInplace, ZnxNormalizeDigit, ZnxNormalizeFinalStep, ZnxNormalizeFinalStepInplace,
4 ZnxNormalizeFirstStep, ZnxNormalizeFirstStepCarryOnly, ZnxNormalizeFirstStepInplace, ZnxNormalizeMiddleStep,
5 ZnxNormalizeMiddleStepCarryOnly, ZnxNormalizeMiddleStepInplace, ZnxRotate, ZnxSub, ZnxSubInplace, ZnxSubNegateInplace,
6 ZnxSwitchRing, ZnxZero, znx_add_inplace_ref, znx_add_ref, znx_automorphism_ref, znx_copy_ref, znx_extract_digit_addmul_ref,
7 znx_mul_add_power_of_two_ref, znx_mul_power_of_two_inplace_ref, znx_mul_power_of_two_ref, znx_negate_inplace_ref,
8 znx_negate_ref, znx_normalize_digit_ref, znx_normalize_final_step_inplace_ref, znx_normalize_final_step_ref,
9 znx_normalize_first_step_carry_only_ref, znx_normalize_first_step_inplace_ref, znx_normalize_first_step_ref,
10 znx_normalize_middle_step_carry_only_ref, znx_normalize_middle_step_inplace_ref, znx_normalize_middle_step_ref, znx_rotate,
11 znx_sub_inplace_ref, znx_sub_negate_inplace_ref, znx_sub_ref, znx_switch_ring_ref, znx_zero_ref,
12};
13
14use crate::FFT64Ref;
15
16impl ZnxAdd for FFT64Ref {
17 #[inline(always)]
18 fn znx_add(res: &mut [i64], a: &[i64], b: &[i64]) {
19 znx_add_ref(res, a, b);
20 }
21}
22
23impl ZnxAddInplace for FFT64Ref {
24 #[inline(always)]
25 fn znx_add_inplace(res: &mut [i64], a: &[i64]) {
26 znx_add_inplace_ref(res, a);
27 }
28}
29
30impl ZnxSub for FFT64Ref {
31 #[inline(always)]
32 fn znx_sub(res: &mut [i64], a: &[i64], b: &[i64]) {
33 znx_sub_ref(res, a, b);
34 }
35}
36
37impl ZnxSubInplace for FFT64Ref {
38 #[inline(always)]
39 fn znx_sub_inplace(res: &mut [i64], a: &[i64]) {
40 znx_sub_inplace_ref(res, a);
41 }
42}
43
44impl ZnxSubNegateInplace for FFT64Ref {
45 #[inline(always)]
46 fn znx_sub_negate_inplace(res: &mut [i64], a: &[i64]) {
47 znx_sub_negate_inplace_ref(res, a);
48 }
49}
50
51impl ZnxMulAddPowerOfTwo for FFT64Ref {
52 #[inline(always)]
53 fn znx_muladd_power_of_two(k: i64, res: &mut [i64], a: &[i64]) {
54 znx_mul_add_power_of_two_ref(k, res, a);
55 }
56}
57
58impl ZnxMulPowerOfTwo for FFT64Ref {
59 #[inline(always)]
60 fn znx_mul_power_of_two(k: i64, res: &mut [i64], a: &[i64]) {
61 znx_mul_power_of_two_ref(k, res, a);
62 }
63}
64
65impl ZnxMulPowerOfTwoInplace for FFT64Ref {
66 #[inline(always)]
67 fn znx_mul_power_of_two_inplace(k: i64, res: &mut [i64]) {
68 znx_mul_power_of_two_inplace_ref(k, res);
69 }
70}
71
72impl ZnxAutomorphism for FFT64Ref {
73 #[inline(always)]
74 fn znx_automorphism(p: i64, res: &mut [i64], a: &[i64]) {
75 znx_automorphism_ref(p, res, a);
76 }
77}
78
79impl ZnxCopy for FFT64Ref {
80 #[inline(always)]
81 fn znx_copy(res: &mut [i64], a: &[i64]) {
82 znx_copy_ref(res, a);
83 }
84}
85
86impl ZnxNegate for FFT64Ref {
87 #[inline(always)]
88 fn znx_negate(res: &mut [i64], src: &[i64]) {
89 znx_negate_ref(res, src);
90 }
91}
92
93impl ZnxNegateInplace for FFT64Ref {
94 #[inline(always)]
95 fn znx_negate_inplace(res: &mut [i64]) {
96 znx_negate_inplace_ref(res);
97 }
98}
99
100impl ZnxRotate for FFT64Ref {
101 #[inline(always)]
102 fn znx_rotate(p: i64, res: &mut [i64], src: &[i64]) {
103 znx_rotate::<Self>(p, res, src);
104 }
105}
106
107impl ZnxZero for FFT64Ref {
108 #[inline(always)]
109 fn znx_zero(res: &mut [i64]) {
110 znx_zero_ref(res);
111 }
112}
113
114impl ZnxSwitchRing for FFT64Ref {
115 #[inline(always)]
116 fn znx_switch_ring(res: &mut [i64], a: &[i64]) {
117 znx_switch_ring_ref(res, a);
118 }
119}
120
121impl ZnxNormalizeFinalStep for FFT64Ref {
122 #[inline(always)]
123 fn znx_normalize_final_step(base2k: usize, lsh: usize, x: &mut [i64], a: &[i64], carry: &mut [i64]) {
124 znx_normalize_final_step_ref(base2k, lsh, x, a, carry);
125 }
126}
127
128impl ZnxNormalizeFinalStepInplace for FFT64Ref {
129 #[inline(always)]
130 fn znx_normalize_final_step_inplace(base2k: usize, lsh: usize, x: &mut [i64], carry: &mut [i64]) {
131 znx_normalize_final_step_inplace_ref(base2k, lsh, x, carry);
132 }
133}
134
135impl ZnxNormalizeFirstStep for FFT64Ref {
136 #[inline(always)]
137 fn znx_normalize_first_step(base2k: usize, lsh: usize, x: &mut [i64], a: &[i64], carry: &mut [i64]) {
138 znx_normalize_first_step_ref(base2k, lsh, x, a, carry);
139 }
140}
141
142impl ZnxNormalizeFirstStepCarryOnly for FFT64Ref {
143 #[inline(always)]
144 fn znx_normalize_first_step_carry_only(base2k: usize, lsh: usize, x: &[i64], carry: &mut [i64]) {
145 znx_normalize_first_step_carry_only_ref(base2k, lsh, x, carry);
146 }
147}
148
149impl ZnxNormalizeFirstStepInplace for FFT64Ref {
150 #[inline(always)]
151 fn znx_normalize_first_step_inplace(base2k: usize, lsh: usize, x: &mut [i64], carry: &mut [i64]) {
152 znx_normalize_first_step_inplace_ref(base2k, lsh, x, carry);
153 }
154}
155
156impl ZnxNormalizeMiddleStep for FFT64Ref {
157 #[inline(always)]
158 fn znx_normalize_middle_step(base2k: usize, lsh: usize, x: &mut [i64], a: &[i64], carry: &mut [i64]) {
159 znx_normalize_middle_step_ref(base2k, lsh, x, a, carry);
160 }
161}
162
163impl ZnxNormalizeMiddleStepCarryOnly for FFT64Ref {
164 #[inline(always)]
165 fn znx_normalize_middle_step_carry_only(base2k: usize, lsh: usize, x: &[i64], carry: &mut [i64]) {
166 znx_normalize_middle_step_carry_only_ref(base2k, lsh, x, carry);
167 }
168}
169
170impl ZnxNormalizeMiddleStepInplace for FFT64Ref {
171 #[inline(always)]
172 fn znx_normalize_middle_step_inplace(base2k: usize, lsh: usize, x: &mut [i64], carry: &mut [i64]) {
173 znx_normalize_middle_step_inplace_ref(base2k, lsh, x, carry);
174 }
175}
176
177impl ZnxExtractDigitAddMul for FFT64Ref {
178 #[inline(always)]
179 fn znx_extract_digit_addmul(base2k: usize, lsh: usize, res: &mut [i64], src: &mut [i64]) {
180 znx_extract_digit_addmul_ref(base2k, lsh, res, src);
181 }
182}
183
184impl ZnxNormalizeDigit for FFT64Ref {
185 #[inline(always)]
186 fn znx_normalize_digit(base2k: usize, res: &mut [i64], src: &mut [i64]) {
187 znx_normalize_digit_ref(base2k, res, src);
188 }
189}