7 static void *sqrt2(cf_t cf
) {
15 // Converges extremely slowly.
16 static void *slow_pi(cf_t cf
) {
45 x
= cf_new_const(sqrt2
);
46 conv
= cf_new_cf_convergent(x
);
53 EXPECT(!mpz_cmp_ui(p
, 1));
55 EXPECT(!mpz_cmp_ui(q
, 1));
58 EXPECT(!mpz_cmp_ui(p
, 3));
60 EXPECT(!mpz_cmp_ui(q
, 2));
63 EXPECT(!mpz_cmp_ui(p
, 7));
65 EXPECT(!mpz_cmp_ui(q
, 5));
68 EXPECT(!mpz_cmp_ui(p
, 17));
70 EXPECT(!mpz_cmp_ui(q
, 12));
78 for (int i
= 0; i
< 4; i
++) mpz_init(z
[i
]);
79 // Identity Mobius transformation.
85 x
= cf_new_const(slow_pi
);
86 conv
= cf_new_nonregular_mobius_to_decimal(x
, z
);
88 EXPECT(!mpz_cmp_ui(digit
, 3));
90 EXPECT(!mpz_cmp_ui(digit
, 1));
92 EXPECT(!mpz_cmp_ui(digit
, 4));
94 EXPECT(!mpz_cmp_ui(digit
, 1));
96 EXPECT(!mpz_cmp_ui(digit
, 5));
98 EXPECT(!mpz_cmp_ui(digit
, 9));
100 EXPECT(!mpz_cmp_ui(digit
, 2));
106 x
= cf_new_const(sqrt2
);
108 mob
= cf_new_mobius_to_cf(x
, z
);
109 CF_EXPECT_DEC(mob
, "1.4142135623730");
112 x
= cf_new_const(sqrt2
);
114 // Works out to be 1 + sqrt(2).
116 mpz_set_si(z
[1], -2);
117 mpz_set_si(z
[2], -3);
119 mob
= cf_new_mobius_to_cf(x
, z
);
120 CF_EXPECT_DEC(mob
, "2.4142135623730");
123 for (int i
= 0; i
< 4; i
++) mpz_clear(z
[i
]);