Skip to content
Discussion options

You must be logged in to vote

This was actually amusing to debug. You fftshifted along the n_trans axis as well as the freq axis!
Check https://numpy.org/devdocs/reference/generated/numpy.fft.fftshift.html

Note you had several other issues that made a non-working code. Here's the CPU code I hacked from yours:

import numpy as cp
import numpy as np
import scipy.fft as cpft
import finufft as finufft
pi = np.pi


d = 3        # ntrans, not dim!
m = 1024
n = 10        # query pts

x = cp.linspace(0, 2 * pi, m, endpoint=False)

# generate random data
u = cp.zeros((d, m))
for _ in range(10):
    for j in range(d):
        a = cp.random.randint(-20, 20)
        u[j] += cp.sin(a * x)

# FFT
u_hat = cpft.fftshift(cpft.fft(u, axis=

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
1 reply
@sijieh23
Comment options

Answer selected by DiamonDinoia
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants