On Saturday 07 February 2009, Florent Hivert wrote: > Dear All, > > I'm preparing a patch which allows one to use generic_power (computing > a^n) for monoids and even semi groups. So I had to change the handling of > particular cases (a=0 or n=0). After this change all tests passes except > for one in matrix_mod2_dense: > ********************************************************************** > File > "/usr/local/sage/devel/sage-combinat/sage/matrix/matrix_mod2_dense.pyx", > line 755: sage: A^(-1) > Expected: > Traceback (most recent call last): > ... > ZeroDivisionError > Got: > [] > ********************************************************************** > Here is the corresponding code > TESTS: > sage: A = matrix(GF(2),0,0) > sage: A^(-1) > Traceback (most recent call last): > ... > ZeroDivisionError > > Note that with my patch it answers without touching the matrix code the > empty matrix "[]". Even if the set of 0x0 matrix seems to be a strange ring > (I think a ring has to contains at least two *different* elements 0 and 1), > it is a perfectly acceptable multiplicative group. From this point of view, > the empty matrix seems to be the correct answer. So I'm tempted to replace > this test by testing the 1x1 zero matrix. > > So my question is the following: is there a specific reason why this test > has been written ?
I wrote that doctest, because that behaviour is consistent with other matrices. sage: A = random_matrix(GF(127),0,0) sage: A^(-1) Traceback (most recent call last) ... ZeroDivisionError: sage: A = random_matrix(QQ,0,0) sage: A^(-1) --------------------------------------------------------------------------- Traceback (most recent call last) ... ZeroDivisionError: I have no strong feelings about how things should behave as long as it is consistent. I suggest, to add doctests to catch these for the various matrix types while you're changing the behaviour. Martin -- name: Martin Albrecht _pgp: http://pgp.mit.edu:11371/pks/lookup?op=get&search=0x8EF0DC99 _otr: 47F43D1A 5D68C36F 468BAEBA 640E8856 D7951CCF _www: http://www.informatik.uni-bremen.de/~malb _jab: [email protected] --~--~---------~--~----~------------~-------~--~----~ 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-devel URLs: http://www.sagemath.org -~----------~----~----~----~------~----~------~--~---
