Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve efficiency of NFFT direct transformation in one dimension. #142

Merged
merged 2 commits into from
Oct 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions kernel/nfft/nfft.c
Original file line number Diff line number Diff line change
Expand Up @@ -146,8 +146,6 @@ void X(trafo_direct)(const X(plan) *ths)
{
C *f_hat = (C*)ths->f_hat, *f = (C*)ths->f;

memset(f, 0, (size_t)(ths->M_total) * sizeof(C));

if (ths->d == 1)
{
/* specialize for univariate case, rationale: faster */
Expand All @@ -157,16 +155,22 @@ void X(trafo_direct)(const X(plan) *ths)
#endif
for (j = 0; j < ths->M_total; j++)
{
C v = K(0.0);
INT k_L;
for (k_L = 0; k_L < ths->N_total; k_L++)
{
R omega = K2PI * ((R)(k_L - ths->N_total/2)) * ths->x[j];
f[j] += f_hat[k_L] * BASE(-II * omega);
v += f_hat[k_L] * (COS(omega) - II * SIN(omega));
}

f[j] = v;
}
}
else
{

memset(f, 0, (size_t)(ths->M_total) * sizeof(C));

/* multivariate case */
INT j;
#ifdef _OPENMP
Expand Down
4 changes: 2 additions & 2 deletions tests/nfft.c
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

need the explicit casts or tests won't compile for me.

Original file line number Diff line number Diff line change
Expand Up @@ -783,13 +783,13 @@ static R compare_adjoint(check_delegate_t *ego, X(plan) *p, const int NN, const
static check_delegate_t check_trafo = {prepare_trafo, compare_trafo};
static check_delegate_t check_adjoint = {prepare_adjoint, compare_adjoint};

static trafo_delegate_t trafo_direct = {"trafo_direct", X(trafo_direct), 0, trafo_direct_cost, err_trafo_direct};
static trafo_delegate_t trafo_direct = {"trafo_direct", (trafo_t)X(trafo_direct), 0, trafo_direct_cost, err_trafo_direct};
static trafo_delegate_t trafo = {"trafo", X(trafo), X(check), 0, err_trafo};
static trafo_delegate_t trafo_1d = {"trafo_1d", X(trafo_1d), X(check), 0, err_trafo};
static trafo_delegate_t trafo_2d = {"trafo_2d", X(trafo_2d), X(check), 0, err_trafo};
static trafo_delegate_t trafo_3d = {"trafo_3d", X(trafo_3d), X(check), 0, err_trafo};

static trafo_delegate_t adjoint_direct = {"adjoint_direct", X(adjoint_direct), 0, trafo_direct_cost, err_trafo_direct};
static trafo_delegate_t adjoint_direct = {"adjoint_direct", (trafo_t)X(adjoint_direct), 0, trafo_direct_cost, err_trafo_direct};
static trafo_delegate_t adjoint = {"adjoint", X(adjoint), X(check), 0, err_trafo};
static trafo_delegate_t adjoint_1d = {"adjoint_1d", X(adjoint_1d), X(check), 0, err_trafo};
static trafo_delegate_t adjoint_2d = {"adjoint_2d", X(adjoint_2d), X(check), 0, err_trafo};
Expand Down
Loading