Commit
2 years ago
gh-37606: Border matrix <!-- ^ Please provide a concise and informative title. --> <!-- ^ Don't put issue numbers in the title, do this in the PR description below. --> <!-- ^ For example, instead of "Fixes #12345" use "Introduce new method to calculate 1 + 2". --> <!-- v Describe your changes below in detail. --> <!-- v Why is this change required? What problem does it solve? --> <!-- v If this PR resolves an open issue, please link to it here. For example, "Fixes #12345". --> Plain TeX users may remember `\bordermatrix`. Here we implement this as options of the `Matrix` class's `str` method. ``` sage: M = matrix([[1,2,3], [4,5,6], [7,8,9]]) sage: M.subdivide(None, 2) sage: print(M.str(unicode=True, ....: top_border=['ab', 'cde', 'f'], ....: bottom_border=['*', '', ''], ....: left_border=[1, 10, 100], ....: right_border=['', ' <', ''])) ab cde f 1⎛ 1 2│ 3⎞ 10⎜ 4 5│ 6⎟ < 100⎝ 7 8│ 9⎠ * ``` Follow-up PR: As the guiding application for this feature, we equip finite-dimensional modules with basis with methods `_repr_matrix`, `_ascii_art_matrix`, `_unicode_art_matrix` that can be used as in this example: ``` sage: M = matrix(ZZ, [[1, 0, 0], [0, 1, 0]], ....: column_keys=['a', 'b', 'c'], ....: row_keys=['v', 'w']); M Generic morphism: From: Free module generated by {'a', 'b', 'c'} over Integer Ring To: Free module generated by {'v', 'w'} over Integer Ring sage: M._unicode_art_ = M._unicode_art_matrix sage: unicode_art(M) # indirect doctest a b c v⎛1 0 0⎞ w⎝0 1 0⎠ ``` ### :memo: Checklist <!-- Put an `x` in all the boxes that apply. --> - [x] The title is concise and informative. - [x] The description explains in detail what this PR is about. - [ ] I have linked a relevant issue or discussion. - [ ] I have created tests covering the changes. - [ ] I have updated the documentation accordingly. ### :hourglass: Dependencies <!-- List all open PRs that this PR logically depends on. For example, --> <!-- - #12345: short description why this is a dependency --> <!-- - #34567: ... --> URL: https://github.com/sagemath/sage/pull/37606 Reported by: Matthias Köppe Reviewer(s): David Coudert, Matthias Köppe
Author
Release Manager
Loading