On Jun 28, 2007, at 16:30 , David Roe wrote:
> Sorry I didn't reply earlier. Not a problem. > Implementing an is_symmetric function for matrices sounds like a > good idea. > But I think it should go in the base class: something like That was my feeling as well. > def is_symmetric(self): > if self.ncols != self.nrows: > return False > cdef int i, j: > for i from 1 <= i < self.nrows: > for j from 0 <= j < i: > if self[i][j] != self[j][i]: > return False > return True You peeked :-} > One can override this in a subclass if desired: if there's some > special, > faster way to test for symmetry. I can't think of a better method in > general than this. Just checking, in case I overlooked something. Thanks for the confirmation. I'm testing it now. Anyone got a pile of symmetric matrices to check? Justin -- Justin C. Walker, Curmudgeon-At-Large Institute for the Absorption of Federal Funds -------- Some people have a mental horizon of radius zero, and call it their point of view. -- David Hilbert -------- --~--~---------~--~----~------------~-------~--~----~ 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://sage.scipy.org/sage/ and http://modular.math.washington.edu/sage/ -~----------~----~----~----~------~----~------~--~---