-
-
Notifications
You must be signed in to change notification settings - Fork 482
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
sage.rings.{real,complex}_double: Remove compile time dependency on cypari2 #32701
Comments
Author: Matthias Koeppe, ... |
comment:3
Here's an attempt but I'm getting doctest errors:
New commits:
|
Commit: |
comment:4
Checking the most obvious thing helped:
New commits:
|
Changed author from Matthias Koeppe, ... to Matthias Koeppe, Jonathan Kliem |
comment:7
Thank you! Let's wait for the patchbot |
comment:8
Testing locally, I am seeing:
|
Reviewer: ..., Matthias Koeppe |
Branch pushed to git repo; I updated commit sha1. New commits:
|
comment:13
I think this requires some checking for speed regressions because the function is both no longer |
comment:14
Replying to @tscrim:
Things get about 1µs slower: Before:
After:
I doubt that calling If the regression is a problem, we could find a faster way to deal with the whole diff --git a/src/sage/libs/pari/convert_sage_complex_double.pyx b/src/sage/libs/pari/convert_sage_complex_double.pyx
index 5a04aff7f6..f8859a7dea 100644
--- a/src/sage/libs/pari/convert_sage_complex_double.pyx
+++ b/src/sage/libs/pari/convert_sage_complex_double.pyx
@@ -58,3 +58,6 @@ cpdef Gen new_gen_from_complex_double_element(ComplexDoubleElement self):
return new_gen_from_double(self._complex.real)
else:
return new_t_COMPLEX_from_double(self._complex.real, self._complex.imag)
+
+cpdef ComplexDoubleElement complex_double_eta(ComplexDoubleElement self, int flag):
+ return pari_to_cdf(new_gen_from_complex_double_element(self).eta(flag))
diff --git a/src/sage/rings/complex_double.pyx b/src/sage/rings/complex_double.pyx
index ecc326b439..0aef6a3aad 100644
--- a/src/sage/rings/complex_double.pyx
+++ b/src/sage/rings/complex_double.pyx
@@ -92,9 +92,11 @@ from sage.structure.coerce cimport is_numpy_type
try:
from cypari2.gen import Gen as pari_gen
from sage.libs.pari.convert_sage_complex_double import pari_to_cdf
+ from sage.libs.pari.convert_sage_complex_double import complex_double_eta
except ImportError:
pari_gen = ()
+ complex_double_eta = None
from . import complex_mpfr
@@ -2241,8 +2243,11 @@ cdef class ComplexDoubleElement(FieldElement):
# this, PARI can easily underflow.
return ComplexDoubleElement(0,0)
+ if complex_double_eta is None:
+ raise ImportError("pari not found")
+
cdef int flag = 0 if omit_frac else 1
- return pari_to_cdf(self.__pari__().eta(flag))
+ return complex_double_eta(self, flag) This is even faster than the original approach with new timing being:
This approach could be used anywhere but to speed up |
comment:15
Thank you for doing the timings. If someone is using polynomials or matrices over RDF/CDF and then running a PARI algorithm on them and has to convert back and forth, then this could have some noticeable effects on speed. With this, that main thing it would be going through is Perhaps this is just the cost of doing business, but I would have expected this to be okay to do. To be precise about "this", I mean implementing a Cython conversion to/from a library. How useful is this to modularization? I am actually more worried about #30022 having an actual impact on calculations because |
comment:16
If you really want to be fast, you should with
In that way, this ticket is an improvement. I'm fixing the other use cases and I will also see, whether #30022 can be improved. |
comment:18
Before this ticket:
With this ticket:
|
comment:19
That requires more understanding of the internal workings of Sage, is not local to the parent object, and is not flexible when the parent changes. So I am not sure it is the best path. However, at least with these changes, the effect on the function calls are minimized. |
comment:22
Replying to @tscrim:
Not sure if I'm answering this in the right context of your question, but I have expanded the ticket description to explain the motivation for this ticket. |
This comment has been minimized.
This comment has been minimized.
Changed reviewer from ..., Matthias Koeppe to Matthias Koeppe, Travis Scrimshaw |
comment:23
That was what I was after. Thank you. The current version LGTM. |
comment:24
Thanks for reviewing! |
New commits:
|
comment:27
I used an old version of the branch, to be redone |
New commits:
|
comment:29
Merging 9.5.beta5 pulls in #32607, so corresponding changes need to be made in |
Branch pushed to git repo; I updated commit sha1. New commits:
|
comment:32
Thanks. |
Changed branch from u/gh-kliem/sage_rings__real_complex__double__remove_compile_time_dependency_on_cypari2 to |
... as previously done in #30022 for
sage.rings.integer
andsage.rings.rational
.This is to support modularization (#29705):
py_scalar_parent
andpy_scalar_to_element
(fromsage.structure.coerce
) fully functional without having to pull in PARI (at compile time or run time)CC: @kliem @videlec @tscrim @yyyyx4
Component: refactoring
Author: Matthias Koeppe, Jonathan Kliem
Branch/Commit:
629c319
Reviewer: Matthias Koeppe, Travis Scrimshaw
Issue created by migration from https://trac.sagemath.org/ticket/32701
The text was updated successfully, but these errors were encountered: