Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 61 additions & 0 deletions src/sage/matrix/matrix_gf2e_dense.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -1129,6 +1129,67 @@ cdef class Matrix_gf2e_dense(matrix_dense.Matrix_dense):
return
mzed_col_swap(self._entries, col1, col2)

def transpose(self):
"""
Return the transpose of ``self``.

EXAMPLES:

We create a matrix, compute its transpose, and note that
the original matrix is not changed::

sage: K.<a> = GF(4)
sage: M = matrix(K, [[0, a, 0], [0, a+1, 1], [0, 0, 0]])
sage: M
[ 0 a 0]
[ 0 a + 1 1]
[ 0 0 0]
sage: N = M.transpose()
sage: N
[ 0 0 0]
[ a a + 1 0]
[ 0 1 0]
sage: M
[ 0 a 0]
[ 0 a + 1 1]
[ 0 0 0]

``.T`` is a convenient shortcut for the transpose::

sage: M.T
[ 0 0 0]
[ a a + 1 0]
[ 0 1 0]

::

sage: M.subdivide(None, 1)
sage: M
[ 0| a 0]
[ 0|a + 1 1]
[ 0| 0 0]
sage: M.transpose()
[ 0 0 0]
[-----------------]
[ a a + 1 0]
[ 0 1 0]
"""
# temporary until mzed_transpose from M4RIE makes its way into Sage
cdef Py_ssize_t nrows = self._nrows
cdef Py_ssize_t ncols = self._ncols

cdef Matrix_gf2e_dense A = self.new_matrix(ncols=nrows,
nrows=ncols)

cdef Py_ssize_t i, j
for i from 0 <= i < ncols:
for j from 0 <= j < nrows:
mzed_write_elem(A._entries, i, j, mzed_read_elem(self._entries, j, i))
if self._subdivisions is not None:
row_divs, col_divs = self.subdivisions()
A.subdivide(col_divs, row_divs)
return A

def augment(self, right):
"""
Augments ``self`` with ``right``.
Expand Down
Loading