On Mon, Jun 15, 2009 at 8:39 PM, Jason Grout<jason-s...@creativetrax.com> wrote: > > William Stein wrote: >> On Mon, Jun 15, 2009 at 7:34 PM, Jason Grout<jason-s...@creativetrax.com> >> wrote: >>> Bill Hart wrote: >>>> Can I ask what applications this "Hadamard product" has? >> >> I've never used it, but I guess it must be really really important in >> numerical computation, since most shockingly it is the *default* for >> A*B in numpy!! >> >> sage: import numpy >> sage: a = numpy.array([[1,2],[3,4]]) >> sage: a*a >> array([[1, 4], >> [9, 16]], dtype=object) > > > It's just default because you aren't using the numpy "matrix" class, > just the "array" class.
I know. > "In NumPy the basic type is a multidimensional array. Operations on > these arrays in all dimensionalities including 2D are elementwise > operations. However, there is a special matrix type for doing linear > algebra, which is just a subclass of the array class. Operations on > matrix-class arrays are linear algebra operations." This is orthogonal to the above, but maybe I took too many courses on object oriented design back when I was a CS undergrad in the early 90's, but subclasses in an object oriented-system should satisfy an "isa" relationship. Subclassing and changing the semantics of * violates that. Here, "isa" would mean that "any matrix is an array with extra structure". Of course there is an exception to every rule, and consistency is the hobgoblin of little minds, etc. :-) -- William --~--~---------~--~----~------------~-------~--~----~ To post to this group, send email to sage-devel@googlegroups.com To unsubscribe from this group, send email to sage-devel-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-devel URLs: http://www.sagemath.org -~----------~----~----~----~------~----~------~--~---