Esempio n. 1
0
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
}
Esempio n. 2
0
func (f *Float) Float64() float64 {
	f.doinit()
	return float64(C.mpf_get_d(&f.i[0]))
}
Esempio n. 3
0
func (f *Float) Double() float64 {
	return float64(C.mpf_get_d(&f.i[0]))
}