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

#include <stdio.h>
#include "cplx.h"
int main() {
complex int a = 1 + 2I;
complex double b = 2 + I;
gsl_complex c = gsl_cplx_from_c99(a);
gsl_vector *v = gsl_vector_alloc(8);
for (size_t i = 0; i < v->size; i++) {
gsl_vector_set(v, i, i/8.);
}
complex double adotb = dot(a, b);
printf("(1+2i) dot (2+i): %g+%gi\n", creal(adotb), cimag(adotb));
printf("v dot 2:\n");
double d = 2;
gsl_vector_complex_print(dot(v, d));
printf("v dot (1+2i)\n");
gsl_vector_complex *vc = dot(v, a);
gsl_vector_complex_print(vc);
printf("v dot (1+2i) again\n");
gsl_vector_complex_print(dot(v, c));
}