Commit a2aab87
Release Manager
sagemathgh-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 sagemath#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 sagemath#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⎠
```
### 📝 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.
### ⌛ Dependencies
<!-- List all open PRs that this PR logically depends on. For example,
-->
<!-- - sagemath#12345: short description why this is a dependency -->
<!-- - sagemath#34567: ... -->
URL: sagemath#37606
Reported by: Matthias Köppe
Reviewer(s): David Coudert, Matthias Köppe
2 files changed
+140
-19
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1796 | 1796 | | |
1797 | 1797 | | |
1798 | 1798 | | |
1799 | | - | |
| 1799 | + | |
| 1800 | + | |
| 1801 | + | |
1800 | 1802 | | |
1801 | 1803 | | |
1802 | 1804 | | |
| |||
1846 | 1848 | | |
1847 | 1849 | | |
1848 | 1850 | | |
| 1851 | + | |
| 1852 | + | |
| 1853 | + | |
| 1854 | + | |
| 1855 | + | |
| 1856 | + | |
| 1857 | + | |
| 1858 | + | |
| 1859 | + | |
| 1860 | + | |
1849 | 1861 | | |
1850 | 1862 | | |
1851 | 1863 | | |
| |||
1921 | 1933 | | |
1922 | 1934 | | |
1923 | 1935 | | |
| 1936 | + | |
| 1937 | + | |
| 1938 | + | |
| 1939 | + | |
| 1940 | + | |
| 1941 | + | |
| 1942 | + | |
| 1943 | + | |
| 1944 | + | |
| 1945 | + | |
| 1946 | + | |
| 1947 | + | |
| 1948 | + | |
| 1949 | + | |
| 1950 | + | |
1924 | 1951 | | |
1925 | 1952 | | |
1926 | 1953 | | |
| |||
1958 | 1985 | | |
1959 | 1986 | | |
1960 | 1987 | | |
| 1988 | + | |
| 1989 | + | |
| 1990 | + | |
| 1991 | + | |
| 1992 | + | |
| 1993 | + | |
| 1994 | + | |
| 1995 | + | |
| 1996 | + | |
| 1997 | + | |
| 1998 | + | |
| 1999 | + | |
| 2000 | + | |
| 2001 | + | |
| 2002 | + | |
| 2003 | + | |
| 2004 | + | |
| 2005 | + | |
| 2006 | + | |
| 2007 | + | |
| 2008 | + | |
| 2009 | + | |
| 2010 | + | |
| 2011 | + | |
| 2012 | + | |
| 2013 | + | |
1961 | 2014 | | |
1962 | 2015 | | |
1963 | 2016 | | |
| |||
2063 | 2116 | | |
2064 | 2117 | | |
2065 | 2118 | | |
| 2119 | + | |
| 2120 | + | |
| 2121 | + | |
| 2122 | + | |
| 2123 | + | |
| 2124 | + | |
2066 | 2125 | | |
2067 | 2126 | | |
2068 | 2127 | | |
| |||
2075 | 2134 | | |
2076 | 2135 | | |
2077 | 2136 | | |
| 2137 | + | |
| 2138 | + | |
| 2139 | + | |
| 2140 | + | |
| 2141 | + | |
| 2142 | + | |
2078 | 2143 | | |
2079 | 2144 | | |
| 2145 | + | |
2080 | 2146 | | |
| 2147 | + | |
2081 | 2148 | | |
2082 | 2149 | | |
2083 | | - | |
| 2150 | + | |
2084 | 2151 | | |
2085 | 2152 | | |
2086 | | - | |
2087 | | - | |
| 2153 | + | |
| 2154 | + | |
| 2155 | + | |
| 2156 | + | |
| 2157 | + | |
| 2158 | + | |
| 2159 | + | |
| 2160 | + | |
| 2161 | + | |
| 2162 | + | |
| 2163 | + | |
2088 | 2164 | | |
2089 | 2165 | | |
2090 | 2166 | | |
2091 | | - | |
| 2167 | + | |
| 2168 | + | |
| 2169 | + | |
| 2170 | + | |
2092 | 2171 | | |
2093 | 2172 | | |
2094 | 2173 | | |
2095 | 2174 | | |
2096 | | - | |
| 2175 | + | |
2097 | 2176 | | |
2098 | 2177 | | |
2099 | | - | |
| 2178 | + | |
| 2179 | + | |
| 2180 | + | |
| 2181 | + | |
| 2182 | + | |
2100 | 2183 | | |
2101 | | - | |
2102 | | - | |
2103 | | - | |
2104 | | - | |
2105 | | - | |
| 2184 | + | |
| 2185 | + | |
| 2186 | + | |
| 2187 | + | |
| 2188 | + | |
| 2189 | + | |
| 2190 | + | |
| 2191 | + | |
| 2192 | + | |
| 2193 | + | |
| 2194 | + | |
| 2195 | + | |
| 2196 | + | |
| 2197 | + | |
| 2198 | + | |
| 2199 | + | |
| 2200 | + | |
2106 | 2201 | | |
2107 | | - | |
2108 | | - | |
2109 | | - | |
2110 | | - | |
| 2202 | + | |
| 2203 | + | |
| 2204 | + | |
| 2205 | + | |
| 2206 | + | |
| 2207 | + | |
| 2208 | + | |
| 2209 | + | |
| 2210 | + | |
| 2211 | + | |
| 2212 | + | |
| 2213 | + | |
2111 | 2214 | | |
2112 | 2215 | | |
2113 | 2216 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
346 | 346 | | |
347 | 347 | | |
348 | 348 | | |
349 | | - | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
350 | 352 | | |
351 | 353 | | |
352 | 354 | | |
| |||
384 | 386 | | |
385 | 387 | | |
386 | 388 | | |
| 389 | + | |
| 390 | + | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
387 | 399 | | |
388 | 400 | | |
389 | 401 | | |
| |||
416 | 428 | | |
417 | 429 | | |
418 | 430 | | |
419 | | - | |
| 431 | + | |
| 432 | + | |
| 433 | + | |
420 | 434 | | |
421 | 435 | | |
422 | 436 | | |
423 | 437 | | |
424 | 438 | | |
425 | | - | |
| 439 | + | |
| 440 | + | |
| 441 | + | |
| 442 | + | |
| 443 | + | |
426 | 444 | | |
427 | 445 | | |
428 | 446 | | |
| |||
0 commit comments