Learning by doing: Reading books and trying to understand the (code) examples
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

31 lines
626 B

  1. #include <stdio.h>
  2. #include "cplx.h"
  3. int main() {
  4. complex int a = 1 + 2I;
  5. complex double b = 2 + I;
  6. gsl_complex c = gsl_cplx_from_c99(a);
  7. gsl_vector *v = gsl_vector_alloc(8);
  8. for (size_t i = 0; i < v->size; i++) {
  9. gsl_vector_set(v, i, i/8.);
  10. }
  11. complex double adotb = dot(a, b);
  12. printf("(1+2i) dot (2+i): %g+%gi\n", creal(adotb), cimag(adotb));
  13. printf("v dot 2:\n");
  14. double d = 2;
  15. gsl_vector_complex_print(dot(v, d));
  16. printf("v dot (1+2i)\n");
  17. gsl_vector_complex *vc = dot(v, a);
  18. gsl_vector_complex_print(vc);
  19. printf("v dot (1+2i) again\n");
  20. gsl_vector_complex_print(dot(v, c));
  21. }