1 #include "config.h"
2 
3 #include <stdio.h>
4 
5 #ifdef HAVE_COMPLEX_H
6 #include <complex.h>
7 #endif
8 
9 #include <math.h>
10 #include <string.h>
11 #include <stdlib.h>
12 
13 #include "nfft3.h"
14 #include "infft.h"
15 
jnfst_alloc(void)16 nfst_plan* jnfst_alloc(void){
17 	nfst_plan* p = nfft_malloc(sizeof(nfst_plan));
18 	return p;
19 }
20 
jnfst_init(nfst_plan * p,int d,int * N,int M,int * n,int m,unsigned int f1,unsigned int f2)21 void jnfst_init(nfst_plan* p, int d, int* N, int M, int* n, int m, unsigned int f1, unsigned int f2){
22     nfst_init_guru(p,d,N,M,n,m,f1,f2);
23 }
24 
jnfst_set_x(nfst_plan * p,double * X)25 double* jnfst_set_x(nfst_plan* p, double* X){
26 	int M = p->M_total;
27 	int d = p->d;
28 	int r,c;
29 	for (r = 0; r < M; r++)
30 		for (c = 0; c < d; c++)
31 			p->x[d*r+c] = X[d*r+c];
32 	nfst_precompute_one_psi(p);
33 	return p->x;
34 }
35 
36 // setting Fourier coefficients and returning pointer for access by Julia
jnfst_set_fhat(nfst_plan * p,double * f_hat)37 double* jnfst_set_fhat(nfst_plan* p,double* f_hat){
38 	int n = p->N_total;
39 	int k;
40 	for (k=0;k<n;k++)
41 		p->f_hat[k] = f_hat[k];
42 	return p->f_hat;
43 }
44 
45 // setting values and returning pointer for access by Julia
jnfst_set_f(nfst_plan * p,double * f)46 double* jnfst_set_f(nfst_plan* p,double* f){
47 	int M = p->M_total;
48 	int j;
49 	for (j=0;j<M;j++)
50 		p->f[j] = f[j];
51 	return p->f;
52 }
53 
54 // nfst trafo, return pointer to values for access by Julia if pointer isn't set
jnfst_trafo(nfst_plan * p)55 double* jnfst_trafo(nfst_plan* p){
56 	nfst_trafo(p);
57 	return p->f;
58 }
59 
60 // nfst adjoint, return pointer to coefficients for access by Julia if pointer isn't set
jnfst_adjoint(nfst_plan * p)61 double* jnfst_adjoint(nfst_plan* p){
62 	nfst_adjoint(p);
63 	return p->f_hat;
64 }
65 
66 // nfst trafo, return pointer to values for access by Julia if pointer isn't set
jnfst_trafo_direct(nfst_plan * p)67 double* jnfst_trafo_direct(nfst_plan* p){
68 	nfst_trafo_direct(p);
69 	return p->f;
70 }
71 
72 // nfst adjoint, return pointer to coefficients for access by Julia if pointer isn't set
jnfst_adjoint_direct(nfst_plan * p)73 double* jnfst_adjoint_direct(nfst_plan* p){
74 	nfst_adjoint_direct(p);
75 	return p->f_hat;
76 }
77 
78 // nfst plan finalizer
jnfst_finalize(nfst_plan * p)79 void jnfst_finalize(nfst_plan* p){
80 	nfst_finalize(p);
81 	nfft_free(p);
82 }
83