-
Notifications
You must be signed in to change notification settings - Fork 35
acb_theta_jet #392
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
Open
SamSchiavone
wants to merge
5
commits into
flintlib:main
Choose a base branch
from
SamSchiavone:acb_theta_jet
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
acb_theta_jet #392
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
f3dd05a
working on getting acb_theta_jet in Magma; need to rebuild using meson
SamSchiavone 75b6aab
Some bug-fixing
JHanselman cd11057
Removed nonsense
JHanselman 22b4e5a
Add tests and docstring
JHanselman 2c390d8
fixed linter issues
SamSchiavone File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -95,3 +95,84 @@ def acb_theta(acb_mat z, acb_mat tau, ulong square=False): | |
| res.append(r) | ||
| _acb_vec_clear(theta, nb) | ||
| return acb_mat([res]) | ||
|
|
||
|
|
||
| def acb_theta_jets(acb_mat z, acb_mat tau, slong ord): | ||
| r""" | ||
| Computes the coefficients of the Taylor expansion of the vector valued Riemann | ||
| theta function `(\theta_{a,b}(z, \tau) : a, b \in \{0,1\}^{g})` or its squares. | ||
|
|
||
| This is a wrapper for the C-function | ||
| `acb_theta_jet <https://flintlib.org/doc/acb_theta.html#c.acb_theta_jet>`_ | ||
| and it follows the same conventions for the ordering of the theta characteristics. | ||
|
|
||
| This should be used via the method :meth:`.acb_mat.theta_jets`, explicitly ``tau.theta_jets(z, ord)``. | ||
|
|
||
| >>> from flint import acb, acb_mat, showgood, ctx | ||
| >>> z = acb(1+1j); tau = acb(1.25+3j) | ||
| >>> acb_mat([[tau]]).theta_jets(acb_mat([[z]]),2) # doctest: +SKIP | ||
| [[0.969443038779670 +/- 5.67e-16] + [-0.0305569612081680 +/- 5.13e-17]j, | ||
| [-0.191993710594950 +/- 4.89e-16] + [0.191993710747776 +/- 7.42e-16]j, | ||
| [0.60317023860834 +/- 2.93e-15] + [0.60317023764810 +/- 4.86e-15]j] | ||
| [[1.03055696119601 +/- 3.89e-15] + [0.0305569612081680 +/- 5.13e-17]j, | ||
| [0.191993710594950 +/- 4.89e-16] + [-0.191993710442123 +/- 4.62e-16]j, | ||
| [-0.60317023668787 +/- 5.90e-15] + [-0.60317023764810 +/- 4.86e-15]j] | ||
| [[-1.22079026757697 +/- 4.36e-15] + [-1.82705551679115 +/- 5.17e-15]j, | ||
| [-5.71849316258739 +/- 7.02e-15] + [3.82088827346268 +/- 5.75e-15]j, | ||
| [6.0241074288587 +/- 3.88e-14] + [9.0163253443780 +/- 2.05e-14]j] | ||
| [[-1.82023591012499 +/- 2.67e-15] + [1.21625195015448 +/- 4.14e-15]j, | ||
| [3.8353056542516 +/- 4.99e-14] + [5.73981078971270 +/- 6.74e-15]j, | ||
| [8.9823364151977 +/- 2.44e-14] + [-6.0022138700195 +/- 3.72e-14]j] | ||
| """ | ||
| g = tau.nrows() | ||
| if g == 0: | ||
| return [] | ||
|
|
||
| # Calculate the length of the jet for one characteristic | ||
| # This is the number of multi-indices (alpha) such that |alpha| < ord | ||
| cdef slong nj = acb_theta_jet_nb(g, ord) | ||
|
|
||
| # Total number of characteristics | ||
| cdef slong nb = 1 << (2 * g) | ||
|
|
||
| # Total number of acb elements to allocate | ||
| # FLINT stores nj coefficients for each of the nb characteristics | ||
| cdef slong total_size = nb * nj | ||
|
|
||
| cdef acb_ptr zvec = _acb_vec_init(g) | ||
| cdef slong i, j | ||
| for i in range(g): | ||
| acb_set(zvec + i, acb_mat_entry(z.val, i, 0)) | ||
|
|
||
| # Parameters for characteristics | ||
| cdef slong nb_in = 1 # Number of input z vectors | ||
| cdef ulong ab = 0 # Base characteristic | ||
| cdef ulong all = True # Compute all 2^2g characteristics | ||
| cdef ulong square = False # Don't compute the squares of the thetas. | ||
|
|
||
| # Initialize the output buffer | ||
| cdef acb_ptr theta = _acb_vec_init(total_size) | ||
|
|
||
| # Call the FLINT C function | ||
| # Note: Computes all partial derivatives up to total order 'ord' | ||
| acb_theta_jet(theta, zvec, nb_in, tau.val, ord, ab, all, square, getprec()) | ||
|
|
||
| # Copy the output into a structured format | ||
| # We return a list of lists: res[char_idx] = [coeff_0, coeff_1, ...] | ||
| res = [] | ||
| cdef acb r | ||
| for i in range(nb): | ||
| char_jet = [] | ||
| for j in range(nj): | ||
| r = acb.__new__(acb) | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Rather than creating Python-level acb objects and then using those to create an acb_mat. it would be more efficient to create an acb_mat and use loop over acb_set/acb_mat_entry. |
||
| # Offset: characteristic index * length of one jet + coefficient index | ||
| acb_set(r.val, theta + (i * nj + j)) | ||
| char_jet.append(r) | ||
| res.append(char_jet) | ||
|
|
||
| # Cleanup | ||
| _acb_vec_clear(zvec, g) | ||
| _acb_vec_clear(theta, total_size) | ||
|
|
||
| return acb_mat(res) | ||
|
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The indentation here is off.