shithub: fractals

ref: bbc82d529a5b3c46630b79bd2d60125b4692df89
dir: /complex.c/

View raw version
#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);
}