1 /** D bindings for GSL. 2 Authors: Chibisi Chima-Okereke 3 Copyright: Copyright (c) 2016, Chibisi Chima-Okereke. All rights reserved. 4 License: Boost License 1.0 5 */ 6 7 module gsl.fft; 8 import gsl.complex; 9 10 extern (C): 11 12 13 //gsl_fft 14 enum gsl_fft_direction 15 { 16 gsl_fft_forward = -1, 17 gsl_fft_backward = 1 18 } 19 20 //gsl_dft_complex 21 int gsl_dft_complex_forward (const(double)* data, const size_t stride, const size_t n, double* result); 22 int gsl_dft_complex_backward (const(double)* data, const size_t stride, const size_t n, double* result); 23 int gsl_dft_complex_inverse (const(double)* data, const size_t stride, const size_t n, double* result); 24 int gsl_dft_complex_transform (const(double)* data, const size_t stride, const size_t n, double* result, const gsl_fft_direction sign); 25 26 //gsl_dft_complex_float 27 int gsl_dft_complex_float_forward (const(float)* data, const size_t stride, const size_t n, float* result); 28 int gsl_dft_complex_float_backward (const(float)* data, const size_t stride, const size_t n, float* result); 29 int gsl_dft_complex_float_inverse (const(float)* data, const size_t stride, const size_t n, float* result); 30 int gsl_dft_complex_float_transform (const(float)* data, const size_t stride, const size_t n, float* result, const gsl_fft_direction sign); 31 32 //gsl_fft_complex 33 struct gsl_fft_complex_wavetable 34 { 35 size_t n; 36 size_t nf; 37 size_t[64] factor; 38 gsl_complex*[64] twiddle; 39 gsl_complex* trig; 40 } 41 42 struct gsl_fft_complex_workspace 43 { 44 size_t n; 45 double* scratch; 46 } 47 48 int gsl_fft_complex_radix2_forward (gsl_complex_packed_array data, const size_t stride, const size_t n); 49 int gsl_fft_complex_radix2_backward (gsl_complex_packed_array data, const size_t stride, const size_t n); 50 int gsl_fft_complex_radix2_inverse (gsl_complex_packed_array data, const size_t stride, const size_t n); 51 int gsl_fft_complex_radix2_transform (gsl_complex_packed_array data, const size_t stride, const size_t n, const gsl_fft_direction sign); 52 int gsl_fft_complex_radix2_dif_forward (gsl_complex_packed_array data, const size_t stride, const size_t n); 53 int gsl_fft_complex_radix2_dif_backward (gsl_complex_packed_array data, const size_t stride, const size_t n); 54 int gsl_fft_complex_radix2_dif_inverse (gsl_complex_packed_array data, const size_t stride, const size_t n); 55 int gsl_fft_complex_radix2_dif_transform (gsl_complex_packed_array data, const size_t stride, const size_t n, const gsl_fft_direction sign); 56 gsl_fft_complex_wavetable* gsl_fft_complex_wavetable_alloc (size_t n); 57 void gsl_fft_complex_wavetable_free (gsl_fft_complex_wavetable* wavetable); 58 gsl_fft_complex_workspace* gsl_fft_complex_workspace_alloc (size_t n); 59 void gsl_fft_complex_workspace_free (gsl_fft_complex_workspace* workspace); 60 int gsl_fft_complex_memcpy (gsl_fft_complex_wavetable* dest, gsl_fft_complex_wavetable* src); 61 int gsl_fft_complex_forward (gsl_complex_packed_array data, const size_t stride, const size_t n, const(gsl_fft_complex_wavetable)* wavetable, gsl_fft_complex_workspace* work); 62 int gsl_fft_complex_backward (gsl_complex_packed_array data, const size_t stride, const size_t n, const(gsl_fft_complex_wavetable)* wavetable, gsl_fft_complex_workspace* work); 63 int gsl_fft_complex_inverse (gsl_complex_packed_array data, const size_t stride, const size_t n, const(gsl_fft_complex_wavetable)* wavetable, gsl_fft_complex_workspace* work); 64 int gsl_fft_complex_transform (gsl_complex_packed_array data, const size_t stride, const size_t n, const(gsl_fft_complex_wavetable)* wavetable, gsl_fft_complex_workspace* work, const gsl_fft_direction sign); 65 66 67 //gsl_fft_complex_float 68 struct gsl_fft_complex_wavetable_float 69 { 70 size_t n; 71 size_t nf; 72 size_t[64] factor; 73 gsl_complex_float*[64] twiddle; 74 gsl_complex_float* trig; 75 } 76 77 struct gsl_fft_complex_workspace_float 78 { 79 size_t n; 80 float* scratch; 81 } 82 83 int gsl_fft_complex_float_radix2_forward (gsl_complex_packed_array_float data, const size_t stride, const size_t n); 84 int gsl_fft_complex_float_radix2_backward (gsl_complex_packed_array_float data, const size_t stride, const size_t n); 85 int gsl_fft_complex_float_radix2_inverse (gsl_complex_packed_array_float data, const size_t stride, const size_t n); 86 int gsl_fft_complex_float_radix2_transform (gsl_complex_packed_array_float data, const size_t stride, const size_t n, const gsl_fft_direction sign); 87 int gsl_fft_complex_float_radix2_dif_forward (gsl_complex_packed_array_float data, const size_t stride, const size_t n); 88 int gsl_fft_complex_float_radix2_dif_backward (gsl_complex_packed_array_float data, const size_t stride, const size_t n); 89 int gsl_fft_complex_float_radix2_dif_inverse (gsl_complex_packed_array_float data, const size_t stride, const size_t n); 90 int gsl_fft_complex_float_radix2_dif_transform (gsl_complex_packed_array_float data, const size_t stride, const size_t n, const gsl_fft_direction sign); 91 gsl_fft_complex_wavetable_float* gsl_fft_complex_wavetable_float_alloc (size_t n); 92 void gsl_fft_complex_wavetable_float_free (gsl_fft_complex_wavetable_float* wavetable); 93 gsl_fft_complex_workspace_float* gsl_fft_complex_workspace_float_alloc (size_t n); 94 void gsl_fft_complex_workspace_float_free (gsl_fft_complex_workspace_float* workspace); 95 int gsl_fft_complex_float_memcpy (gsl_fft_complex_wavetable_float* dest, gsl_fft_complex_wavetable_float* src); 96 int gsl_fft_complex_float_forward (gsl_complex_packed_array_float data, const size_t stride, const size_t n, const(gsl_fft_complex_wavetable_float)* wavetable, gsl_fft_complex_workspace_float* work); 97 int gsl_fft_complex_float_backward (gsl_complex_packed_array_float data, const size_t stride, const size_t n, const(gsl_fft_complex_wavetable_float)* wavetable, gsl_fft_complex_workspace_float* work); 98 int gsl_fft_complex_float_inverse (gsl_complex_packed_array_float data, const size_t stride, const size_t n, const(gsl_fft_complex_wavetable_float)* wavetable, gsl_fft_complex_workspace_float* work); 99 int gsl_fft_complex_float_transform (gsl_complex_packed_array_float data, const size_t stride, const size_t n, const(gsl_fft_complex_wavetable_float)* wavetable, gsl_fft_complex_workspace_float* work, const gsl_fft_direction sign); 100 101 102 //gsl_fft_halfcomplex 103 struct gsl_fft_halfcomplex_wavetable 104 { 105 size_t n; 106 size_t nf; 107 size_t[64] factor; 108 gsl_complex*[64] twiddle; 109 gsl_complex* trig; 110 } 111 112 int gsl_fft_halfcomplex_radix2_backward (double* data, const size_t stride, const size_t n); 113 int gsl_fft_halfcomplex_radix2_inverse (double* data, const size_t stride, const size_t n); 114 int gsl_fft_halfcomplex_radix2_transform (double* data, const size_t stride, const size_t n); 115 gsl_fft_halfcomplex_wavetable* gsl_fft_halfcomplex_wavetable_alloc (size_t n); 116 void gsl_fft_halfcomplex_wavetable_free (gsl_fft_halfcomplex_wavetable* wavetable); 117 int gsl_fft_halfcomplex_backward (double* data, const size_t stride, const size_t n, const(gsl_fft_halfcomplex_wavetable)* wavetable, gsl_fft_real_workspace* work); 118 int gsl_fft_halfcomplex_inverse (double* data, const size_t stride, const size_t n, const(gsl_fft_halfcomplex_wavetable)* wavetable, gsl_fft_real_workspace* work); 119 int gsl_fft_halfcomplex_transform (double* data, const size_t stride, const size_t n, const(gsl_fft_halfcomplex_wavetable)* wavetable, gsl_fft_real_workspace* work); 120 int gsl_fft_halfcomplex_unpack (const(double)* halfcomplex_coefficient, double* complex_coefficient, const size_t stride, const size_t n); 121 int gsl_fft_halfcomplex_radix2_unpack (const(double)* halfcomplex_coefficient, double* complex_coefficient, const size_t stride, const size_t n); 122 123 124 //gsl_fft_halfcomplex_float 125 struct gsl_fft_halfcomplex_wavetable_float 126 { 127 size_t n; 128 size_t nf; 129 size_t[64] factor; 130 gsl_complex_float*[64] twiddle; 131 gsl_complex_float* trig; 132 } 133 134 int gsl_fft_halfcomplex_float_radix2_backward (float* data, const size_t stride, const size_t n); 135 int gsl_fft_halfcomplex_float_radix2_inverse (float* data, const size_t stride, const size_t n); 136 int gsl_fft_halfcomplex_float_radix2_transform (float* data, const size_t stride, const size_t n); 137 gsl_fft_halfcomplex_wavetable_float* gsl_fft_halfcomplex_wavetable_float_alloc (size_t n); 138 void gsl_fft_halfcomplex_wavetable_float_free (gsl_fft_halfcomplex_wavetable_float* wavetable); 139 int gsl_fft_halfcomplex_float_backward (float* data, const size_t stride, const size_t n, const(gsl_fft_halfcomplex_wavetable_float)* wavetable, gsl_fft_real_workspace_float* work); 140 int gsl_fft_halfcomplex_float_inverse (float* data, const size_t stride, const size_t n, const(gsl_fft_halfcomplex_wavetable_float)* wavetable, gsl_fft_real_workspace_float* work); 141 int gsl_fft_halfcomplex_float_transform (float* data, const size_t stride, const size_t n, const(gsl_fft_halfcomplex_wavetable_float)* wavetable, gsl_fft_real_workspace_float* work); 142 int gsl_fft_halfcomplex_float_unpack (const(float)* halfcomplex_coefficient, float* complex_coefficient, const size_t stride, const size_t n); 143 int gsl_fft_halfcomplex_float_radix2_unpack (const(float)* halfcomplex_coefficient, float* complex_coefficient, const size_t stride, const size_t n); 144 145 146 //gsl_fft_real 147 struct gsl_fft_real_wavetable 148 { 149 size_t n; 150 size_t nf; 151 size_t[64] factor; 152 gsl_complex*[64] twiddle; 153 gsl_complex* trig; 154 } 155 156 struct gsl_fft_real_workspace 157 { 158 size_t n; 159 double* scratch; 160 } 161 162 int gsl_fft_real_radix2_transform (double* data, const size_t stride, const size_t n); 163 gsl_fft_real_wavetable* gsl_fft_real_wavetable_alloc (size_t n); 164 void gsl_fft_real_wavetable_free (gsl_fft_real_wavetable* wavetable); 165 gsl_fft_real_workspace* gsl_fft_real_workspace_alloc (size_t n); 166 void gsl_fft_real_workspace_free (gsl_fft_real_workspace* workspace); 167 int gsl_fft_real_transform (double* data, const size_t stride, const size_t n, const(gsl_fft_real_wavetable)* wavetable, gsl_fft_real_workspace* work); 168 int gsl_fft_real_unpack (const(double)* real_coefficient, double* complex_coefficient, const size_t stride, const size_t n); 169 170 171 //gsl_fft_real_float 172 struct gsl_fft_real_wavetable_float 173 { 174 size_t n; 175 size_t nf; 176 size_t[64] factor; 177 gsl_complex_float*[64] twiddle; 178 gsl_complex_float* trig; 179 } 180 181 struct gsl_fft_real_workspace_float 182 { 183 size_t n; 184 float* scratch; 185 } 186 187 int gsl_fft_real_float_radix2_transform (float* data, const size_t stride, const size_t n); 188 gsl_fft_real_wavetable_float* gsl_fft_real_wavetable_float_alloc (size_t n); 189 void gsl_fft_real_wavetable_float_free (gsl_fft_real_wavetable_float* wavetable); 190 gsl_fft_real_workspace_float* gsl_fft_real_workspace_float_alloc (size_t n); 191 void gsl_fft_real_workspace_float_free (gsl_fft_real_workspace_float* workspace); 192 int gsl_fft_real_float_transform (float* data, const size_t stride, const size_t n, const(gsl_fft_real_wavetable_float)* wavetable, gsl_fft_real_workspace_float* work); 193 int gsl_fft_real_float_unpack (const(float)* real_float_coefficient, float* complex_coefficient, const size_t stride, const size_t n);