Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
b24ec90
test: use cython==3.0.0a11 to build in CI
oscarbenjamin Dec 14, 2022
5fe55f3
fix: add __radd__ etc to fmpz
oscarbenjamin Dec 14, 2022
12885b6
test: also use cython 3 on Windows
oscarbenjamin Dec 14, 2022
3bacb07
fix: remove redundant paths in dunder methods
oscarbenjamin Apr 20, 2023
978696a
fix: add __rdunder__ methods for fmpq and nmod
oscarbenjamin Apr 20, 2023
1556939
fix: add __rdunder__ fmpz_mat, fmpq_mat and nmp_mat
oscarbenjamin Aug 3, 2023
19d7526
fix: add __rdunder__ fmpz_poly, fmpq_poly and nmp_poly
oscarbenjamin Apr 21, 2023
4d9175b
fix: add __rdunder__ methods fmpz_series, fmpq_series
oscarbenjamin Apr 21, 2023
3c03077
fix: add __rdunder__ methods for arb and acb
oscarbenjamin Apr 21, 2023
fcda89f
Use cython 3.0.0b2
oscarbenjamin Apr 21, 2023
5082c78
fix: add modulus arg to acb.__rpow__
oscarbenjamin Apr 21, 2023
5a4a2aa
fix: __rdunder__ acb_poly, acb_series, arb_poly, arb_series
oscarbenjamin Apr 21, 2023
d3c2519
Use cython==3.0.0b2 in Cirruc CI as well
oscarbenjamin Apr 21, 2023
0a8bf5c
fix: add __rdunder__ methods for acb_mat and arb_mat
oscarbenjamin Apr 21, 2023
913f69c
Add redundant type casts for older Cython
oscarbenjamin Apr 21, 2023
a390bdc
fix: fmpz_mat * nmod_mat -> nmod_mat
oscarbenjamin Aug 3, 2023
12bc215
Use GMP mirror from GitHub in CI
oscarbenjamin Aug 3, 2023
e1c0c70
Update Cython -> 3.0.0, GMP -> 6.3.0
oscarbenjamin Aug 3, 2023
d4db446
Do not apply GMP macos_arm64 patch
oscarbenjamin Aug 3, 2023
0370688
Remove version constraints for Cython
oscarbenjamin Aug 3, 2023
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
2 changes: 1 addition & 1 deletion .github/workflows/buildwheel.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ jobs:
CIBW_BEFORE_ALL_MACOS: bin/cibw_before_all_macosx_x86_64.sh
CIBW_BEFORE_ALL_WINDOWS: msys2 -c bin/cibw_before_all_windows.sh
CIBW_BEFORE_BUILD_WINDOWS: msys2 -c bin/cibw_before_build_windows.sh
CIBW_BEFORE_BUILD: pip install numpy cython delvewheel
CIBW_BEFORE_BUILD: pip install numpy cython==3.0.0b2 delvewheel
CIBW_ENVIRONMENT: >
C_INCLUDE_PATH=$(pwd)/.local/include/
LIBRARY_PATH=$(pwd)/.local/lib/
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,4 @@ MANIFEST
*.egg-info
.coverage
*.swp
.python-version
20 changes: 15 additions & 5 deletions bin/build_dependencies_unix.sh
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,10 @@ do
PATCH_GMP_ARM64=yes
shift
;;
--use-gmp-github-mirror)
USE_GMP_GITHUB_MIRROR=yes
shift
;;
*)
2>&1 echo "unrecognised argument:" $key
exit 1
Expand Down Expand Up @@ -82,17 +86,22 @@ if [ $USE_GMP = "gmp" ]; then
# #
# ----------------------------------------------------------------------- #

curl -O https://gmplib.org/download/gmp/gmp-$GMPVER.tar.xz
if [ $USE_GMP_GITHUB_MIRROR = "yes" ]; then
# Needed in GitHub Actions because it is blocked from gmplib.org
git clone https://github.com/oscarbenjamin/gmp_mirror.git
cp gmp_mirror/gmp-$GMPVER.tar.xz .
else
curl -O https://gmplib.org/download/gmp/gmp-$GMPVER.tar.xz
fi

tar xf gmp-$GMPVER.tar.xz
cd gmp-$GMPVER

#
# See https://github.com/aleaxit/gmpy/issues/350
#
# We need to patch GMP for OSX arm64 (Apple M1) hardware. This patch is
# from the GMP repo but was applied after the release of GMP 6.2.1.
# Hopefully when a newer version of GMP is released we will not need to
# apply this patch any more.
# We need to patch GMP for OSX arm64 (Apple M1) hardware for GMP 6.2.1.
# Now with GMP 6.3.0 this should not be needed any more.
#
if [ $PATCH_GMP_ARM64 = "yes" ]; then
echo
Expand All @@ -103,6 +112,7 @@ if [ $USE_GMP = "gmp" ]; then
fi

# Show the output of configfsf.guess
chmod +x configfsf.guess
./configfsf.guess
./configure --prefix=$PREFIX\
--enable-fat\
Expand Down
2 changes: 1 addition & 1 deletion bin/build_variables.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
PREFIX=$(pwd)/.local
mkdir -p $PREFIX

GMPVER=6.2.1
GMPVER=6.3.0
YASMVER=1.3.0
MPIRVER=3.0.0
MPFRVER=4.1.0
Expand Down
3 changes: 2 additions & 1 deletion bin/cibw_before_all_linux.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@
yum install -y xz
bin/build_dependencies_unix.sh\
--gmp gmp\
--host x86_64-pc-linux-gnu
--host x86_64-pc-linux-gnu\
--use-gmp-github-mirror
2 changes: 1 addition & 1 deletion bin/cibw_before_all_macosx_arm64.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ export LDFLAGS=" -arch arm64"
bin/build_dependencies_unix.sh\
--gmp gmp\
--host aarch64-apple-darwin\
--patch-gmp-arm64
--use-gmp-github-mirror
3 changes: 2 additions & 1 deletion bin/cibw_before_all_macosx_x86_64.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@

bin/build_dependencies_unix.sh\
--gmp gmp\
--host x86_64-apple-darwin
--host x86_64-apple-darwin\
--use-gmp-github-mirror
2 changes: 1 addition & 1 deletion bin/cibw_before_all_windows.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@ cat setup.cfg
pacman -S --noconfirm mingw-w64-x86_64-gcc m4 make mingw-w64-x86_64-tools-git

# This takes ~30mins
bin/build_dependencies_unix.sh
bin/build_dependencies_unix.sh --use-gmp-github-mirror
2 changes: 1 addition & 1 deletion bin/cibw_before_build_windows.sh
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,4 @@ mv libpython${VER}.a libs
# Install build dependencies #
###################################################

pip install Cython numpy delvewheel
pip install cython numpy delvewheel
5 changes: 4 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,10 @@


define_macros = []
compiler_directives = {'language_level':3}
compiler_directives = {
'language_level': 3,
'binding': False,
}


# Enable coverage tracing
Expand Down
112 changes: 65 additions & 47 deletions src/flint/acb.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -156,23 +156,18 @@ cdef class acb(flint_scalar):
return (self.real._mpf_, self.imag._mpf_)

def __richcmp__(s, t, int op):
cdef acb_struct sval[1]
cdef acb_struct tval[1]
cdef bint res
cdef int stype, ttype
cdef int ttype
if not (op == 2 or op == 3):
raise ValueError("comparing complex numbers")
stype = acb_set_any_ref(sval, s)
if stype == FMPZ_UNKNOWN:
return NotImplemented
ttype = acb_set_any_ref(tval, t)
if ttype == FMPZ_UNKNOWN:
return NotImplemented
if op == 2:
res = acb_eq(sval, tval)
res = acb_eq(s.val, tval)
else:
res = acb_ne(sval, tval)
if stype == FMPZ_TMP: acb_clear(sval)
res = acb_ne(s.val, tval)
if ttype == FMPZ_TMP: acb_clear(tval)
return res

Expand Down Expand Up @@ -363,92 +358,116 @@ cdef class acb(flint_scalar):
return res

def __add__(s, t):
cdef acb_struct sval[1]
cdef acb_struct tval[1]
cdef int stype, ttype
stype = acb_set_any_ref(sval, s)
if stype == FMPZ_UNKNOWN:
cdef int ttype
ttype = acb_set_any_ref(tval, t)
if ttype == FMPZ_UNKNOWN:
return NotImplemented
u = acb.__new__(acb)
acb_add((<acb>u).val, (<acb>s).val, tval, getprec())
if ttype == FMPZ_TMP: acb_clear(tval)
return u

def __radd__(s, t):
cdef acb_struct tval[1]
cdef int ttype
ttype = acb_set_any_ref(tval, t)
if ttype == FMPZ_UNKNOWN:
return NotImplemented
u = acb.__new__(acb)
acb_add((<acb>u).val, sval, tval, getprec())
if stype == FMPZ_TMP: acb_clear(sval)
acb_add((<acb>u).val, tval, s.val, getprec())
if ttype == FMPZ_TMP: acb_clear(tval)
return u

def __sub__(s, t):
cdef acb_struct sval[1]
cdef acb_struct tval[1]
cdef int stype, ttype
stype = acb_set_any_ref(sval, s)
if stype == FMPZ_UNKNOWN:
cdef int ttype
ttype = acb_set_any_ref(tval, t)
if ttype == FMPZ_UNKNOWN:
return NotImplemented
u = acb.__new__(acb)
acb_sub((<acb>u).val, (<acb>s).val, tval, getprec())
if ttype == FMPZ_TMP: acb_clear(tval)
return u

def __rsub__(s, t):
cdef acb_struct tval[1]
cdef int ttype
ttype = acb_set_any_ref(tval, t)
if ttype == FMPZ_UNKNOWN:
return NotImplemented
u = acb.__new__(acb)
acb_sub((<acb>u).val, sval, tval, getprec())
if stype == FMPZ_TMP: acb_clear(sval)
acb_sub((<acb>u).val, tval, s.val, getprec())
if ttype == FMPZ_TMP: acb_clear(tval)
return u

def __mul__(s, t):
cdef acb_struct sval[1]
cdef acb_struct tval[1]
cdef int stype, ttype
stype = acb_set_any_ref(sval, s)
if stype == FMPZ_UNKNOWN:
return NotImplemented
cdef int ttype
ttype = acb_set_any_ref(tval, t)
if ttype == FMPZ_UNKNOWN:
return NotImplemented
u = acb.__new__(acb)
acb_mul((<acb>u).val, sval, tval, getprec())
if stype == FMPZ_TMP: acb_clear(sval)
acb_mul((<acb>u).val, (<acb>s).val, tval, getprec())
if ttype == FMPZ_TMP: acb_clear(tval)
return u

# important: must not be cdef because of cython magic
@staticmethod
def _div_(s, t):
cdef acb_struct sval[1]
def __rmul__(s, t):
cdef acb_struct tval[1]
cdef int stype, ttype
stype = acb_set_any_ref(sval, s)
if stype == FMPZ_UNKNOWN:
return NotImplemented
cdef int ttype
ttype = acb_set_any_ref(tval, t)
if ttype == FMPZ_UNKNOWN:
return NotImplemented
u = acb.__new__(acb)
acb_div((<acb>u).val, sval, tval, getprec())
if stype == FMPZ_TMP: acb_clear(sval)
acb_mul((<acb>u).val, tval, s.val, getprec())
if ttype == FMPZ_TMP: acb_clear(tval)
return u

def __truediv__(s, t):
return acb._div_(s, t)
cdef acb_struct tval[1]
cdef int ttype
ttype = acb_set_any_ref(tval, t)
if ttype == FMPZ_UNKNOWN:
return NotImplemented
u = acb.__new__(acb)
acb_div((<acb>u).val, (<acb>s).val, tval, getprec())
if ttype == FMPZ_TMP: acb_clear(tval)
return u

def __div__(s, t):
return acb._div_(s, t)
def __rtruediv__(s, t):
cdef acb_struct tval[1]
cdef int ttype
ttype = acb_set_any_ref(tval, t)
if ttype == FMPZ_UNKNOWN:
return NotImplemented
u = acb.__new__(acb)
acb_div((<acb>u).val, tval, s.val, getprec())
if ttype == FMPZ_TMP: acb_clear(tval)
return u

def __pow__(s, t, u):
cdef acb_struct sval[1]
cdef acb_struct tval[1]
cdef int stype, ttype
cdef int ttype
if u is not None:
raise ValueError("modular exponentiation of complex number")
stype = acb_set_any_ref(sval, s)
if stype == FMPZ_UNKNOWN:
ttype = acb_set_any_ref(tval, t)
if ttype == FMPZ_UNKNOWN:
return NotImplemented
u = acb.__new__(acb)
acb_pow((<acb>u).val, (<acb>s).val, tval, getprec())
if ttype == FMPZ_TMP: acb_clear(tval)
return u

def __rpow__(s, t, u):
cdef acb_struct tval[1]
cdef int ttype
if u is not None:
raise ValueError("modular exponentiation of complex number")
ttype = acb_set_any_ref(tval, t)
if ttype == FMPZ_UNKNOWN:
return NotImplemented
u = acb.__new__(acb)
acb_pow((<acb>u).val, sval, tval, getprec())
if stype == FMPZ_TMP: acb_clear(sval)
acb_pow((<acb>u).val, tval, s.val, getprec())
if ttype == FMPZ_TMP: acb_clear(tval)
return u

Expand Down Expand Up @@ -2560,4 +2579,3 @@ cdef class acb(flint_scalar):
acb_hypgeom_coulomb(NULL, (<acb>G).val, NULL, NULL,
(<acb>l).val, (<acb>eta).val, (<acb>self).val, getprec())
return G

Loading