#4681: [with patch, needs work] General Smith normal form implementation
---------------------------------------+------------------------------------
 Reporter:  davidloeffler              |        Owner:  davidloeffler
     Type:  enhancement                |       Status:  assigned     
 Priority:  major                      |    Milestone:  sage-3.2.2   
Component:  linear algebra             |   Resolution:               
 Keywords:  matrix, smith normal form  |  
---------------------------------------+------------------------------------
Changes (by was):

  * summary:  [with patch, needs review] General Smith normal form
              implementation => [with patch, needs work]
              General Smith normal form implementation

Comment:

 I read the code, which looks fine.  The doctests pass.  This test passes:
 {{{
 for i in range(10):
    print i
    a = random_matrix(ZZ[sqrt(-1)],7)
    d,u,v = a.smith_form()
    assert u*a*v == d
    assert u.det() == 1
    assert v.det() == 1
 }}}

 This fails pretty quickly, but it's not the fault of this code:
 {{{
 K.<a>=NumberField(x^3-2)
 print "h = ", K.class_number()
 for i in range(10):
    print i
    a = random_matrix(K,3)
    d,u,v = a.smith_form()
    assert u*a*v == d
    assert u.det() == 1
    assert v.det() == 1
 ...

 Traceback (most recent call last):       d,u,v = a.smith_form()

   File "element.pyx", line 1269, in
 sage.structure.element.CommutativeRingElement.inverse_mod
 (sage/structure/element.c:10039)
 NotImplementedError
 }}}

 It's the fault of other stuff missing in Sage.

 Another thing -- in matrices over ZZ there is a smith_form function, and
 it's inputs, etc., are *not* consistent with the above.  It doesn't have a
 transformation option - instead it always gives the transformation
 matrices.  However, it also says to use the function "elementary_divisors"
 to get the diagonal entries.   I attached a patch that fixes this by
 making the sage integer matrix snf have the same interface as the generic
 one.

 The definition of smith_form between your new code and Sage's code (which
 relies on pari) is inconsistent (see below).  This needs to be somehow
 resolved.  I haven't done this yet at all.
 {{{
 sage: a = matrix(ZZ,3,[1..9]); a

 [1 2 3]
 [4 5 6]
 [7 8 9]
 sage: a.smith_form()

 ([0 0 0]
 [0 3 0]
 [0 0 1],
  [ 1 -2  1]
 [ 0 -1  1]
 [ 0  2 -1],
  [ 1  2 -1]
 [-2 -1  1]
 [ 1  0  0])
 sage: a.smith_form(transformation=False)

 [0 0 0]
 [0 3 0]
 [0 0 1]
 sage: a = matrix(ZZ[i],3,[1..9]); a

 [1 2 3]
 [4 5 6]
 [7 8 9]
 sage: a.smith_form(transformation=False)

 [ 1  0  0]
 [ 0 -3  0]
 [ 0  0  0]
 }}}

 To get this into Sage, please:
   * review my matrix_integer_dense patch
   * decide on what to do about the inconsistency between sage/pari/your
 code.

-- 
Ticket URL: <http://trac.sagemath.org/sage_trac/ticket/4681#comment:7>
Sage <http://sagemath.org/>
Sage - Open Source Mathematical Software: Building the Car Instead of 
Reinventing the Wheel
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"sage-trac" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sage-trac?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to