libdspl-2.0/examples/src/conv_fft_test.c

39 wiersze
855 B
C

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "dspl.h"
#define N 13
#define M 7
int main()
{
Examples style changed Changes to be committed: modified: examples/src/array_test.c modified: examples/src/bessel_i0.c modified: examples/src/bilinear_test.c modified: examples/src/butter_ap_test.c modified: examples/src/butter_ap_zp_test.c modified: examples/src/cheby1_ap_test.c modified: examples/src/cheby1_ap_zp_test.c modified: examples/src/cheby2_ap_test.c modified: examples/src/cheby2_ap_zp_test.c modified: examples/src/cheby_poly1_test.c modified: examples/src/cheby_poly2_test.c modified: examples/src/complex_test.c modified: examples/src/conv_fft_cmplx_test.c modified: examples/src/conv_fft_test.c modified: examples/src/conv_test.c modified: examples/src/dft_cmplx_test.c modified: examples/src/dft_test.c modified: examples/src/dspl_info_test.c modified: examples/src/ellip_ap_test.c modified: examples/src/ellip_ap_zp_test.c modified: examples/src/ellip_landen_test.c modified: examples/src/fft_cmplx_test.c modified: examples/src/fft_test.c modified: examples/src/filter_iir_test.c modified: examples/src/fir_linphase_test.c modified: examples/src/gnuplot_script_test.c modified: examples/src/idft_cmplx_test.c modified: examples/src/ifft_cmplx_test.c modified: examples/src/iir_bstop.c modified: examples/src/iir_lpf.c modified: examples/src/iir_test.c modified: examples/src/matrix_eig.c modified: examples/src/matrix_mul.c modified: examples/src/matrix_print.c modified: examples/src/matrix_transpose.c modified: examples/src/polyroots_test.c modified: examples/src/randb_test.c modified: examples/src/randi_test.c modified: examples/src/randn_test.c modified: examples/src/randu_accuracy_test.c modified: examples/src/randu_test.c modified: examples/src/sinc_test.c modified: examples/src/sine_int_test.c modified: examples/src/writetxt_3d_test.c
2020-07-18 06:34:52 +00:00
void* handle; /* DSPL handle */
handle = dspl_load(); /* Load DSPL function */
double a[N], b[M], c[N+M-1], d[N+M-1];
fft_t pfft;
int n, err;
linspace(0, N, N, DSPL_PERIODIC, a);
linspace(0, M, M, DSPL_PERIODIC, b);
memset(&pfft, 0, sizeof(fft_t));
err = conv_fft(a, N, b, M, &pfft, 16, c);
printf("conv_fft error: 0x%.8x\n", err);
err = conv(a, N, b, M, d);
printf("conv error: 0x%.8x\n", err);
/* print result */
for(n = 0; n < N+M-1; n++)
printf("c[%3d] = %9.2f d[%3d] = %9.2f\n", n, c[n], n, d[n]);
fft_free(&pfft); /* free fft structure memory */
dspl_free(handle); /* free dspl handle */
return 0;
}