ref: 558a014a3f0463fdc23c8b28c49503e456b5d753
dir: /complex.c/
#include <u.h> #include <libc.h> #include "complex.h" Complex cadd(Complex *a, Complex *b) { Complex r; r.r = a->r + b->r; r.i = a->i + b->i; return r; } Complex cmul(Complex *a, Complex *b) { Complex r; r.r = a->r*b->r - a->i*b->i; r.i = a->r*b->i + a->i*b->r; return r; } Complex cpow2(Complex *a) { return cmul(a, a); }