00001 #ifndef FFTW_CONVOLVE
00002 #define FFTW_CONVOLVE
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #define FFTW_CONV_SHAPE_FULL 0
00018 #define FFTW_CONV_SHAPE_AS_A 1
00019 #define FFTW_CONV_SHAPE_AS_B 2
00020
00021 #ifdef sgi
00022 #define INLINE
00023 #else
00024 #define INLINE inline
00025 #endif
00026
00027
00028 typedef struct fftw_convolve_op_struct {
00029 int reva;
00030 int na, nb, N;
00031 int ma, mb, M;
00032 double scale;
00033 double *pada, *padb;
00034 fftw_complex *cc;
00035 int freeb, freec;
00036 fftw_plan q,s;
00037 } fftw_convolve_op;
00038
00039
00040
00041
00042 fftw_convolve_op *dfftw_convolve_1d_prepare(int reva, int na, int nb,
00043 double *a, double *padb,
00044 fftw_complex *padc);
00045 void dfftw_convolve_1d_execute(fftw_convolve_op *op, int revb,
00046 double *b, double *c);
00047 void dfftw_convolve_1d_free(fftw_convolve_op *op);
00048
00049 void dfftw_convolve_1d(int reva, int na, double *a, int revb, int nb, double *b,
00050 double *c);
00051 static INLINE void dfftw_corr_1d(int na, double *a, int nb, double *b, double *c)
00052 {
00053 dfftw_convolve_1d(0, na, a, 1, nb, b, c);
00054 }
00055
00056 static INLINE void dfftw_conv_1d(int na, double *a, int nb, double *b, double *c)
00057 {
00058 dfftw_convolve_1d(0, na, a, 0, nb, b, c);
00059 }
00060
00061
00062
00063 fftw_convolve_op *dfftw_convolve_2d_prepare(int ma, int na,
00064 int mb, int nb, double *a,
00065 double *padb, fftw_complex *padc);
00066 void dfftw_convolve_2d_execute(fftw_convolve_op *op, int shape,
00067 int reva, int revb,
00068 double *b, double alpha, double beta,
00069 double *c);
00070 void dfftw_convolve_2d_free(fftw_convolve_op *op);
00071 void dfftw_convolve_2d(int shape,
00072 int reva, int ma, int na, double *a,
00073 int revb, int mb, int nb, double *b,
00074 double alpha, double beta, double *c);
00075 static INLINE void dfftw_corr_2d(int shape, int ma, int na, double *a, int mb, int nb,
00076 double *b, double *c)
00077 {
00078 dfftw_convolve_2d(shape, 0, ma, na, a, 1, mb, nb, b, 1.0, 0.0, c);
00079 }
00080
00081 static INLINE void dfftw_conv_2d(int shape, int ma, int na, double *a, int mb, int nb,
00082 double *b, double *c)
00083 {
00084 dfftw_convolve_2d(shape, 0, ma, na, a, 0, mb, nb, b, 1.0, 0.0, c);
00085 }
00086
00087
00088
00089 void dfftw_corr_1d_(int *na, double *a, int *nb, double *b, double *c);
00090 void dfftw_conv_1d_(int *na, double *a, int *nb, double *b, double *c);
00091 void dfftw_convolve_1d_prepare_(fftw_convolve_op **op, int *reva, int *na,
00092 int *nb, double *a, double **padb,
00093 fftw_complex **padc);
00094 void dfftw_convolve_1d_execute_(fftw_convolve_op **op, int *revb,
00095 double *b, double *c);
00096 void dfftw_convolve_1d_free_(fftw_convolve_op **op);
00097
00098 void dfftw_convolve_1d_(int *reva, int *na, double *a, int *revb, int *nb,
00099 double *b, double *c);
00100
00101
00102 void dfftw_corr_2d_(int *shape, int *ma, int *na, double *a, int *mb, int *nb,
00103 double *b, double *c);
00104 void dfftw_conv_2d_(int *shape, int *ma, int *na, double *a, int *mb, int *nb,
00105 double *b, double *c);
00106
00107 void dfftw_convolve_2d_prepare_(fftw_convolve_op **op, int *ma,
00108 int *na, int *mb, int *nb, double *a,
00109 double **padb, fftw_complex **padc);
00110
00111 void dfftw_convolve_2d_execute_(fftw_convolve_op **op, int *shape,
00112 int *reva, int *revb,
00113 double *b, double *alpha,
00114 double *beta, double *c);
00115 void dfftw_convolve_2d_free_(fftw_convolve_op **op);
00116 void dfftw_convolve_2d_(int *shape,
00117 int *reva, int *ma, int *na, double *a,
00118 int *revb, int *mb, int *nb, double *b,
00119 double *alpha, double *beta, double *c);
00120
00121 #endif