Skip to content

Commit

Permalink
Moving some code to make it clear what part of cusp area computation …
Browse files Browse the repository at this point in the history
…is legacy and which one is current.
  • Loading branch information
unhyperbolic committed Feb 17, 2024
1 parent 9d41cef commit df299a5
Show file tree
Hide file tree
Showing 4 changed files with 72 additions and 71 deletions.
7 changes: 4 additions & 3 deletions python/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,7 @@ def identify(self, extends_to_link=False):
ManifoldHP.verify_hyperbolicity = verify.verify_hyperbolicity

from .cusps.maximal_cusp_area_matrix import maximal_cusp_area_matrix
from .cusps.cusp_area_matrix import triangulation_dependent_cusp_area_matrix

def canonical_retriangulation(
manifold, verified=False,
Expand Down Expand Up @@ -386,15 +387,15 @@ def cusp_area_matrix(manifold, method='trigDependentTryCanonize',
raise NotImplementedError("Maximal cusp area matrix only "
"available as verified computation. "
"Pass verified = True.")
return verify.verified_maximal_cusp_area_matrix(
return verify.legacy_verified_maximal_cusp_area_matrix(
manifold, bits_prec=bits_prec)
if method in ['trigDependent', 'trigDependentTryCanonize']:
if method == 'trigDependentTryCanonize':
manifold = manifold.copy()
manifold.canonize()

return verify.triangulation_dependent_cusp_area_matrix(
manifold, verified=verified, bits_prec=bits_prec)
return triangulation_dependent_cusp_area_matrix(
manifold, bits_prec=bits_prec, verified=verified)

raise ValueError("method passed to cusp_area_matrix must be "
"'trigDependent', 'trigDependentTryCanonize', "
Expand Down
63 changes: 63 additions & 0 deletions python/cusps/cusp_area_matrix.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
from ..geometric_structure.cusp_neighborhood.cusp_cross_section import ComplexCuspCrossSection
from ..math_basics import correct_min
from ..verify.shapes import compute_hyperbolic_shapes

__all__ = ['triangulation_dependent_cusp_area_matrix']

def triangulation_dependent_cusp_area_matrix(
snappy_manifold, bits_prec, verified):
"""
Interesting case: t12521
Maximal cusp area matrix:
[ 77.5537626509970512653317518641810890989543820290380458409? 11.40953140648583915022197187043644048603871960228564151087?]
[11.40953140648583915022197187043644048603871960228564151087? 91.1461442179608339668518063027198489593908228325190920?]
This result:
[ 77.553762651? 11.409531407?]
[ 11.409531407? 5.508968850234?]
After M.canonize:
[ 62.42018359? 11.409531407?]
[ 11.409531407? 15.1140644993?]
"""
# Get shapes, as intervals if requested
shapes = compute_hyperbolic_shapes(
snappy_manifold, verified=verified, bits_prec=bits_prec)

# Compute cusp cross section, the code is agnostic about whether
# the numbers are floating-point or intervals.
# Note that the constructed cusp cross section will always be too "large"
# and we need to scale them down (since during construction the
# cross-section of each cusp will have one edge of length 1, the
# corresponding tetrahedron does not intersect in "standard" form.)
c = ComplexCuspCrossSection.fromManifoldAndShapes(snappy_manifold, shapes)

# If no areas are given, scale (up or down) all the cusps so that
# they are in standard form.
c.ensure_std_form(allow_scaling_up=True)

areas = c.cusp_areas()
RIF = areas[0].parent()

def entry(i, j):
if i > j:
i, j = j, i
result = areas[i] * areas[j]
if (i, j) in c._edge_dict:
result *= correct_min(
[ RIF(1), ComplexCuspCrossSection._exp_distance_of_edges(
c._edge_dict[(i,j)])]) ** 2
return result

return _to_matrix([[entry(i, j) for i in range(len(areas))]
for j in range(len(areas))])

def _to_matrix(m):
# delayed import to avoid cycles
from snappy.SnapPy import matrix

return matrix(m)
3 changes: 1 addition & 2 deletions python/cusps/maximal_cusp_area_matrix.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from ..geometric_structure.cusp_neighborhood.tiles_for_cusp_neighborhood import (
mcomplex_for_tiling_cusp_neighborhoods,
compute_tiles_for_cusp_neighborhood)
mcomplex_for_tiling_cusp_neighborhoods)
from ..tiling.tile import Tile

from ..sage_helper import _within_sage
Expand Down
70 changes: 4 additions & 66 deletions python/verify/maximal_cusp_area_matrix/__init__.py
Original file line number Diff line number Diff line change
@@ -1,24 +1,17 @@
from ...geometric_structure.cusp_neighborhood.cusp_cross_section import ComplexCuspCrossSection
from ...sage_helper import _within_sage, sage_method
from ...math_basics import correct_min
from ..shapes import compute_hyperbolic_shapes
from .cusp_tiling_engine import *

if _within_sage:
from sage.all import matrix

__all__ = ['verified_maximal_cusp_area_matrix',
'triangulation_dependent_cusp_area_matrix']
from .cusp_tiling_engine import *

__all__ = ['legacy_verified_maximal_cusp_area_matrix']

@sage_method
def verified_maximal_cusp_area_matrix(snappy_manifold, bits_prec=None):
def legacy_verified_maximal_cusp_area_matrix(snappy_manifold, bits_prec=None):
"""
TESTS::
sage: from snappy import Manifold
sage: M = Manifold("s776")
sage: verified_maximal_cusp_area_matrix(M) # doctest: +NUMERIC6
sage: legacy_verified_maximal_cusp_area_matrix(M) # doctest: +NUMERIC6
[28.0000000000? 7.00000000000? 7.00000000000?]
[7.00000000000? 28.000000000? 7.00000000000?]
[7.00000000000? 7.00000000000? 28.000000000?]
Expand All @@ -43,67 +36,12 @@ def verified_maximal_cusp_area_matrix(snappy_manifold, bits_prec=None):

return _to_matrix(rows)


def triangulation_dependent_cusp_area_matrix(
snappy_manifold, verified, bits_prec=None):
"""
Interesting case: t12521
Maximal cusp area matrix:
[ 77.5537626509970512653317518641810890989543820290380458409? 11.40953140648583915022197187043644048603871960228564151087?]
[11.40953140648583915022197187043644048603871960228564151087? 91.1461442179608339668518063027198489593908228325190920?]
This result:
[ 77.553762651? 11.409531407?]
[ 11.409531407? 5.508968850234?]
After M.canonize:
[ 62.42018359? 11.409531407?]
[ 11.409531407? 15.1140644993?]
"""
# Get shapes, as intervals if requested
shapes = compute_hyperbolic_shapes(
snappy_manifold, verified=verified, bits_prec=bits_prec)

# Compute cusp cross section, the code is agnostic about whether
# the numbers are floating-point or intervals.
# Note that the constructed cusp cross section will always be too "large"
# and we need to scale them down (since during construction the
# cross-section of each cusp will have one edge of length 1, the
# corresponding tetrahedron does not intersect in "standard" form.)
c = ComplexCuspCrossSection.fromManifoldAndShapes(snappy_manifold, shapes)

# If no areas are given, scale (up or down) all the cusps so that
# they are in standard form.
c.ensure_std_form(allow_scaling_up=True)

areas = c.cusp_areas()
RIF = areas[0].parent()

def entry(i, j):
if i > j:
i, j = j, i
result = areas[i] * areas[j]
if (i, j) in c._edge_dict:
result *= correct_min(
[ RIF(1), ComplexCuspCrossSection._exp_distance_of_edges(
c._edge_dict[(i,j)])]) ** 2
return result

return _to_matrix([[entry(i, j) for i in range(len(areas))]
for j in range(len(areas))])


def _to_matrix(m):
# delayed import to avoid cycles
from snappy.SnapPy import matrix

return matrix(m)


def _doctest():
import doctest
doctest.testmod()
Expand Down

0 comments on commit df299a5

Please sign in to comment.