At the moment, if I create an integer matrix, there are methods "elementary_divisors" and "smith_form". Example:
sage: m = matrix(ZZ,3,3,xrange(9)); m.elementary_divisors() [1, 3, 0] sage: m.smith_form() ([0 0 0] [0 3 0] [0 0 1], [-1 2 -1] [ 0 -1 1] [ 0 1 0], [ 1 4 -1] [-2 -3 1] [ 1 0 0]) According to the docstring for smith_form, the method "returns matrices S, U, and V such that S = U*self*V, and S is in Smith normal form. Thus S is diagonal with diagonal entries the ordered elementary divisors of S. WARNING: The elementary_divisors function, which returns the diagonal entries of S, is VASTLY faster than this function." But as you can see from the example above, the diagonal entries of S are ordered differently from the elementary divisors. So there's an inconsistency there. Sage takes its conventions for the elementary_divisors function from linbox, although at present calculation via linbox is disabled, and the code is actually taking Pari's output and reversing the order. I suggest we should change one or the other to make it consistent. Does anyone have any strong preferences for which? I suggest that we keep elementary_divisors as it is and change smith_form. This breaks consistency with Pari, but makes us consistent with every other Smith form implementation I've seen (including those in Gap, Kash, Magma and Maple). Also, changing smith_form rather than elementary_divisors would probably have fewer knock-on effects for existing Sage code. This came up during the review process for patch #4681, which adds Smith form over more general base rings. I'm quite keen to get this patch in, and the reviewer raised this consistency issue, so if nobody objects violently in the next day or two I'll change the existing Smith form over ZZ. Regards, David --~--~---------~--~----~------------~-------~--~----~ To post to this group, send email to sage-devel@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/sage-devel URLs: http://www.sagemath.org -~----------~----~----~----~------~----~------~--~---