libdspl-2.0/examples/src/complex_test.c

60 wiersze
1.7 KiB
C
Czysty Zwykły widok Historia

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "dspl.h"
2019-11-04 14:05:33 +00:00
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* handle; /* DSPL handle */
complex_t x[3] = {{1.0, 2.0}, {3.0, 4.0}, {5.0, 6.0}};
complex_t y[3];
int k;
handle = dspl_load(); /* Load DSPL function */
printf("\n\nacos_cmplx\n---------------------------------\n");
acos_cmplx(x, 3, y);
for(k = 0; k < 3; k++)
printf("acos_cmplx(%.1f%+.1fj) = %.3f%+.3fj\n",
RE(x[k]), IM(x[k]), RE(y[k]), IM(y[k]));
printf("\n\nasin_cmplx\n---------------------------------\n");
asin_cmplx(x, 3, y);
for(k = 0; k < 3; k++)
printf("asin_cmplx(%.1f%+.1fj) = %.3f%+.3fj\n",
RE(x[k]), IM(x[k]), RE(y[k]), IM(y[k]));
printf("\n\ncos_cmplx\n---------------------------------\n");
cos_cmplx(x, 3, y);
for(k = 0; k < 3; k++)
printf("cos_cmplx(%.1f%+.1fj) = %9.3f%+9.3fj\n",
RE(x[k]), IM(x[k]), RE(y[k]), IM(y[k]));
printf("\n\nlog_cmplx\n---------------------------------\n");
log_cmplx(x, 3, y);
for(k = 0; k < 3; k++)
printf("log_cmplx(%.1f%+.1fj) = %.3f%+.3fj\n",
RE(x[k]), IM(x[k]), RE(y[k]), IM(y[k]));
printf("\n\nsin_cmplx\n---------------------------------\n");
sin_cmplx(x, 3, y);
for(k = 0; k < 3; k++)
printf("sin_cmplx(%.1f%+.1fj) = %9.3f%+9.3fj\n",
RE(x[k]), IM(x[k]), RE(y[k]), IM(y[k]));
printf("\n\nsqrt_cmplx\n---------------------------------\n");
sqrt_cmplx(x, 3, y);
for(k = 0; k < 3; k++)
printf("sqrt_cmplx(%.1f%+.1fj) = %.3f%+.3fj\n",
RE(x[k]), IM(x[k]), RE(y[k]), IM(y[k]));
/* free dspl handle */
dspl_free(handle);
return 0;
}