Im trying to create a complex numbers library in C by using a typedef of an structure.
typedef struct{
double real;
double imag;
}complex_t;
However I'm curious whether if it's plausible to use this definition to do some computations using the '+' and '*' sign to operate complex numbers, instead of
creating a complex_t sum(complex_t z,complex_t w)
or complex_t prod(complex_t z,complex_t w)
. I want to do something like this :
#include<complex_library.h>
complex_t z1,z_2,w_1,w_2;
z_1 = newComplex(1,2);
z_2 = newComplex(-3,-4);
w_1 = z_1 + z_2;
w_2 = z_1 * z_2;
Thanks.