sagemath / sage

Main repository of SageMath
https://www.sagemath.org
Other
1.33k stars 453 forks source link

Speed up some methods for quasimodular forms ring elements #34778

Closed DavidAyotte closed 1 year ago

DavidAyotte commented 1 year ago

The goal of this ticket is to refactor the following methods:

Currently, these methods are implemented using polynomial conversion of graded quasimodular forms ring elements which is relatively expensive and totally unecessary. It is possible to speed up the code simply by using the fact that a graded quasimodular form is a univariate polynomial in E2 (the weight 2 Eisenstein series) over the subring of modular forms.

CC: @videlec

Component: modular forms

Author: David Ayotte

Branch/Commit: u/gh-DavidAyotte/refactor_weight_method_quasimodforms @ 271d87d

Reviewer: Vincent Delecroix

Issue created by migration from https://trac.sagemath.org/ticket/34778

DavidAyotte commented 1 year ago

Branch: u/gh-DavidAyotte/refactor_weight_method_quasimodforms

DavidAyotte commented 1 year ago

Commit: 8eb423f

DavidAyotte commented 1 year ago
comment:2

Some tests:

sage: QM = QuasiModularForms(1)
sage: E2, E4, E6 = QM.gens()
sage: F = E6^3 + E4^4*E2 + (E4^2*E6)*E2^2 + (E4^3 + E6^2)*E2^3
sage: time(F.weight())
CPU times: user 114 µs, sys: 15 µs, total: 129 µs
Wall time: 133 µs
18
sage: time(F.is_homogeneous())
CPU times: user 109 µs, sys: 14 µs, total: 123 µs
Wall time: 128 µs
True
sage: time(F.homogeneous_components())
CPU times: user 10.5 ms, sys: 31 µs, total: 10.6 ms
Wall time: 10.2 ms
{18: 5 - 1296*q + 1287504*q^2 - 79583040*q^3 - 8643792240*q^4 - 476322048864*q^5 + O(q^6)}
sage: time(F.weights_list())
CPU times: user 2.3 ms, sys: 0 ns, total: 2.3 ms
Wall time: 2.31 ms
[18]

The same tests performed on the current develop branch:

sage: QM = QuasiModularForms(1)
sage: E2, E4, E6 = QM.gens()
sage: F = E6^3 + E4^4*E2 + (E4^2*E6)*E2^2 + (E4^3 + E6^2)*E2^3
sage: time(F.weight())
CPU times: user 190 ms, sys: 0 ns, total: 190 ms
Wall time: 186 ms
18
sage: time(F.is_homogeneous())
CPU times: user 16 ms, sys: 0 ns, total: 16 ms
Wall time: 15.2 ms
True
sage: time(F.homogeneous_components())
CPU times: user 28.6 ms, sys: 428 µs, total: 29 ms
Wall time: 27.6 ms
{18: 5 - 1080*q + 1272024*q^2 - 49729248*q^3 - 8985745800*q^4 - 449504439120*q^5 + O(q^6)}
sage: time(F.weights_list())
CPU times: user 19.4 ms, sys: 504 µs, total: 19.9 ms
Wall time: 19 ms
[18]

New commits:

8eb423fsrc/sage/modular/quasimodform/element.py: refactor weight, homogeneous_components and is_homogeneous
7ed8c4ca-6d56-4ae9-953a-41e42b4ed313 commented 1 year ago

Changed commit from 8eb423f to 99b8518

7ed8c4ca-6d56-4ae9-953a-41e42b4ed313 commented 1 year ago

Branch pushed to git repo; I updated commit sha1. New commits:

99b8518src/sage/modular/quasimodform/element.py: fix small mistake
7ed8c4ca-6d56-4ae9-953a-41e42b4ed313 commented 1 year ago

Branch pushed to git repo; I updated commit sha1. New commits:

da7e598src/sage/modular/quasimodform/element.py: fix doctest
7ed8c4ca-6d56-4ae9-953a-41e42b4ed313 commented 1 year ago

Changed commit from 99b8518 to da7e598

videlec commented 1 year ago
comment:5

Maybe

-        return sorted(list(self.homogeneous_components().keys()))
+        return sorted(self.homogeneous_components().keys())
videlec commented 1 year ago

Reviewer: Vincent Delecroix

videlec commented 1 year ago
comment:6

The rest looks good to me.

7ed8c4ca-6d56-4ae9-953a-41e42b4ed313 commented 1 year ago

Branch pushed to git repo; I updated commit sha1. New commits:

d5c79a7src/sage/modular/quasimodform/element.py: add continue statement in is_homogeneous
271d87dsrc/sage/modular/quasimodform/element.py: apply suggestion
7ed8c4ca-6d56-4ae9-953a-41e42b4ed313 commented 1 year ago

Changed commit from da7e598 to 271d87d

vbraun commented 1 year ago
comment:10

Merge failure on top of:

015f8720227 Trac #34760: latex of empty SkewPartition is broken

5c23d3eeb96 Trac #34734: Adapt findstat interface to new version of findstat.org

d37bee32ca5 Trac #34714: fast path for factoring monomials over number fields

06e4d048d10 Trac #34698: Fix conversion bug in modular forms rings

59b829a72eb Trac #34690: implement more constructions for Hadamard matrices, e.g. for size 116

a372136c066 Trac #33941: Implement from_integer and to_integer for all finite fields, extending and replacing fetch_int and integer_representation

3b1c9de1201 Trac #33757: commutativity test

34266283ab5 Trac #29360: change_ring() should preserve sparsity of vectors and vector spaces

1f56ce0e9d7 Trac #27652: parent of plethysm

019537d9929 Trac #34693: Further support for matplotlib 3.6

59e9f7b4f01 Trac #34658: Update numpy to 1.23.5, scipy 1.9.3, networkx 2.8.8, meson_python 0.11.0

6d03a671290 Trac #34593: Document and manage temporary directories

454290087ec Trac #33842: Upgrade python to 3.11

f53f07a063f Trac #34766: GH Actions: Update actions

795383fbdc9 Trac #34728: change sorting for WeierstrassIsomorphism

2cec793d624 Trac #33562: Bad error message for weighted adjacency matrix

3670306d20f Trac #34740: dead hyperlinks in developer manual

9666ae7ced6 Trac #34722: some code cleanup in WeierstrassIsomorphism

f41abf6243d Trac #34759: some details in filtered simplicial complexes

dfc299ba564 Trac #34756: Documentation regarding setting up SageMath's Jupyter kernel in an existing installation points to wrong directory

513a7bc6a9c Trac #34753: fix all W391 in pyx files

7503e42cf2f Trac #34751: Update sage tutorial

623ea7446d3 Trac #34745: modernize super in algebras/ again

f2fa7597737 Trac #34741: OS X 13: filter out dylib warning

a4748c342ab Trac #34738: tiny details in symbolic min and max

fb213dfda77 Trac #34769: use libgap in simplicial_complex

01beb6a1069 Trac #34765: meson: Add spkg-configure.m4

d94c7334140 Trac #34762: Fix random chain complex doctest

b3398f0543d Trac #34761: Remove src/sage/libs/fes.pyx

3c42a395c22 Trac #34754: Remove module-level imports from sage.plot

0d120581338 Trac #34569: Fix some quasimodular forms rings methods for congruence subgroups

84f02afa5c8 Updated SageMath version to 9.8.beta4

merge was not clean: conflicts in src/sage/modular/quasimodform/element.py

mkoeppe commented 1 year ago

Removed branch from the issue description because it has been replaced by PR #35004