Changes between Version 4 and Version 5 of Ticket #15835


Ignore:
Timestamp:
02/19/14 06:44:22 (8 years ago)
Author:
jhpalmieri
Comment:

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #15835 – Description

    v4 v5  
    11Try the following (Mac OS X Mavericks, Sage 6.11 Master Branch):
    22
     3{{{
    34A = Matrix(IntegerModRing(2),[[1,0,2],[1,0,1]])
    45A.smith_form()
     6}}}
    57
    68You get the error:
     9{{{
    710> TypeError                                 Traceback (most recent call
    811> last) <ipython-input-6-23e95c6be019> in <module>() ----> 1
     
    1619> TypeError: submatrix() takes exactly 4 positional arguments (2
    1720> given)
    18 
     21}}}
    1922This error does not appear for calculations over the integers mod 3
    2023
     
    2326Inside the smith_form() function in matrix2.pyx:
    2427
    25 We have: mm = t.submatrix(1,1) on line 12413.
     28We have: `mm = t.submatrix(1,1)` on line 12413.
    2629
    2730The 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{{{
    2932submatrix_rows = t.rows -1
    3033submatrix_cols = t.cols - 1
    3134mm = t.submatrix(1,1, submatrix_rows, submatrix,cols)
    32 
     35}}}
    3336The above modification gives the same answers as all the examples in the source code. I tested a couple of other things:
    34 
     37{{{
    3538Mod 3 Example:
    3639A = Matrix(Integers(3),[[1,0,2],[1,0,1],[1,1,1]])
     
    3841[0 1 0]  [2 0 1]  [0 1 1]
    3942[0 0 1], [1 2 0], [0 0 1]
     43}}}
    4044(same for mod 3 in current master and modified version)
    4145
    4246Example mod 2 (not computable in current version of Sage - checked with hand computation - good luck checking it!) -
    43 
     47{{{
    4448sage: 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]])
    4549sage: C.smith_form()
     
    6064[0 0 1 0 1 0]
    6165[0 1 1 0 0 1]
     66}}}