Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add arb_log_base, arb_bits, acb_bits #160

Merged
merged 5 commits into from
Jul 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,8 @@ CHANGELOG
-------------

Next release:

- [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.
- [gh-144](https://github.com/flintlib/python-flint/pull/144)
Expand Down
1 change: 1 addition & 0 deletions src/flint/flintlib/arb.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
8 changes: 8 additions & 0 deletions src/flint/types/acb.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -1403,6 +1403,14 @@ cdef class acb(flint_scalar):
def rel_one_accuracy_bits(self):
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):
r"""
Exponential integral `\operatorname{Ei}(s)`.
Expand Down
18 changes: 18 additions & 0 deletions src/flint/types/arb.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -809,6 +809,16 @@ cdef class arb(flint_scalar):
arb_log1p((<arb>u).val, (<arb>s).val, getprec())
return u

def log_base(s, ulong b):
r"""Returns `\log_b(s)`, computed exactly when possible.

>>> arb(2048).log_base(2)
11.0000000000000
"""
u = arb.__new__(arb)
arb_log_base_ui((<arb>u).val, (<arb>s).val, b, getprec())
return u

def sin(s):
r"""
Sine function `\sin(s)`.
Expand Down Expand Up @@ -2416,6 +2426,14 @@ cdef class arb(flint_scalar):
def rel_one_accuracy_bits(self):
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)
roos-j marked this conversation as resolved.
Show resolved Hide resolved

def lambertw(s, int branch=0):
r"""
Lambert *W* function, `W_k(s)`. Either the principal
Expand Down
Loading