Skip to content

Commit 6ed0045

Browse files
author
Matthias Koeppe
committed
MatrixArgs.get_type: Recognize elements of the base ring as MA_ENTRIES_SCALAR
1 parent 8e46414 commit 6ed0045

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

src/sage/matrix/args.pyx

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1500,6 +1500,21 @@ cdef class MatrixArgs:
15001500
Traceback (most recent call last):
15011501
...
15021502
NameError: name 'a' is not defined
1503+
1504+
Check that :issue:`38221` is fixed::
1505+
1506+
sage: # needs sage.groups
1507+
sage: G = CyclicPermutationGroup(7)
1508+
sage: R = GF(2)
1509+
sage: A = G.algebra(R)
1510+
sage: matrix(A, 3, 3, A.zero())
1511+
[0 0 0]
1512+
[0 0 0]
1513+
[0 0 0]
1514+
sage: matrix(A, 3, 3, A.one())
1515+
[() 0 0]
1516+
[ 0 () 0]
1517+
[ 0 0 ()]
15031518
"""
15041519
# Check basic Python types. This is very fast, so it doesn't
15051520
# hurt to do these first.
@@ -1524,6 +1539,8 @@ cdef class MatrixArgs:
15241539
cdef bint is_elt = isinstance(self.entries, Element)
15251540
if is_elt and isinstance(self.entries, Matrix):
15261541
return MA_ENTRIES_MATRIX
1542+
if is_elt and self.base is not None and self.entries.parent() == self.base:
1543+
return MA_ENTRIES_SCALAR
15271544
t = type(self.entries)
15281545
try:
15291546
f = t._matrix_

0 commit comments

Comments
 (0)