Skip to content
This repository has been archived by the owner on Jan 30, 2023. It is now read-only.

Commit

Permalink
Fixing issue when the support is smaller than the dimension.
Browse files Browse the repository at this point in the history
  • Loading branch information
tscrim committed Jun 20, 2021
1 parent c60bc37 commit e270655
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 3 deletions.
17 changes: 16 additions & 1 deletion src/sage/categories/finite_dimensional_modules_with_basis.py
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,17 @@ def echelon_form(self, elements, row_reduced=False, order=None):
sage: x = C.basis()
sage: C.echelon_form([x[0] - x[1], 2*x[1] - 2*x[2], x[0] - x[2]])
[x[0] - x[2], x[1] - x[2]]
::
sage: M = MatrixSpace(QQ, 3, 3)
sage: A = M([[0, 0, 2], [0, 0, 0], [0, 0, 0]])
sage: M.echelon_form([A, A])
[
[0 0 1]
[0 0 0]
[0 0 0]
]
"""
if order is not None:
order = self._compute_support_order(elements, order)
Expand Down Expand Up @@ -394,7 +405,11 @@ def _vector_(self, order=None):
sage: C.an_element()._vector_()
(2, 2, 3)
"""
dense_free_module = self.parent()._dense_free_module()
if order is None:
dense_free_module = self.parent()._dense_free_module()
else:
from sage.modules.free_module import FreeModule
dense_free_module = FreeModule(self.parent().base_ring(), len(order))
# We slightly break encapsulation for speed reasons
return dense_free_module.element_class(dense_free_module,
self.dense_coefficient_list(order),
Expand Down
18 changes: 16 additions & 2 deletions src/sage/matrix/matrix_space.py
Original file line number Diff line number Diff line change
Expand Up @@ -1586,7 +1586,7 @@ def submodule(self, gens, check=True, already_echelonized=False,
If ``already_echelonized`` is ``False``, then the
generators are put in reduced echelon form using
:meth:`echelonize`, and reindexed by `0,1,...`.
:meth:`echelonize`, and reindexed by `0, 1, \ldots`.
.. WARNING::
Expand All @@ -1601,7 +1601,6 @@ def submodule(self, gens, check=True, already_echelonized=False,
The basis of the submodule uses the same index set as the
generators, and the lifting map sends `y_i` to `gens[i]`.
.. SEEALSO::
:meth:`ModulesWithBasis.ParentMethods.submodule`
Expand All @@ -1620,6 +1619,21 @@ def submodule(self, gens, check=True, already_echelonized=False,
[ 1 0] [0 1]
[-3 2], [3 1]
]
sage: A = matrix([[1, 1], [0, -1]])
sage: B = matrix([[0, 1], [0, 2]])
sage: X = M.submodule([A, B])
sage: Xp = M.submodule([A, B], order=[(0,1), (1,1), (0,0)])
sage: [X.lift(b) for b in Xp.basis()]
[
[ 1 0] [0 1]
[ 0 -3], [0 2]
]
sage: [Xp.lift(b) for b in X.basis()]
[
[2/3 1] [-1/3 0]
[ 0 0], [ 0 1]
]
"""
support_order = self._compute_support_order(gens, support_order)
if not already_echelonized:
Expand Down

0 comments on commit e270655

Please sign in to comment.