yum/vfft

git clone https://git.yummers.dev/yum/vfft

yumImplement fft v4 using radix 8fe37f3f

master
984 B36 linesraw
1module util;
2
3#define FRAC_1_SQRT_2 0.7071067811865475244008443621048490392848359376884740365883398689
4
5public float2 cmul(float2 x, float2 y) {
6  return float2(x[0] * y[0] - x[1] * y[1], x[0] * y[1] + x[1] * y[0]);
7}
8
9public float2 mul_ni(float2 x) {
10    return float2(x[1], -x[0]);
11}
12
13public float2 rot_45(float2 c) {
14    return float2(c[0] - c[1], c[0] + c[1]) * FRAC_1_SQRT_2;
15}
16
17public float2 rot_90(float2 c) {
18    // The standard 2D rotation matrix gives:
19    //  [ cos(pi/2) -sin(pi/2)]   [ 0 -1 ]
20    //  [ sin(pi/2)  cos(pi/2)] = [ 1  0 ]
21    return float2(-c[1], c[0]);
22}
23
24public float2 rot_180(float2 c) {
25    // The standard 2D rotation matrix gives:
26    //  [ cos(pi) -sin(pi)]   [ -1  0 ]
27    //  [ sin(pi)  cos(pi)] = [  0 -1 ]
28    return float2(-c[0], -c[1]);
29}
30
31public float2 rot_270(float2 c) {
32    // The standard 2D rotation matrix gives:
33    //  [ cos(3pi/2) -sin(3pi/2)]   [  0 1 ]
34    //  [ sin(3pi/2)  cos(3pi/2)] = [ -1 0 ]
35    return float2(c[1], -c[0]);
36}