Changes between Version 4 and Version 5 of Ticket #15835
- Timestamp:
- 02/19/14 06:44:22 (8 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
Ticket #15835 – Description
v4 v5 1 1 Try the following (Mac OS X Mavericks, Sage 6.11 Master Branch): 2 2 3 {{{ 3 4 A = Matrix(IntegerModRing(2),[[1,0,2],[1,0,1]]) 4 5 A.smith_form() 6 }}} 5 7 6 8 You get the error: 9 {{{ 7 10 > TypeError Traceback (most recent call 8 11 > last) <ipython-input-6-23e95c6be019> in <module>() ----> 1 … … 16 19 > TypeError: submatrix() takes exactly 4 positional arguments (2 17 20 > given) 18 21 }}} 19 22 This error does not appear for calculations over the integers mod 3 20 23 … … 23 26 Inside the smith_form() function in matrix2.pyx: 24 27 25 We have: mm = t.submatrix(1,1)on line 12413.28 We have: `mm = t.submatrix(1,1)` on line 12413. 26 29 27 30 The sub matrix function takes five parameters (self, starting row, starting col, # sub matrix rows, # sub matrix columns). From observation, the 1,1 is the starting row/col respectively. Somehow the function is unable to determine ncols and nrows when using the integers mod 2, but after some trial and error I discovered a potential patch: 28 31 {{{ 29 32 submatrix_rows = t.rows -1 30 33 submatrix_cols = t.cols - 1 31 34 mm = t.submatrix(1,1, submatrix_rows, submatrix,cols) 32 35 }}} 33 36 The above modification gives the same answers as all the examples in the source code. I tested a couple of other things: 34 37 {{{ 35 38 Mod 3 Example: 36 39 A = Matrix(Integers(3),[[1,0,2],[1,0,1],[1,1,1]]) … … 38 41 [0 1 0] [2 0 1] [0 1 1] 39 42 [0 0 1], [1 2 0], [0 0 1] 43 }}} 40 44 (same for mod 3 in current master and modified version) 41 45 42 46 Example mod 2 (not computable in current version of Sage - checked with hand computation - good luck checking it!) - 43 47 {{{ 44 48 sage: C = Matrix(IntegerModRing(2),[[1,0,1,0],[1,1,0,0],[0,1,1,0],[1,0,0,1],[0,0,1,1],[0,1,0,1]]) 45 49 sage: C.smith_form() … … 60 64 [0 0 1 0 1 0] 61 65 [0 1 1 0 0 1] 66 }}}