func DoMandel(cr, ci, zr, zi *Float, iterations int) int { C.mpf_set(&x[0], &zr.i[0]) C.mpf_set(&y[0], &zi.i[0]) C.mpf_set(&cx[0], &cr.i[0]) C.mpf_set(&cy[0], &ci.i[0]) for i := 0; ; i++ { C.mpf_mul(&a[0], &x[0], &x[0]) C.mpf_mul(&b[0], &y[0], &y[0]) if float64(C.mpf_get_d(&a[0]))+float64(C.mpf_get_d(&b[0])) > 4.0 { return i } if i == iterations-1 { break } C.mpf_mul_2exp(&y[0], &y[0], 1) C.mpf_mul(&y[0], &y[0], &x[0]) C.mpf_add(&y[0], &y[0], &cy[0]) C.mpf_sub(&x[0], &a[0], &b[0]) //todo C.mpf_add(&x[0], &x[0], &cx[0]) } return iterations }
// Mul2Exp sets z = x * 2^s and returns z. func (f *Float) Mul2Exp(x *Float, s uint) *Float { x.doinit() f.doinit() C.mpf_mul_2exp(&f.i[0], &x.i[0], C.mp_bitcnt_t(s)) return f }