Skip to content

Commit

Permalink
Tiling in python: splitting off hyperboloid dict.
Browse files Browse the repository at this point in the history
  • Loading branch information
unhyperbolic committed Feb 19, 2024
1 parent abfae1e commit f6fd967
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 37 deletions.
39 changes: 39 additions & 0 deletions python/tiling/hyperboloid_dict.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
from .real_hash_dict import RealHashDict
from ..hyperboloid import r13_dot
from ..exceptions import InsufficientPrecisionError # type: ignore

_epsilon_inverse = 1024

def get_hyperboloid_dict(min_inner_product, verified):
return RealHashDict(
_equality_predicate(min_inner_product),
_hash_function(min_inner_product.parent()),
_epsilon_inverse,
verified)

def _equality_predicate(min_inner_product):
def result(point_0, point_1):
inner_product = r13_dot(point_0, point_1)
if inner_product > min_inner_product:
return True
if inner_product < min_inner_product:
return False

raise InsufficientPrecisionError(
"Could neither verify that the two given tiles are "
"the same nor that they are distinct. "
"Inner product is: %r, cut-off is: %s. " % (
inner_product, min_inner_product))

return result

def _hash_function(RF):
weights = [ RF(1.2003), RF(0.94553), RF(1.431112), RF(1.2342) ]

def result(point):
return (point[0] * weights[0] +
point[1] * weights[1] +
point[2] * weights[2] +
point[3] * weights[3])

return result
40 changes: 3 additions & 37 deletions python/tiling/lifted_tetrahedron_set.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
from .lifted_tetrahedron import LiftedTetrahedron
from .real_hash_dict import RealHashDict
from .canonical_key_dict import CanonicalKeyDict
from .hyperboloid_dict import get_hyperboloid_dict

from ..snap.t3mlite import Mcomplex # type: ignore
from ..hyperboloid import r13_dot, o13_inverse
from ..exceptions import InsufficientPrecisionError # type: ignore
from ..hyperboloid import o13_inverse

class ProductSet:
"""
Expand Down Expand Up @@ -75,43 +73,11 @@ def get_lifted_tetrahedron_set(base_point,
"""

d = RealHashDict(
_equality_predicate(min_inner_product),
_hash_function(base_point[0].parent()),
_epsilon_inverse,
verified)
d = get_hyperboloid_dict(min_inner_product, verified)

if canonical_keys_function:
d = CanonicalKeyDict(d, canonical_keys_function)

return LiftedTetrahedronSet(d, base_point, act_on_base_point_by_inverse)

def _equality_predicate(min_inner_product):
def result(point_0, point_1):
inner_product = r13_dot(point_0, point_1)
if inner_product > min_inner_product:
return True
if inner_product < min_inner_product:
return False

raise InsufficientPrecisionError(
"Could neither verify that the two given tiles are "
"the same nor that they are distinct. "
"Inner product is: %r, cut-off is: %s. " % (
inner_product, min_inner_product))

return result

def _hash_function(RF):
weights = [ RF(1.2003), RF(0.94553), RF(1.431112), RF(1.2342) ]

def result(point):
return (point[0] * weights[0] +
point[1] * weights[1] +
point[2] * weights[2] +
point[3] * weights[3])

return result

_epsilon_inverse = 1024

0 comments on commit f6fd967

Please sign in to comment.