def _generate_weights(self, storage):
        """ This method generates the precomputed weights """

        # Using a custom pi variable should force the calculations to use
        # high precision (I hope so)
        pi = 3.141592653589793238462643383
        num_iter = self.size // 2
        num_k = 1
        resolution_float = float(self.size)
        for i in range(self.log2_size):
            start = 0
            end = 2 * num_k
            for b in range(num_iter):
                K = 0
                for k in range(start, end, 2):
                    fK = float(K)
                    f_num_iter = float(num_iter)
                    weight_a = Vec2(
                        math.cos(2.0 * pi * fK * f_num_iter / resolution_float),
                        -math.sin(2.0 * pi * fK * f_num_iter / resolution_float)
                    )
                    weight_b = Vec2(
                        -math.cos(2.0 * pi * fK * f_num_iter / resolution_float),
                        math.sin(2.0 * pi * fK * f_num_iter / resolution_float)
                    )
                    storage[i][k // 2] = weight_a
                    storage[i][k // 2 + num_k] = weight_b
                    K += 1
                start += 4 * num_k
                end = start + 2 * num_k

            num_iter = num_iter >> 1
            num_k = num_k << 1
 This method generates the precomputed weights 
metadrive/render_pipeline/rpcore/water/gpu_fft.py