Skip to content
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

algebraic intersection is way to slow #311

Open
videlec opened this issue Nov 18, 2024 · 0 comments
Open

algebraic intersection is way to slow #311

videlec opened this issue Nov 18, 2024 · 0 comments

Comments

@videlec
Copy link
Collaborator

videlec commented Nov 18, 2024

The algebraic intersection is an anti-symmetric bilinear map $H_1(S; \mathbb{Z}) \times H_1(S; \mathbb{Z}) \to \mathbb{Z}$. The values should be computed once on a basis (or alternatively generators) and stored as a matrix so that algebraic_intersection is as fast as vector x matrix x vector multiplication. Right now, it is extremely slow.

With

S = translation_surfaces.mcmullen_L(1,1,1,1)
H = S.homology()
gens = H.gens()
intersection_matrix = matrix(ZZ, len(gens))
for i, gi in enumerate(gens):
    for j, gj in enumerate(gens):
        intersection_matrix[i, j] = gi.algebraic_intersection(gj)
B = set(H(sc) for sc in S.saddle_connections(10))

One can compare the 50ms of

for h1 in B:
    for h2 in B:
        _ = vector(ZZ, h1.coefficients()) * intersection_matrix * vector(ZZ, h2.coefficients())

with the 3s of

%%time
for h1 in B:
    for h2 in B:
        _ = h1.algebraic_intersection(h2)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

1 participant