ref: 24cb1dcb30000df8f556468ef6b27a899e6a5db7
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); }