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

Add HarmonicDifferentials #213

Draft
wants to merge 540 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 180 commits
Commits
Show all changes
540 commits
Select commit Hold shift + click to select a range
58210a6
Parallelize L2 computations
saraedum Nov 16, 2023
9319cce
Cache cheap but very frequent computations
saraedum Nov 16, 2023
5b78bf4
Break out symbolic expression into a separate module
saraedum Nov 17, 2023
707a7a3
Make 3,4,13 example work with harmonic differentials
saraedum Nov 20, 2023
a86db03
Work around random output in doctests
saraedum Nov 20, 2023
d9303e4
Fix evaluation of harmonic differentials
saraedum Nov 20, 2023
7185756
Fix doctest output of root_branch
saraedum Nov 20, 2023
1b0c38b
Adapt doctest output to changed printing
saraedum Nov 20, 2023
8673bd1
Untangle power series constraints from generic symbolic computations …
saraedum Nov 21, 2023
a383b94
Fix invocations of HarmonicDifferentials
saraedum Nov 21, 2023
9b7cae1
Fix invocations of voronoi diagram
saraedum Nov 21, 2023
99654da
Simplify PowerSeriesConstraints interface
saraedum Nov 28, 2023
cca138c
Fix doctests
saraedum Dec 1, 2023
3395b87
Fix relation of paths and homology when there is more than one polygon
saraedum Dec 1, 2023
2ecf69b
Drop cohomolyg hack when computing harmonic differentials
saraedum Dec 4, 2023
54371fd
Merge remote-tracking branch 'origin/master' into deformation
saraedum Dec 12, 2023
fab140a
Fix output of intersection number
saraedum Dec 12, 2023
5032b35
Adapt veering triangulation code to changes from deformation
saraedum Dec 12, 2023
e9fea16
sage-flatsurf needs bidict now
saraedum Dec 12, 2023
be70139
Fix doctests
saraedum Dec 31, 2023
ae245b3
Add relative homology
saraedum Dec 31, 2023
e54d5fa
Add TODO to documentation
saraedum Jan 4, 2024
a27cfbf
Make standardize_polygons return a morphism
saraedum Jan 4, 2024
e3878ea
Fix typo
saraedum Jan 5, 2024
7eb7e3a
Make canonicalize() produce a morphism
saraedum Jan 5, 2024
dc3ce21
Fix caching of cohomology
saraedum Jan 5, 2024
66c1d57
Add some (co)homology TODOs
saraedum Jan 5, 2024
9a4b311
Use dimension explicitly in cohomology
saraedum Jan 6, 2024
c8204f8
Make dimension implicit in homology groups
saraedum Jan 6, 2024
561776f
Rename delaunay module to lazy
saraedum Jan 8, 2024
d68c28d
Simplify implementation of Euclidean primitives
saraedum Jan 8, 2024
82fda2a
Speed up Euclidean geometry
saraedum Jan 8, 2024
ebfa3ba
Remove unused code
saraedum Jan 8, 2024
b5fa001
Drop old comment and simplify imports
saraedum Jan 8, 2024
1119018
Cleanup line_intersection() code
saraedum Jan 8, 2024
4eca237
Make euclidean geometry assume that inputs are vectors
saraedum Jan 8, 2024
dbc3a69
Fix deprecation warnings in erase_marked_points()
saraedum Jan 8, 2024
c1cd360
Fix relative homology
saraedum Jan 9, 2024
bcabacd
Fix TODOs
saraedum Jan 9, 2024
7bf5d74
Resolve TODO
saraedum Jan 9, 2024
ba40de9
Fix code sharing for triangulation
saraedum Jan 9, 2024
6712799
Drop TODO
saraedum Jan 9, 2024
5a6a861
Fix pickling for pyflatsurf surfaces
saraedum Jan 9, 2024
e82c29b
Postpone TODO
saraedum Jan 9, 2024
7718351
Make sure old TODOs are rendered in the documentation
saraedum Jan 9, 2024
2c21173
Fix grammar
saraedum Jan 9, 2024
519445b
Fix documentation and news
saraedum Jan 9, 2024
ab3f3e8
Fix tracking of morphism/deformation with pyflatsurf
saraedum Jan 9, 2024
8fa8309
Resolve TODO about cathedral surface
saraedum Jan 10, 2024
2bafdf3
Cleanup _image_edge of morphisms
saraedum Jan 10, 2024
59bcb9c
Implement _image_point for triangulation morphisms
saraedum Jan 10, 2024
d2a9e59
Implement mapping points through erasure of marked points
saraedum Jan 10, 2024
8c19839
Implement and document methods of identity morphisms
saraedum Jan 10, 2024
187663b
Fix category machinery for surface morphisms
saraedum Jan 11, 2024
5d82a23
Make test suite pass for spaces of morphisms
saraedum Jan 12, 2024
76337bf
Fix printing of surface morphisms
saraedum Jan 12, 2024
3b37e31
Allow iterating over all saddle connections
saraedum Jan 12, 2024
ee06405
Cleanup handling of sections and add more tests
saraedum Jan 13, 2024
ac22479
Cleanup saddle connection computations
saraedum Jan 17, 2024
db71901
Fix doctest warnings
saraedum Jan 17, 2024
c31c297
Fix mutability of normalized_coordinates()
saraedum Jan 17, 2024
c6739a1
Fix is_segment_intersecting
saraedum Jan 17, 2024
c21ee5f
Fix most pytest tests
saraedum Jan 17, 2024
4074d22
Fix is_segment_intersecting
saraedum Jan 17, 2024
13cb500
Fix typo
saraedum Jan 17, 2024
0f77108
Implement and fix saddle connections with non-convex polygonal surfaces
saraedum Jan 18, 2024
3226c15
Drop fixed deprecation warning from test
saraedum Jan 19, 2024
037ed80
Fix path of mpreal-support header
saraedum Jan 25, 2024
115377f
Add basis() helper for harmonic differentials
saraedum Jan 25, 2024
2517b47
Merge branch 'deformation' into hodge
saraedum Jan 25, 2024
a85ced0
Fix merge errors
saraedum Jan 25, 2024
a461e18
Fix merge errors
saraedum Jan 25, 2024
84067ae
Fix failing doctests
saraedum Jan 25, 2024
9a4d08a
Fix most doctests
saraedum Jan 25, 2024
c6f0083
Add symplectic basis for homology groups
saraedum Jan 26, 2024
913a63b
Add period matrix of harmonic differentials
saraedum Jan 26, 2024
cf1438f
Add generic deformation to orbit closure
saraedum Jan 30, 2024
2c4ca51
Cache expensive computations in harmonic differentials
saraedum Jan 30, 2024
a1e3398
Transpose period matrix to be consistent with riemann surfaces in Sag…
saraedum Jan 31, 2024
85829cd
Submit incomplete changes to continue work on harmonic differentials
saraedum Jan 25, 2024
e014345
Merge branch 'deformation' into hodge
saraedum Feb 2, 2024
00a6335
Fix typo
saraedum Feb 2, 2024
0550503
Fix location of polygon after subdivide edges
saraedum Feb 2, 2024
dd5328d
Add singularities() method for cone surfaces
saraedum Feb 2, 2024
ee6bb29
Fix immutability of polygons after subdivide
saraedum Feb 2, 2024
3df21d7
Add angle() to points in a surface
saraedum Feb 2, 2024
be7ab2c
Speed up is_with_boundary()
saraedum Feb 2, 2024
38597c6
Allow algorithm selection when enumerating saddle connections
saraedum Feb 2, 2024
7ed0474
Fix pickling of surfaces with lazy labels
saraedum Feb 2, 2024
4823335
Add a draft of geometric primitives
saraedum Feb 2, 2024
c7073e9
Add symplectic basis to homology
saraedum Feb 2, 2024
a68e79f
Add more sections to morphisms
saraedum Feb 2, 2024
5b4c0bd
Remove fixed warning
saraedum Feb 2, 2024
c1cb76f
Add more sections to morphisms
saraedum Feb 2, 2024
622dba9
Add flatsurf saddle connection wrapper
saraedum Feb 2, 2024
ed832af
Fix doctests
saraedum Feb 2, 2024
ee55d2f
Fix hashing of some surfaces
saraedum Feb 2, 2024
1852403
Fix doctests
saraedum Feb 2, 2024
08f02d8
Fix error message
saraedum Feb 2, 2024
05bfe7d
Fix plotting of surfaces with boundary
saraedum Feb 2, 2024
8166bdc
Add TODO
saraedum Feb 2, 2024
8c2b97f
Fix doctests
saraedum Feb 2, 2024
a6f0af6
Make conversion from and to exact real with pyflatsurf work again
saraedum Feb 2, 2024
28003ed
Implement conversion from AA to pyflatsurf
saraedum Feb 4, 2024
623a6f6
Add a draft of Euclidean geometry ressembling our hyperbolic geometry
saraedum Feb 9, 2024
7be676c
Cleanup hyperbolic geometry
saraedum Feb 9, 2024
bfb89de
Fix circle_from_three_points
saraedum Feb 9, 2024
86c7e2e
Merge circle copyright into euclidean copyright
saraedum Feb 9, 2024
a363ce6
Fix doctests
saraedum Feb 9, 2024
7e79c51
Merge branch 'deformation' into hodge
saraedum Feb 9, 2024
bc3326c
Fix doctests
saraedum Feb 9, 2024
4d9f85b
Fix doctests
saraedum Feb 9, 2024
30b3485
Fix doctests
saraedum Feb 9, 2024
4fa0f6e
Merge branch 'deformation' into hodge
saraedum Feb 9, 2024
b9af4fb
Hide more of the pyflatsurf surface interface in GL2ROrbitClosure
saraedum Feb 10, 2024
099a635
Simplify pyflatsurf conversion code
saraedum Feb 11, 2024
74383c2
Make FlowComponents objects in sage-flatsurf
saraedum Feb 11, 2024
03e7bc5
Add TODO
saraedum Feb 13, 2024
0d936f3
Generalize subdivisions
saraedum Feb 13, 2024
a342577
Merge branch 'deformation' into hodge
saraedum Feb 13, 2024
4d925d7
Fix radius of convergence computations for Voronoi cells
saraedum Feb 13, 2024
b16ed65
Add error computations
saraedum Feb 19, 2024
0a665bd
Generalize insertion of marked points
saraedum Feb 19, 2024
71eb143
Merge branch 'deformation' into hodge
saraedum Feb 19, 2024
b3d1d48
A draft of generalized Voronoi cells
saraedum Feb 21, 2024
7c4fd50
Fix multiplication of identity morphisms
saraedum Feb 21, 2024
4631b77
Simplify equality of the unknown surface
saraedum Feb 21, 2024
2ee91ce
Add more generalized Voronoi bits
saraedum Feb 27, 2024
817db63
Revert "Add more generalized Voronoi bits"
saraedum Feb 27, 2024
b487a5e
Revert "A draft of generalized Voronoi cells"
saraedum Feb 27, 2024
774a65d
Only allow Voronoi cells around vertices
saraedum Feb 27, 2024
c748001
A draft of cheaper Apollonius disks
saraedum Feb 27, 2024
c808d6b
Revert "A draft of cheaper Apollonius disks"
saraedum Feb 28, 2024
2485be9
Fix equality checks for half spaces
saraedum Feb 28, 2024
598ce0a
Add a more involved harmonic differential example
saraedum Feb 28, 2024
7e22f81
Replace ncoefficients with explicit error bounds
saraedum Feb 28, 2024
3cb01e2
Fix classical Voronoi cell computations
saraedum Feb 28, 2024
8e48898
Simplify and generalize Voronoi cell machinery
saraedum Mar 4, 2024
dd9cd1c
Fix doctests
saraedum Mar 4, 2024
8a4643b
Add some TODOs for surface plotting
saraedum Mar 4, 2024
4ba092d
Add a generic isometry morphism to implement rotations and such
saraedum Mar 5, 2024
a040346
Add mapping of cohomology classes through isomorphisms
saraedum Mar 5, 2024
0c93acc
Map harmonic differentials through morphisms
saraedum Mar 5, 2024
c067cab
A first version of functional non-Voronoi cells
saraedum Mar 8, 2024
71d0c7a
A first draft of a cleaner setup for cell decompositions
saraedum Mar 8, 2024
fb93b97
Make approximate Voronoi cells work
saraedum Mar 10, 2024
2a3923f
Speed up cell computations
saraedum Mar 10, 2024
c64a83e
Fix bug in roots containment of surfaces
saraedum Mar 10, 2024
f6b85ad
Improve layouting of finite type surfaces
saraedum Mar 10, 2024
ebf15c8
Adapt harmonic differentials to cell constructions
saraedum Mar 10, 2024
01a1cbf
Better error reporting for harmonic differentials
saraedum Mar 11, 2024
26524db
Fix corners()
saraedum Mar 12, 2024
40b3f57
A draft of exporting tangent vectors to simplicial cohomology for fee…
saraedum Mar 13, 2024
3cc2b9f
Add convenience interface to relabel()
saraedum Mar 15, 2024
8f64dc7
Update 3413 example for harmonic differentials
saraedum Mar 15, 2024
379c3e9
Speed up graphical surface copying
saraedum Mar 15, 2024
d3f48dc
Compute roots of differentials
saraedum Mar 21, 2024
4bcb764
Implement normalization of linear system to bring down condition when…
saraedum Mar 27, 2024
f68239e
Cache L2 consistency for various cohomology classes
saraedum Mar 27, 2024
ea98c34
Speed up surface layouting algorithm
saraedum Mar 27, 2024
f0d6155
Speed up is_segment_intersecting() with bounding box computations
saraedum Mar 27, 2024
f393a19
Fix box intersection algorithm
saraedum Mar 28, 2024
ae275eb
Speed up plotting
saraedum Mar 28, 2024
dca3349
Speed up plotting by computing vertex locations on demand
saraedum Mar 28, 2024
acc08fe
Add methods to show how points in a surface cluster
saraedum Mar 28, 2024
610d18a
Improve differential caching and reporting of L2 errors
saraedum Mar 28, 2024
453fb7a
Implement clustering of roots
saraedum Mar 29, 2024
6e05afa
Add explicit forcing of zeros at singularities
saraedum Mar 29, 2024
753256f
Fix forcing of zeros near singularities
saraedum Mar 29, 2024
7005bdb
Speed up root branch computations
saraedum Mar 29, 2024
97312a4
Export L2 explicitly in differential
saraedum Mar 29, 2024
24eb27c
Speed up radius of convergence computations when repeated
saraedum Mar 29, 2024
4a8f80f
Enable denormalization again and fix formula for scaling factor
saraedum Mar 29, 2024
5b50069
Make prescribed singularities configurable
saraedum Mar 29, 2024
23fcc5a
Speed up differential computations
saraedum Mar 29, 2024
ffb6c9b
Improve condition of harmonic differential system by using inradius
saraedum Mar 31, 2024
9984758
Fix doctest output
saraedum Mar 31, 2024
6e2b1b7
Make it easier to show zero flags when plotting
saraedum Mar 31, 2024
206497f
Bring adjaciencies=[] feature back
saraedum Mar 31, 2024
955b88c
Remove temporary asserts again
saraedum Mar 31, 2024
c511698
Update doctest
saraedum Mar 31, 2024
62754d6
Fix distance computations
saraedum Apr 3, 2024
2073af6
Fix typo in error message
saraedum Apr 3, 2024
578e968
Silence verbose error output a bit
saraedum Apr 3, 2024
7a1e615
Towards better coefficient counts for harmonic differentials
saraedum Apr 3, 2024
e6def81
Run expensive import only once
saraedum Apr 6, 2024
b8ddc37
Disable (likely) broken plotting code
saraedum Apr 6, 2024
e81ceda
Use CDF/RDF for speed
saraedum Apr 6, 2024
7ce8469
Faster computation by more aggressive caching of roots of unity
saraedum Apr 7, 2024
c2f5052
Faster iszero for power series
saraedum Apr 7, 2024
9af37c6
Minor speedups
saraedum Apr 7, 2024
88e5b05
Fix Delaunay triangulation
saraedum Apr 16, 2024
1c9f452
Make mapped voronoi decompositions mostly functional
saraedum Apr 22, 2024
4a730b5
Drop unused code
saraedum Apr 23, 2024
527d7e0
Fix printing of mapped cells
saraedum Apr 23, 2024
d1f0a57
Normalize differential in example
saraedum Apr 24, 2024
c54927a
Initial version of a 3-4-13 overview which should be added to example…
saraedum May 3, 2024
d8cbd9b
Fix root finding of rational functions and implement generic preimage…
saraedum May 6, 2024
620a44e
Improve monodromy computations
saraedum May 7, 2024
5766b7a
Fix root clustering computations
saraedum May 7, 2024
99924d6
Modify monodromy a bit
saraedum May 8, 2024
a0f4720
Towards degree and ramification computations and controlling duplicat…
saraedum May 9, 2024
1a093c9
Implement deduplication of preimages of rational maps
saraedum May 11, 2024
c52f350
Make basic ramification point detection work
saraedum May 12, 2024
89a544d
Fix monodromy plots
saraedum May 14, 2024
0b69f8f
Some minor patches to improve monodromy
saraedum May 14, 2024
ade0d01
Do not abort monodromy plots when there is a problem with the data
saraedum May 16, 2024
4a4aaef
Black format source code
saraedum May 16, 2024
d2b263c
Merge remote-tracking branch 'origin/master' into hodge
saraedum May 16, 2024
7ae8f98
Describe an algorithm to determine ncoefficients()
saraedum May 28, 2024
31c3664
Add TODO
saraedum May 28, 2024
c6b82aa
Fix memory leak in computing L2 consistencies
saraedum Jun 9, 2024
d2309f8
Roots may not be exactly zero
saraedum Jun 9, 2024
2f44a64
Use same default value everywhere
saraedum Jun 9, 2024
d8666e7
Improve monodromy videos
saraedum Jun 9, 2024
fd96983
Fix ncoefficients
saraedum Jun 9, 2024
b06adf3
Speed up error plotting
saraedum Jun 9, 2024
b25ba6e
Speed up Voronoi machinery
saraedum Jun 9, 2024
fcd7542
Speed up some vector constructions
saraedum Jun 9, 2024
337587c
Add monodromy group calculation
saraedum Jun 9, 2024
9e9a5f0
Fix ordering in parallel monodromy computation
saraedum Jun 10, 2024
5273f58
Allow more recent exactreal
saraedum Jun 11, 2024
7d281ff
Merge remote-tracking branch 'origin/master' into hodge
saraedum Jun 12, 2024
fe6fa88
Merge remote-tracking branch 'origin/master' into hodge
saraedum Jun 13, 2024
b77334f
Merge branch 'cache' into hodge
saraedum Jul 2, 2024
2b8d15f
Fix cached methods
saraedum Jul 2, 2024
305017a
Bring back radius_of_convergence() that was deleted accidentally
saraedum Jul 4, 2024
97bed43
Merge branch 'cache' into hodge
saraedum Jul 4, 2024
2f6df21
Improve printing of cache and features in TOC
saraedum Jul 4, 2024
37554ac
Merge remote-tracking branch 'origin/master' into hodge
saraedum Jul 4, 2024
2e2786a
Fix typo
saraedum Jul 4, 2024
e00da28
Merge remote-tracking branch 'origin/master' into hodge
saraedum Jul 8, 2024
f7013f6
Merge remote-tracking branch 'origin/master' into deformation
saraedum Aug 9, 2024
19c4806
Black format source code
saraedum Aug 9, 2024
2ded549
Drop duplicate homology() and cohomology()
saraedum Aug 9, 2024
705dda3
Black format source code
saraedum Aug 25, 2024
63d1e1d
Merge branch 'veech-on-homology' into deformation
saraedum Aug 26, 2024
fc4451b
Merge branch 'deformation' into hodge
saraedum Aug 26, 2024
1251266
Merge branch 'master' into deformation
saraedum Aug 26, 2024
01403fa
Merge branch 'master' into hodge
saraedum Aug 26, 2024
d45d592
Merge branch 'delaunay-decompose' into deformation
saraedum Aug 26, 2024
1923bd9
Merge branch 'deformation' into hodge
saraedum Aug 26, 2024
4afd27e
Only cache for immutable surfaces
saraedum Aug 26, 2024
2683e44
Fix merge from deformation
saraedum Aug 26, 2024
736d628
Fix calls to delaunay_triangulate
saraedum Aug 26, 2024
a0790f1
Implement some eq and hash
saraedum Aug 26, 2024
8534fab
Simplify doctests
saraedum Aug 26, 2024
656136a
Fix warning
saraedum Aug 26, 2024
8f66b05
Allow mapping of line segments
saraedum Aug 26, 2024
b1e1ab9
Merge remote-tracking branch 'origin/master' into hodge
saraedum Aug 26, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 43 additions & 0 deletions benchmark/geometry/harmonic_differentials.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# ********************************************************************
# This file is part of sage-flatsurf.
#
# Copyright (C) 2022 Julian Rüth
#
# sage-flatsurf is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.
#
# sage-flatsurf is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with sage-flatsurf. If not, see <https://www.gnu.org/licenses/>.
# ********************************************************************
import flatsurf


def time_harmonic_differential(surface):
if surface == "TORUS":
surface = flatsurf.translation_surfaces.torus((1, 0), (0, 1))
elif surface == "3413":
E = flatsurf.EquiangularPolygons(3, 4, 13)
P = E.an_element()
surface = flatsurf.similarity_surfaces.billiard(P, rational=True).minimal_cover(cover_type="translation")
else:
raise NotImplementedError

surface = surface.delaunay_triangulation()
surface.set_immutable()
Ω = flatsurf.HarmonicDifferentials(surface)
a = flatsurf.SimplicialHomology(surface).gens()[0]
H = flatsurf.SimplicialCohomology(surface)
Ω(H({a: 1}), check=False)


time_harmonic_differential.params = ([
"TORUS",
"3413",
])
2 changes: 1 addition & 1 deletion doc/environment.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# This file lists the minimial dependencies needed to build the documentation
# This file lists the minimal dependencies needed to build the documentation
# for sage-flatsurf. Create a conda environment with these dependencies
# preinstalled with:
# conda env create -n sage-flatsurf-docbuild -f ../environment.yml
Expand Down
246 changes: 246 additions & 0 deletions doc/examples/harmonic.md

Large diffs are not rendered by default.

6 changes: 5 additions & 1 deletion flatsurf/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
"""
from flatsurf.version import version as __version__

from flatsurf.geometry.homology import SimplicialHomology
from flatsurf.geometry.cohomology import SimplicialCohomology
from flatsurf.geometry.harmonic_differentials import HarmonicDifferentials

from flatsurf.geometry.polygon import (
Polygon,
polygons,
Expand Down Expand Up @@ -34,5 +38,5 @@
ConeSurface,
RationalConeSurface,
HalfTranslationSurface,
TranslationSurface,
TranslationSurface
)
6 changes: 5 additions & 1 deletion flatsurf/features.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# ####################################################################
# This file is part of sage-flatsurf.
#
# Copyright (C) 2021 Julian Rüth
# Copyright (C) 2021-2023 Julian Rüth
#
# sage-flatsurf is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
Expand All @@ -28,3 +28,7 @@
pyflatsurf_feature = PythonModule(
"pyflatsurf", url="https://github.com/flatsurf/flatsurf/#install-with-conda"
)

pyeantic_feature = PythonModule(
"pyeantic", url="https://github.com/flatsurf/e-antic/#install-with-conda"
)
3 changes: 3 additions & 0 deletions flatsurf/geometry/categories/cone_surfaces.py
Original file line number Diff line number Diff line change
Expand Up @@ -382,6 +382,9 @@ def angles(self, numerical=False, return_adjacent_edges=False):

return angles

def singularities(self):
return [self.point(edges[0][0], self.polygon(edges[0][0]).vertex(edges[0][1])) for (angle, edges) in self.angles(return_adjacent_edges=True) if angle > 1]

class Connected(SurfaceCategoryWithAxiom):
r"""
The category of oriented connected cone surfaces without boundary.
Expand Down
1 change: 1 addition & 0 deletions flatsurf/geometry/categories/dilation_surfaces.py
Original file line number Diff line number Diff line change
Expand Up @@ -338,6 +338,7 @@ def apply_matrix(self, m, in_place=True, mapping=False):
if not us.is_mutable():
raise ValueError("in-place changes only work for mutable surfaces")
for label in self.labels():
# TODO: replace_polygon() does not exist anymore.
us.replace_polygon(label, m * self.polygon(label))
if m.det() < self.base_ring().zero():
# Polygons were all reversed orientation. Need to redo gluings.
Expand Down
13 changes: 7 additions & 6 deletions flatsurf/geometry/categories/euclidean_polygons.py
Original file line number Diff line number Diff line change
Expand Up @@ -1777,11 +1777,12 @@ def circumscribing_circle(self):
circle = circle_from_three_points(
self.vertex(0), self.vertex(1), self.vertex(2), self.base_ring()
)
for i in range(3, len(self.vertices())):
if not circle.point_position(self.vertex(i)) == 0:
raise ValueError(
"Vertex " + str(i) + " is not on the circle."
)
# TODO: Temporarily disabled because it fails over inexact rings.
# for i in range(3, len(self.vertices())):
# if not circle.point_position(self.vertex(i)) == 0:
# raise ValueError(
# "Vertex " + str(i) + " is not on the circle."
# )
return circle

def subdivide(self):
Expand Down Expand Up @@ -1870,7 +1871,7 @@ def subdivide_edges(self, parts=2):
steps = [e / parts for e in self.edges()]
from flatsurf import Polygon

return Polygon(edges=[e for e in steps for p in range(parts)])
return Polygon(edges=[e for e in steps for p in range(parts)]).translate(self.vertex(0))

def j_invariant(self):
r"""
Expand Down
4 changes: 4 additions & 0 deletions flatsurf/geometry/categories/polygonal_surfaces.py
Original file line number Diff line number Diff line change
Expand Up @@ -1075,6 +1075,10 @@ def is_with_boundary(self):
False

"""
if "WithoutBoundary" in self.category().axioms():
return False
if "WithBoundary" in self.category().axioms():
return True
for label in self.labels():
for edge in range(len(self.polygon(label).vertices())):
cross = self.opposite_edge(label, edge)
Expand Down
18 changes: 13 additions & 5 deletions flatsurf/geometry/categories/similarity_surfaces.py
Original file line number Diff line number Diff line change
Expand Up @@ -2073,7 +2073,7 @@ def subdivide(self):

Subdivision of this surface yields a surface with three triangles::

sage: T = S.subdivide()
sage: T = S.subdivide().codomain()
sage: T.labels()
(('Δ', 0), ('Δ', 1), ('Δ', 2))

Expand All @@ -2097,7 +2097,7 @@ def subdivide(self):
sage: S.glue(("Δ", 0), ("□", 2))
sage: S.glue(("□", 1), ("□", 3))

sage: T = S.subdivide()
sage: T = S.subdivide().codomain()

sage: T.labels()
(('Δ', 0), ('□', 2), ('Δ', 1), ('Δ', 2), ('□', 3), ('□', 1), ('□', 0))
Expand Down Expand Up @@ -2152,7 +2152,11 @@ def subdivide(self):
if opposite is not None:
surface.glue(((label, p), 0), (opposite, 0))

return surface
surface.set_immutable()

from flatsurf.geometry.deformation import SubdivideDeformation
return SubdivideDeformation(self, surface)


def subdivide_edges(self, parts=2):
r"""
Expand Down Expand Up @@ -2188,7 +2192,7 @@ def subdivide_edges(self, parts=2):
sage: S.glue(("Δ", 0), ("□", 2))
sage: S.glue(("□", 1), ("□", 3))

sage: T = S.subdivide_edges()
sage: T = S.subdivide_edges().codomain()
sage: list(sorted(T.gluings()))
[(('Δ', 0), ('□', 5)),
(('Δ', 1), ('□', 4)),
Expand Down Expand Up @@ -2229,7 +2233,11 @@ def subdivide_edges(self, parts=2):
),
)

return surface
surface.set_immutable()

from flatsurf.geometry.deformation import SubdivideEdgesDeformation

return SubdivideEdgesDeformation(self, surface, parts=parts)

class Rational(SurfaceCategoryWithAxiom):
r"""
Expand Down
23 changes: 23 additions & 0 deletions flatsurf/geometry/categories/translation_surfaces.py
Original file line number Diff line number Diff line change
Expand Up @@ -714,3 +714,26 @@ def canonicalize(self, in_place=None):
s.relabel(labels, in_place=True)
s.set_immutable()
return s

def _pyflatsurf(self):
r"""
Return a surface backed by libflatsurf that is isomorphic to this
surface and an isomorphism to that surface.

EXAMPLES::

sage: from flatsurf import MutableOrientedSimilaritySurface, Polygon
sage: S = MutableOrientedSimilaritySurface(QQ)
sage: S.add_polygon(Polygon(vertices=[(0, 0), (1, 0), (1, 1)]), label=0)
0
sage: S.add_polygon(Polygon(vertices=[(0, 0), (1, 1), (0, 1)]), label=1)
1
sage: S.glue((0, 0), (1, 1))
sage: S.glue((0, 1), (1, 2))
sage: S.glue((0, 2), (1, 0))
sage: S._to_pyflatsurf() # optional: pyflatsurf

"""
from flatsurf.geometry.pyflatsurf.surface import Surface_pyflatsurf

return Surface_pyflatsurf._from_flatsurf(self)
166 changes: 166 additions & 0 deletions flatsurf/geometry/cohomology.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,166 @@
r"""
TODO: Document this module.
"""
######################################################################
# This file is part of sage-flatsurf.
#
# Copyright (C) 2022 Julian Rüth
#
# sage-flatsurf is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.
#
# sage-flatsurf is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with sage-flatsurf. If not, see <https://www.gnu.org/licenses/>.
######################################################################

from sage.structure.parent import Parent
from sage.structure.element import Element
from sage.categories.all import SetsWithPartialMaps
from sage.structure.unique_representation import UniqueRepresentation
from sage.misc.cachefunc import cached_method


class SimplicialCohomologyClass(Element):
def __init__(self, parent, values):
super().__init__(parent)

self._values = values

def _repr_(self):
return repr(self._values)

def __call__(self, homology):
r"""
Evaluate this class at an element of homology.

EXAMPLES::

sage: from flatsurf import translation_surfaces, SimplicialCohomology
sage: T = translation_surfaces.torus((1, 0), (0, 1)).delaunay_triangulation()
sage: T.set_immutable()
sage: H = SimplicialCohomology(T)

sage: γ = H.homology().gens()[0]
sage: f = H({γ: 1.337})
sage: f(γ)
1.33700000000000

"""
return sum(
self._values.get(gen, 0) * homology.coefficient(gen)
for gen in self.parent().homology().gens()
)

def _add_(self, other):
r"""
Return the pointwise sum of two homology classes.

EXAMPLES::

sage: from flatsurf import translation_surfaces, SimplicialCohomology
sage: T = translation_surfaces.torus((1, 0), (0, 1)).delaunay_triangulation()
sage: T.set_immutable()
sage: H = SimplicialCohomology(T)

sage: γ = H.homology().gens()[0]
sage: f = H({γ: 1.337})
sage: (f + f)(γ) == 2*f(γ)
True

"""
values = {}
for gen in self.parent().homology().gens():
value = self(gen) + other(gen)
if value:
values[gen] = value

return self.parent()(values)


class SimplicialCohomology(UniqueRepresentation, Parent):
r"""
Absolute simplicial cohomology of the ``surface`` with ``coefficients``.

EXAMPLES::

sage: from flatsurf import translation_surfaces, SimplicialCohomology
sage: T = translation_surfaces.torus((1, 0), (0, 1)).delaunay_triangulation()
sage: T.set_immutable()

Currently, surfaces must be Delaunay triangulated to compute their homology::

sage: SimplicialCohomology(T)
H¹(Translation Surface in H_1(0) built from 2 isosceles triangles; Real Field with 53 bits of precision)

"""
Element = SimplicialCohomologyClass

@staticmethod
def __classcall__(cls, surface, coefficients=None, homology=None, category=None):
r"""
Normalize parameters used to construct cohomology.

TESTS:

Cohomology is unique and cached::

sage: from flatsurf import translation_surfaces, SimplicialCohomology
sage: T = translation_surfaces.torus((1, 0), (0, 1)).delaunay_triangulation()
sage: T.set_immutable()
sage: SimplicialCohomology(T) is SimplicialCohomology(T)
True

"""
from sage.all import RR
from flatsurf.geometry.homology import SimplicialHomology
return super().__classcall__(cls, surface, coefficients or RR, homology or SimplicialHomology(surface), category or SetsWithPartialMaps())

def __init__(self, surface, coefficients, homology, category):
# TODO: Not checking this anymore. Do we need it?
# if surface != surface.delaunay_triangulation():
# # TODO: This is a silly limitation in here.
# raise NotImplementedError("Surface must be Delaunay triangulated")

Parent.__init__(self, category=category)

self._surface = surface
self._homology = homology
self._coefficients = coefficients

def _repr_(self):
return f"H¹({self._surface}; {self._coefficients})"

def _element_constructor_(self, x):
if not x:
x = {}

if isinstance(x, dict):
assert all(k in self.homology().gens() for k in x.keys())
return self.element_class(self, x)

raise NotImplementedError

@cached_method
def homology(self):
r"""
Return the homology of the underlying space (with integer
coefficients.)

EXAMPLES::

sage: from flatsurf import translation_surfaces, SimplicialCohomology
sage: T = translation_surfaces.torus((1, 0), (0, 1)).delaunay_triangulation()
sage: T.set_immutable()
sage: H = SimplicialCohomology(T)
sage: H.homology()
H₁(Translation Surface in H_1(0) built from 2 isosceles triangles; Integer Ring)

"""
return self._homology
Loading
Loading