On Thu, Dec 4, 2014 at 2:13 AM, Vincent Delecroix <20100.delecr...@gmail.com> wrote: > 2014-12-04 9:32 UTC+01:00, David Roe <roed.m...@gmail.com>: >>> abs(matrix) is currently returning the determinant (and this goes back >>> to the early implementation in 2006!). If anybody contests the fact >>> that it should return the matrix whose entries are the absolute value >>> of the initial matrix, please tell me. >> >> I don't think that it should be the matrix consisting of absolute >> values of entries, since that only works for matrices over a ring with >> an absolute value. Using >> it as a determinant is consistent with standard notation, though I >> agree that we don't usually say absolute value in this context. > > abs(m) is not a standard notation for the determinant... (though |m| > is as Simon mentioned). My conclusion is that we should just forbid > __abs__ for matrices. > >> In general, I'm opposed to matrix operations which do the same thing >> to each entry, unless we're very explicit about it. I would prefer a >> method 'elementwise()' which takes in a method (either the global >> function abs or the string 'abs') and applies it to each entry. > > All right, I can do that in the ticket. It is perfectly fine to send a > function to .elementwise() because it can be optimized for abs as it > is the one from __builtin__. > > def elementwise(self, f): > if f is abs: > # try to find optimized routine > try: > self._elementwise_abs() > except AttributeError: > pass > > # default behavior > return self.parent()([[f(x) for x in row] for row in self.rows()]) > > It would be nice to guarantee uniqueness of other functions like > cos,sin,exp, ... to get optimized subroutines for matrices over > various real and complex numbers.
Sounds good to me. David > > Vincent > > -- > You received this message because you are subscribed to the Google Groups > "sage-devel" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to sage-devel+unsubscr...@googlegroups.com. > To post to this group, send email to sage-devel@googlegroups.com. > Visit this group at http://groups.google.com/group/sage-devel. > For more options, visit https://groups.google.com/d/optout. -- You received this message because you are subscribed to the Google Groups "sage-devel" group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-devel+unsubscr...@googlegroups.com. To post to this group, send email to sage-devel@googlegroups.com. Visit this group at http://groups.google.com/group/sage-devel. For more options, visit https://groups.google.com/d/optout.