From e45f48544aa45d10b467482672d1ef03333556f6 Mon Sep 17 00:00:00 2001 From: roos-j Date: Sat, 6 Jul 2024 20:52:28 -0400 Subject: [PATCH 1/5] add arb_bits, acb_bits --- src/flint/types/acb.pyx | 3 +++ src/flint/types/arb.pyx | 3 +++ 2 files changed, 6 insertions(+) diff --git a/src/flint/types/acb.pyx b/src/flint/types/acb.pyx index 074c210a..a7d3729e 100644 --- a/src/flint/types/acb.pyx +++ b/src/flint/types/acb.pyx @@ -1403,6 +1403,9 @@ cdef class acb(flint_scalar): def rel_one_accuracy_bits(self): return acb_rel_one_accuracy_bits(self.val) + def bits(self): + return acb_bits(self.val) + def ei(s): r""" Exponential integral `\operatorname{Ei}(s)`. diff --git a/src/flint/types/arb.pyx b/src/flint/types/arb.pyx index 50274775..30339f88 100644 --- a/src/flint/types/arb.pyx +++ b/src/flint/types/arb.pyx @@ -2416,6 +2416,9 @@ cdef class arb(flint_scalar): def rel_one_accuracy_bits(self): return arb_rel_one_accuracy_bits(self.val) + def bits(self): + return arb_bits(self.val) + def lambertw(s, int branch=0): r""" Lambert *W* function, `W_k(s)`. Either the principal From af486f60908a6d2a2fa74e0060f6357441934eae Mon Sep 17 00:00:00 2001 From: roos-j Date: Sat, 6 Jul 2024 20:52:57 -0400 Subject: [PATCH 2/5] add arb_log_base_ui --- src/flint/flintlib/arb.pxd | 1 + src/flint/types/arb.pyx | 10 ++++++++++ 2 files changed, 11 insertions(+) diff --git a/src/flint/flintlib/arb.pxd b/src/flint/flintlib/arb.pxd index d9e54b69..e0887ff9 100644 --- a/src/flint/flintlib/arb.pxd +++ b/src/flint/flintlib/arb.pxd @@ -183,6 +183,7 @@ cdef extern from "flint/arb.h": void arb_log_ui(arb_t z, ulong x, long prec) void arb_log_fmpz(arb_t z, const fmpz_t x, long prec) void arb_log1p(arb_t z, const arb_t x, long prec) + void arb_log_base_ui(arb_t z, const arb_t x, ulong b, long prec) void arb_exp(arb_t z, const arb_t x, long prec) void arb_expm1(arb_t z, const arb_t x, long prec) void arb_sin(arb_t s, const arb_t x, long prec) diff --git a/src/flint/types/arb.pyx b/src/flint/types/arb.pyx index 30339f88..b426bb47 100644 --- a/src/flint/types/arb.pyx +++ b/src/flint/types/arb.pyx @@ -809,6 +809,16 @@ cdef class arb(flint_scalar): arb_log1p((u).val, (s).val, getprec()) return u + def log_base_ui(s, ulong b): + r"""Returns `\log_b(s)`, computed exactly when possible. + + >>> arb(2048).log_base_ui(2) + 11.0000000000000 + """ + u = arb.__new__(arb) + arb_log_base_ui((u).val, (s).val, b, getprec()) + return u + def sin(s): r""" Sine function `\sin(s)`. From 45e1b682786c7107edf93a1427e04fcecf1fd74a Mon Sep 17 00:00:00 2001 From: roos-j Date: Sun, 7 Jul 2024 08:59:12 -0400 Subject: [PATCH 3/5] add gh-160 to changelog --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 8c7baa90..a3f7a00d 100644 --- a/README.md +++ b/README.md @@ -132,7 +132,8 @@ CHANGELOG ------------- Next release: - +- [gh-160](https://github.com/flintlib/python-flint/pull/148) + Add `bits` to `arb` and `acb`, add `log_base` to `arb`. - [gh-148](https://github.com/flintlib/python-flint/pull/148) Remove debug symbols to make smaller Linux binaries. - [gh-144](https://github.com/flintlib/python-flint/pull/144) From 30d67ba8ab400256239c80ccd1dd4704e8e31b9a Mon Sep 17 00:00:00 2001 From: roos-j Date: Sun, 7 Jul 2024 09:00:38 -0400 Subject: [PATCH 4/5] name change of log_base in arb, docstrings for bits in arb, acb --- src/flint/types/acb.pyx | 5 +++++ src/flint/types/arb.pyx | 9 +++++++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/flint/types/acb.pyx b/src/flint/types/acb.pyx index a7d3729e..bb2bd6e6 100644 --- a/src/flint/types/acb.pyx +++ b/src/flint/types/acb.pyx @@ -1404,6 +1404,11 @@ cdef class acb(flint_scalar): return acb_rel_one_accuracy_bits(self.val) def bits(self): + r"""Returns maximum of :meth:`.arb.bits` called on real and imaginary part. + + >>> acb("2047/2048").bits() + 11 + """ return acb_bits(self.val) def ei(s): diff --git a/src/flint/types/arb.pyx b/src/flint/types/arb.pyx index b426bb47..ad84c41c 100644 --- a/src/flint/types/arb.pyx +++ b/src/flint/types/arb.pyx @@ -809,10 +809,10 @@ cdef class arb(flint_scalar): arb_log1p((u).val, (s).val, getprec()) return u - def log_base_ui(s, ulong b): + def log_base(s, ulong b): r"""Returns `\log_b(s)`, computed exactly when possible. - >>> arb(2048).log_base_ui(2) + >>> arb(2048).log_base(2) 11.0000000000000 """ u = arb.__new__(arb) @@ -2427,6 +2427,11 @@ cdef class arb(flint_scalar): return arb_rel_one_accuracy_bits(self.val) def bits(self): + r"""Returns number of bits needed to represent absolute value of mantissa of the midpoint; returns 0 if midpoint is special value. + + >>> arb("2047/2048").bits() + 11 + """ return arb_bits(self.val) def lambertw(s, int branch=0): From 426c1d53db24873349a85dd556c8482924407b62 Mon Sep 17 00:00:00 2001 From: roos-j Date: Sun, 7 Jul 2024 09:07:22 -0400 Subject: [PATCH 5/5] fix typo --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index a3f7a00d..b3ff1f02 100644 --- a/README.md +++ b/README.md @@ -132,7 +132,7 @@ CHANGELOG ------------- Next release: -- [gh-160](https://github.com/flintlib/python-flint/pull/148) +- [gh-160](https://github.com/flintlib/python-flint/pull/160) Add `bits` to `arb` and `acb`, add `log_base` to `arb`. - [gh-148](https://github.com/flintlib/python-flint/pull/148) Remove debug symbols to make smaller Linux binaries.