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.  Of course, the product of two arrays is the 
element-wise product.  See http://www.scipy.org/NumPy_for_Matlab_Users

"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."

That said, the matrix class is not very well supported (there are 
movements on the numpy mailing list to correct this), so we use the 
array class and the "dot" method in Sage.

Jason


--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to