libdspl-2.0/examples/src/randi_test.c

57 wiersze
1.5 KiB
C
Czysty Zwykły widok Historia

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "dspl.h"
#define N 1000
int main(int argc, char* argv[])
{
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* hdspl; /* DSPL handle */
void* hplot; /* GNUPLOT handles */
random_t rnd = {0}; /* random structure */
hdspl = dspl_load(); /* Load DSPL function */
int x[N];
int err;
err = random_init(&rnd, RAND_TYPE_MRG32K3A, NULL);
if(err != RES_OK)
goto exit_label;
err = randi(x, N, -4, 3, &rnd);
if(err != RES_OK)
goto exit_label;
/* Save to file */
err = writetxt_int(x, NULL, N, "dat/randi_mrg32k3a.txt");
if(err != RES_OK)
goto exit_label;
/**************************************************************************/
/* plotting by GNUPLOT */
/**************************************************************************/
/* Create window plot */
err = gnuplot_create(argc, argv, 820, 320, "img/randi_test.png", &hplot);
if(err != RES_OK)
goto exit_label;
gnuplot_cmd(hplot, "set xlabel 'n'");
gnuplot_cmd(hplot, "set ylabel 'x(n)'");
gnuplot_cmd(hplot, "unset key");
gnuplot_cmd(hplot, "set yrange[-5:4]");
gnuplot_cmd(hplot, "set title 'randi example'");
gnuplot_cmd(hplot, "plot 'dat/randi_mrg32k3a.txt' with impulses");
exit_label:
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
printf("Error code = 0x%.8x\n", err);
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
if(hplot)
gnuplot_close(hplot);
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
/* free dspl handle */
dspl_free(hdspl);
return 0;
}