NFFT 3.6.0
nfct/simple_test.c
1/*
2 * Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
3 *
4 * This program is free software; you can redistribute it and/or modify it under
5 * the terms of the GNU General Public License as published by the Free Software
6 * Foundation; either version 2 of the License, or (at your option) any later
7 * version.
8 *
9 * This program is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
12 * details.
13 *
14 * You should have received a copy of the GNU General Public License along with
15 * this program; if not, write to the Free Software Foundation, Inc., 51
16 * Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17 */
18
19#include <stdio.h>
20#include <math.h>
21#include <string.h>
22#include <stdlib.h>
23
24#define NFFT_PRECISION_DOUBLE
25
26#include "nfft3mp.h"
27
28static void simple_test_nfct_1d(void)
29{
30 NFCT(plan) p;
31
32 const char *error_str;
33
34 int N = 14;
35 int M = 19;
36
38 NFCT(init_1d)(&p,N,M);
39
41 NFFT(vrand_real)(p.x, p.M_total, NFFT_K(0.0), NFFT_K(0.5));
42
44 if( p.flags & PRE_ONE_PSI)
45 NFCT(precompute_one_psi)(&p);
46
48 NFFT(vrand_real)(p.f_hat, p.N_total, NFFT_K(0.0), NFFT_K(1.0));
49 NFFT(vpr_double)(p.f_hat,p.N_total,"given Fourier coefficients, vector f_hat");
50
52 error_str = NFCT(check)(&p);
53 if (error_str != 0)
54 {
55 printf("Error in nfct module: %s\n", error_str);
56 return;
57 }
58
60 NFCT(trafo_direct)(&p);
61 NFFT(vpr_double)(p.f,p.M_total,"ndct, vector f");
62
64 NFCT(trafo)(&p);
65 NFFT(vpr_double)(p.f,p.M_total,"nfct, vector f");
66
68 NFCT(adjoint_direct)(&p);
69 NFFT(vpr_double)(p.f_hat,p.N_total,"adjoint ndct, vector f_hat");
70
72 NFCT(adjoint)(&p);
73 NFFT(vpr_double)(p.f_hat,p.N_total,"adjoint nfct, vector f_hat");
74
76 NFCT(finalize)(&p);
77}
78
79int main(void)
80{
81 printf("Computing one dimensional ndct, nfct, adjoint ndct, and adjoint nfct...\n\n");
82 simple_test_nfct_1d();
83 printf("\n\n");
84
85 return EXIT_SUCCESS;
86}
#define PRE_ONE_PSI
Definition nfft3.h:200