../../.cargo/katex-header.html

winter_math/fft/
real_u64.rs

1// Copyright (c) Facebook, Inc. and its affiliates.
2//
3// This source code is licensed under the MIT license found in the
4// LICENSE file in the root directory of this source tree.
5
6/// Real 2-FFT over u64 integers.
7#[inline(always)]
8pub fn fft2_real(x: [u64; 2]) -> [i64; 2] {
9    [(x[0] as i64 + x[1] as i64), (x[0] as i64 - x[1] as i64)]
10}
11
12/// Real 2-iFFT over u64 integers.
13/// Division by two to complete the inverse FFT is expected to be performed ***outside*** of this
14/// function.
15#[inline(always)]
16pub fn ifft2_real_unreduced(y: [i64; 2]) -> [u64; 2] {
17    [(y[0] + y[1]) as u64, (y[0] - y[1]) as u64]
18}
19
20/// Real 4-FFT over u64 integers.
21#[inline(always)]
22pub fn fft4_real(x: [u64; 4]) -> (i64, (i64, i64), i64) {
23    let [z0, z2] = fft2_real([x[0], x[2]]);
24    let [z1, z3] = fft2_real([x[1], x[3]]);
25    let y0 = z0 + z1;
26    let y1 = (z2, -z3);
27    let y2 = z0 - z1;
28    (y0, y1, y2)
29}
30
31/// Real 4-iFFT over u64 integers.
32/// Division by four to complete the inverse FFT is expected to be performed ***outside*** of this
33/// function.
34#[inline(always)]
35pub fn ifft4_real_unreduced(y: (i64, (i64, i64), i64)) -> [u64; 4] {
36    let z0 = y.0 + y.2;
37    let z1 = y.0 - y.2;
38    let z2 = y.1 .0;
39    let z3 = -y.1 .1;
40
41    let [x0, x2] = ifft2_real_unreduced([z0, z2]);
42    let [x1, x3] = ifft2_real_unreduced([z1, z3]);
43
44    [x0, x1, x2, x3]
45}