Skip to content

Commit

Permalink
Improve direct trafo efficiency by inlining memset operation and usin…
Browse files Browse the repository at this point in the history
…g real-valued sin/cos instead of complex valued cexp.
  • Loading branch information
jenskeiner committed Aug 15, 2024
1 parent 82575ec commit e996b2a
Showing 1 changed file with 7 additions and 3 deletions.
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

0 comments on commit e996b2a

Please sign in to comment.