Skip to content

Commit 7f1a1f9

Browse files
Merge pull request #160 from roos-j/master
add arb_log_base, arb_bits, acb_bits
2 parents 430b8e5 + 426c1d5 commit 7f1a1f9

File tree

4 files changed

+29
-1
lines changed

4 files changed

+29
-1
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,8 @@ CHANGELOG
132132
-------------
133133

134134
Next release:
135-
135+
- [gh-160](https://github.com/flintlib/python-flint/pull/160)
136+
Add `bits` to `arb` and `acb`, add `log_base` to `arb`.
136137
- [gh-148](https://github.com/flintlib/python-flint/pull/148)
137138
Remove debug symbols to make smaller Linux binaries.
138139
- [gh-144](https://github.com/flintlib/python-flint/pull/144)

src/flint/flintlib/arb.pxd

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,7 @@ cdef extern from "flint/arb.h":
183183
void arb_log_ui(arb_t z, ulong x, long prec)
184184
void arb_log_fmpz(arb_t z, const fmpz_t x, long prec)
185185
void arb_log1p(arb_t z, const arb_t x, long prec)
186+
void arb_log_base_ui(arb_t z, const arb_t x, ulong b, long prec)
186187
void arb_exp(arb_t z, const arb_t x, long prec)
187188
void arb_expm1(arb_t z, const arb_t x, long prec)
188189
void arb_sin(arb_t s, const arb_t x, long prec)

src/flint/types/acb.pyx

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1403,6 +1403,14 @@ cdef class acb(flint_scalar):
14031403
def rel_one_accuracy_bits(self):
14041404
return acb_rel_one_accuracy_bits(self.val)
14051405

1406+
def bits(self):
1407+
r"""Returns maximum of :meth:`.arb.bits` called on real and imaginary part.
1408+
1409+
>>> acb("2047/2048").bits()
1410+
11
1411+
"""
1412+
return acb_bits(self.val)
1413+
14061414
def ei(s):
14071415
r"""
14081416
Exponential integral `\operatorname{Ei}(s)`.

src/flint/types/arb.pyx

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -809,6 +809,16 @@ cdef class arb(flint_scalar):
809809
arb_log1p((<arb>u).val, (<arb>s).val, getprec())
810810
return u
811811

812+
def log_base(s, ulong b):
813+
r"""Returns `\log_b(s)`, computed exactly when possible.
814+
815+
>>> arb(2048).log_base(2)
816+
11.0000000000000
817+
"""
818+
u = arb.__new__(arb)
819+
arb_log_base_ui((<arb>u).val, (<arb>s).val, b, getprec())
820+
return u
821+
812822
def sin(s):
813823
r"""
814824
Sine function `\sin(s)`.
@@ -2416,6 +2426,14 @@ cdef class arb(flint_scalar):
24162426
def rel_one_accuracy_bits(self):
24172427
return arb_rel_one_accuracy_bits(self.val)
24182428

2429+
def bits(self):
2430+
r"""Returns number of bits needed to represent absolute value of mantissa of the midpoint; returns 0 if midpoint is special value.
2431+
2432+
>>> arb("2047/2048").bits()
2433+
11
2434+
"""
2435+
return arb_bits(self.val)
2436+
24192437
def lambertw(s, int branch=0):
24202438
r"""
24212439
Lambert *W* function, `W_k(s)`. Either the principal

0 commit comments

Comments
 (0)