Skip to content

Commit

Permalink
python/matrix.py: adding make_identity_matrix.
Browse files Browse the repository at this point in the history
  • Loading branch information
unhyperbolic committed May 6, 2024
1 parent de23286 commit b63f23d
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 4 deletions.
3 changes: 2 additions & 1 deletion python/drilling/debug.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from ..snap.t3mlite import simplex
from ..matrix import make_identity_matrix
from ..hyperboloid import *


Expand Down Expand Up @@ -82,7 +83,7 @@ def check_points_consistency(m):

def check_edge_consistency(m):
RF = m.Tetrahedra[0].O13_matrices[simplex.F0].base_ring()
id_matrix = matrix.identity(ring=RF, n=4)
id_matrix = make_identity_matrix(ring=RF, n=4)

for e in m.Edges:
t = id_matrix
Expand Down
6 changes: 3 additions & 3 deletions python/drilling/moves.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

from ..geometric_structure import add_r13_planes_to_tetrahedron
from ..snap.t3mlite import simplex, Perm4, Tetrahedron, Corner # type: ignore
from ..matrix import matrix # type: ignore
from ..matrix import make_identity_matrix # type: ignore
from ..exceptions import InsufficientPrecisionError # type: ignore

from typing import Sequence, Optional, List
Expand Down Expand Up @@ -72,7 +72,7 @@ def one_four_move(given_pieces : Sequence[GeodesicPiece],
neighbors : dict[int, Tetrahedron] = dict(tet.Neighbor.items())
gluings : dict[int, Perm4] = dict(tet.Gluing.items())

id_matrix = matrix.identity(ring=RF, n=4)
id_matrix = make_identity_matrix(ring=RF, n=4)

for f0, new_tet0 in new_tets.items():
new_tet0.geodesic_pieces = []
Expand Down Expand Up @@ -209,7 +209,7 @@ def two_three_move(given_pieces : Sequence[GeodesicPiece],
for old_tip in old_tips ]

RF = old_tets[0].O13_matrices[simplex.F0].base_ring()
id_matrix = matrix.identity(ring=RF, n=4)
id_matrix = make_identity_matrix(ring=RF, n=4)

# Embeddings to map both tetrahedra into the same coordinate
# system
Expand Down
8 changes: 8 additions & 0 deletions python/matrix.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ def snappy_make_vector(entries, *, ring=None):
def snappy_make_matrix(entries, *, ring=None):
return SimpleMatrix(entries, ring)

def snappy_make_identity(*, n, ring):
return SimpleMatrix.identity(ring, n)

if _within_sage:
from sage.modules.free_module_element import vector as _sage_vector
from sage.matrix.constructor import matrix as _sage_matrix
Expand All @@ -25,11 +28,16 @@ def sage_make_matrix(entries, *, ring=None):
else:
return _sage_matrix(ring, entries)

def sage_make_identity_matrix(*, n, ring):
return _sage_matrix.identity(ring, n)

make_vector = sage_make_vector
make_matrix = sage_make_matrix
make_identity_matrix = sage_make_identity_matrix
else:
make_vector = snappy_make_vector
make_matrix = snappy_make_matrix
make_identity_matrix = snappy_make_identity_matrix

class SimpleVector(number.SupportsMultiplicationByNumber):
def __init__(self, entries, ring=None):
Expand Down

0 comments on commit b63f23d

Please sign in to comment.