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