summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTravis Scrimshaw <tscrimsh at umn.edu>2016-01-21 10:54:21 -0600
committerTravis Scrimshaw <tscrimsh at umn.edu>2016-01-21 10:54:21 -0600
commit29f72539754e8efba97deb07a93d735af559a552 (patch)
tree1af394ed9f3b12b3eb84508c0cb308c5429cb663
parentMerge branch 'develop' into public/groups/cythonize_matrix_group_element-19870 (diff)
Special case for dense matrices over ZZ and making sure the inverse is in the base ring.
-rw-r--r--src/sage/groups/matrix_gps/group_element.pyx19
1 files changed, 18 insertions, 1 deletions
diff --git a/src/sage/groups/matrix_gps/group_element.pyx b/src/sage/groups/matrix_gps/group_element.pyx
index 3ec3195..09127ba 100644
--- a/src/sage/groups/matrix_gps/group_element.pyx
+++ b/src/sage/groups/matrix_gps/group_element.pyx
@@ -76,6 +76,7 @@ from sage.matrix.matrix import is_Matrix
from sage.structure.factorization import Factorization
from sage.misc.cachefunc import cached_method
from sage.structure.element import have_same_parent
+from sage.rings.all import ZZ
cpdef is_MatrixGroupElement(x):
@@ -345,9 +346,25 @@ cdef class MatrixGroupElement_generic(MultiplicativeGroupElement):
True
sage: ~g * g == W.one()
True
+
+ sage: W = CoxeterGroup(['B',3])
+ sage: W.base_ring()
+ Universal Cyclotomic Field
+ sage: g = W.an_element()
+ sage: ~g
+ [ -1 1 0]
+ [ -1 0 E(8) - E(8)^3]
+ [-E(8) + E(8)^3 0 1]
"""
cdef Parent parent = self.parent()
- cdef Matrix M = ~self._matrix
+ cdef Matrix M = self._matrix
+ # We have a special method for dense matrices over ZZ
+ if M.base_ring() is ZZ and M.is_dense():
+ M = M._invert_unit()
+ else:
+ M = ~M
+ if M.base_ring() is not parent.base_ring():
+ M = M.change_ring(parent.base_ring())