Cleaned up lock mess monster.
[frac.git] / cf.h
bloba406fedcc4068470ff4ff24289db685b212ea083
1 // Requires gmp.h
2 //
3 // Opaque interface to continued fractions object.
5 #ifndef __CF_H__
6 #define __CF_H__
8 struct cf_s;
9 typedef struct cf_s *cf_t;
11 cf_t cf_new(void *(*func)(cf_t), void *data);
12 void cf_free(cf_t cf);
14 void cf_get(mpz_t z, cf_t cf);
15 void cf_put(cf_t cf, mpz_t z);
17 int cf_wait(cf_t cf);
19 void *cf_data(cf_t cf);
21 // cf_mobius.c:
22 // Compute convergents of a simple continued fraction x.
23 // Outputs p then q on channel, where p/q is the last convergent computed.
24 cf_t cf_new_convergent(cf_t x);
26 // Compute convergents of (a x + b)/(c x + d)
27 // where x is a regular continued fraction.
28 cf_t cf_new_mobius_convergent(cf_t x, mpz_t a, mpz_t b, mpz_t c, mpz_t d);
30 // Compute convergents of (a x + b)/(c x + d)
31 // where x is a nonregular continued fraction.
32 cf_t cf_new_nonregular_mobius_convergent(cf_t x, mpz_t a, mpz_t b, mpz_t c, mpz_t d);
34 cf_t cf_new_nonregular_to_cf(cf_t x, mpz_t a, mpz_t b, mpz_t c, mpz_t d);
36 cf_t cf_new_mobius_to_decimal(cf_t x, mpz_t a, mpz_t b, mpz_t c, mpz_t d);
37 cf_t cf_new_cf_to_decimal(cf_t x);
38 cf_t cf_new_nonregular_mobius_to_decimal(cf_t x, mpz_t a, mpz_t b, mpz_t c, mpz_t d);
40 #endif // __CF_H__