Skip to content

Commit f9e1bde

Browse files
Merge pull request #142 from NFFT/feature/nfft_trafo_direct_d_1
Improve efficiency of NFFT direct transformation in one dimension.
2 parents 3843638 + e996b2a commit f9e1bde

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

kernel/nfft/nfft.c

+7-3
Original file line numberDiff line numberDiff line change
@@ -146,8 +146,6 @@ void X(trafo_direct)(const X(plan) *ths)
146146
{
147147
C *f_hat = (C*)ths->f_hat, *f = (C*)ths->f;
148148

149-
memset(f, 0, (size_t)(ths->M_total) * sizeof(C));
150-
151149
if (ths->d == 1)
152150
{
153151
/* specialize for univariate case, rationale: faster */
@@ -157,16 +155,22 @@ void X(trafo_direct)(const X(plan) *ths)
157155
#endif
158156
for (j = 0; j < ths->M_total; j++)
159157
{
158+
C v = K(0.0);
160159
INT k_L;
161160
for (k_L = 0; k_L < ths->N_total; k_L++)
162161
{
163162
R omega = K2PI * ((R)(k_L - ths->N_total/2)) * ths->x[j];
164-
f[j] += f_hat[k_L] * BASE(-II * omega);
163+
v += f_hat[k_L] * (COS(omega) - II * SIN(omega));
165164
}
165+
166+
f[j] = v;
166167
}
167168
}
168169
else
169170
{
171+
172+
memset(f, 0, (size_t)(ths->M_total) * sizeof(C));
173+
170174
/* multivariate case */
171175
INT j;
172176
#ifdef _OPENMP

tests/nfft.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -783,13 +783,13 @@ static R compare_adjoint(check_delegate_t *ego, X(plan) *p, const int NN, const
783783
static check_delegate_t check_trafo = {prepare_trafo, compare_trafo};
784784
static check_delegate_t check_adjoint = {prepare_adjoint, compare_adjoint};
785785

786-
static trafo_delegate_t trafo_direct = {"trafo_direct", X(trafo_direct), 0, trafo_direct_cost, err_trafo_direct};
786+
static trafo_delegate_t trafo_direct = {"trafo_direct", (trafo_t)X(trafo_direct), 0, trafo_direct_cost, err_trafo_direct};
787787
static trafo_delegate_t trafo = {"trafo", X(trafo), X(check), 0, err_trafo};
788788
static trafo_delegate_t trafo_1d = {"trafo_1d", X(trafo_1d), X(check), 0, err_trafo};
789789
static trafo_delegate_t trafo_2d = {"trafo_2d", X(trafo_2d), X(check), 0, err_trafo};
790790
static trafo_delegate_t trafo_3d = {"trafo_3d", X(trafo_3d), X(check), 0, err_trafo};
791791

792-
static trafo_delegate_t adjoint_direct = {"adjoint_direct", X(adjoint_direct), 0, trafo_direct_cost, err_trafo_direct};
792+
static trafo_delegate_t adjoint_direct = {"adjoint_direct", (trafo_t)X(adjoint_direct), 0, trafo_direct_cost, err_trafo_direct};
793793
static trafo_delegate_t adjoint = {"adjoint", X(adjoint), X(check), 0, err_trafo};
794794
static trafo_delegate_t adjoint_1d = {"adjoint_1d", X(adjoint_1d), X(check), 0, err_trafo};
795795
static trafo_delegate_t adjoint_2d = {"adjoint_2d", X(adjoint_2d), X(check), 0, err_trafo};

0 commit comments

Comments
 (0)