Opened 3 years ago
Closed 2 years ago
#21198 closed enhancement (fixed)
fast_callable for domain=ComplexField(...)
Reported by:  nbruin  Owned by:  

Priority:  major  Milestone:  sage8.0 
Component:  numerical  Keywords:  sd86.5 
Cc:  robertwb  Merged in:  
Authors:  Nils Bruin  Reviewers:  Aly Deines 
Report Upstream:  N/A  Work issues:  
Branch:  6789aec (Commits)  Commit:  6789aeca7204cbeeeecce566f86ab3ca93e75919 
Dependencies:  Stopgaps: 
Description
We currently don't have a fast callable interpreter that is specialized for ComplexField?. The obvious candidate is to base one on the mpc library (although sage's ComplexNumber is not based on mpc!!)
Change History (19)
comment:1 Changed 3 years ago by
 Branch set to u/nbruin/fast_callable_for_domain_complexfield_____
comment:2 followup: ↓ 4 Changed 3 years ago by
 Commit set to 6ddf1fe1780c754b1d14ec8689550f5c2461686f
comment:3 Changed 3 years ago by
(Trac madness, I didn't set the commit, it was already there.)
comment:4 in reply to: ↑ 2 Changed 3 years ago by
Replying to leif:
The library order in
# distutils: libraries =
is wrong, and I don't think you need GMP there.But it seems redundant anyway, when you're importing from
sage.libs.{mpfr,mpc}
.
It seemed; just noticed both mpfr.pxd
and mpc.pxd
still lack # distutils:
directives.
comment:5 Changed 3 years ago by
 Commit changed from 6ddf1fe1780c754b1d14ec8689550f5c2461686f to 0c29de6d45eba03ec34144b9d9daca2eccdd1235
Branch pushed to git repo; I updated commit sha1. New commits:
0c29de6  trac 21198: fix new element allocation so that "CC.zero()" doesn't get clobbered

comment:6 Changed 3 years ago by
 Status changed from new to needs_review
I think it works now! Timing improvements are signficant but not spectacular.
comment:7 followup: ↓ 8 Changed 3 years ago by
Could you give [your] application examples?
comment:8 in reply to: ↑ 7 Changed 3 years ago by
Replying to leif:
Could you give [your] application examples?
The main application would be computing the periods of algebraic Riemann surfaces. You end up with a lot of newton iterations on complexvalued polynomials to compute analytic continuations, in order to compute integrals numerically. Convincing examples require extensive code (this is functionality that I intend to contribute).
So, the simplest example is perhaps newton iteration?
def newton_iterate(f,z,w0): """ Approximate a value w such that f(z,w)=0, using Newton iteration starting at w0""" CC=w0.parent() R=f.parent() F=fast_callable(f,domain=CC) dF=fast_callable(f.derivative(R.1),domain=CC) delta=F(z,w0)/dF(z,w0) Ndelta=delta.norm() w0+=delta while True: new_delta=F(z,w0)/dF(z,w0) Nnew_delta=new_delta.norm() if Nnew_delta == 0 or Nnew_delta >= Ndelta: return w0 delta=new_delta Ndelta=Nnew_delta w0+=delta sage: R.<x,y>=QQ[] sage: f=y^2x^3x1 sage: CC=ComplexField(1000) sage: %timeit newton_iterate(f,CC(1,1),CC(1.2,1.2)) 1000 loops, best of 3: 1.21 ms per loop
comment:9 Changed 3 years ago by
 Cc robertwb added
CCing Robert Bradshaw, on the off chance that he's still capable/willing to do ticket reviews (I think he's one of the few who has worked on fast_callable). Any other reviewer should be fine too.
comment:10 Changed 2 years ago by
 Commit changed from 0c29de6d45eba03ec34144b9d9daca2eccdd1235 to f7602b50a4715da9b7ad9cfb7abfa0aa6c0298f3
comment:11 Changed 2 years ago by
 Commit changed from f7602b50a4715da9b7ad9cfb7abfa0aa6c0298f3 to d020f412fc5d7e05ffcef3b486f48d207eee510d
Branch pushed to git repo; I updated commit sha1. This was a forced push. New commits:
d020f41  Implement a fast_callable interpreter for multiprecision complex numbers , based on mpc.

comment:12 Changed 2 years ago by
 Commit changed from d020f412fc5d7e05ffcef3b486f48d207eee510d to 05edc910c22f52cd5fac088d00991aadf11fddcf
Branch pushed to git repo; I updated commit sha1. This was a forced push. New commits:
05edc91  Implement a fast_callable interpreter for multiprecision complex numbers , based on mpc.

comment:13 Changed 2 years ago by
Updated to fit with new layout of interpreters. Ready for merge.
comment:14 Changed 2 years ago by
 Keywords sd86.5 added
comment:15 Changed 2 years ago by
 Commit changed from 05edc910c22f52cd5fac088d00991aadf11fddcf to 4febb2df4f6a70f1bc19c192e1af451b8e1247cb
Branch pushed to git repo; I updated commit sha1. This was a forced push. New commits:
4febb2d  Implement a fast_callable interpreter for multiprecision complex numbers , based on mpc.

comment:16 Changed 2 years ago by
 Commit changed from 4febb2df4f6a70f1bc19c192e1af451b8e1247cb to 6789aeca7204cbeeeecce566f86ab3ca93e75919
Branch pushed to git repo; I updated commit sha1. New commits:
6789aec  doctest, referee changes

comment:17 Changed 2 years ago by
 Reviewers set to Aly Deines
 Status changed from needs_review to positive_review
Thanks for adding the doctests.
I'm seeing a bit of a speed up when I use this. Nice!
comment:18 Changed 2 years ago by
 Milestone set to sage8.0
comment:19 Changed 2 years ago by
 Branch changed from u/nbruin/fast_callable_for_domain_complexfield_____ to 6789aeca7204cbeeeecce566f86ab3ca93e75919
 Resolution set to fixed
 Status changed from positive_review to closed
There are a few copypaste leftovers in comments (RR, mpfr instead of CC, mpc).
The library order in
# distutils: libraries =
is wrong, and I don't think you need GMP there. But it seems redundant anyway, when you're importing fromsage.libs.{mpfr,mpc}
.New commits:
trac 21198: implement MPC based fast_callable for ComplexField