On Sunday, March 9, 2014 7:20:50 PM UTC, Jeroen Demeyer wrote:
>
> I think the following piece should be made more clear, I don't 
> understand what you're trying to say here: 
>
> The problem is that the presence of two different duck-types for numeric 
> data -- one where * means matrix multiply, and one where * means 
> elementwise multiplication -- make it impossible to write generic 
> functions that can operate on arbitrary data. 
>

Indeed, it's clear from everyone's responses here that I at least need to 
add a new section talking about these things explicitly, and also about why 
elementwise-* is actually used so often in practice in numeric computation 
(as opposed dto symbolic comptuation), and why np.matrix is so loathed. (It 
really is though, I didn't just make that up :-) I doubt you can find a 
single developer of any numpy-using package who has anything good to say 
about it.) I'll try to get to write such a section over the next few hours; 
at least it might make a better basis for discussion.

In brief, the issue is that elementwise-* is a fine convention and you can 
use it to write useful code, and matrix-multiply-* is a fine convention and 
you can use it to write useful code, but if you then try to glue those two 
pieces of code together into a larger system you will quickly find yourself 
in hell as you have to cast objects back and forth at every function call. 
Or similarly, if you try to write a function that works regardless of 
whether it receives an elementwise-*-object or a matrix-multiply-*-object, 
then this is also very painful (suddenly you need lots of type-checking and 
if statements scattered around every single function you write, it's 
horrible and no-one is willing to do it).

This doesn't get into the reasons why numpy goes with the elementwise-* 
convention, but it's why it seems important to have *some* convention.

(Some of the reasons for why numpy goes with elementwise-* are here: 
https://github.com/njsmith/numpy/blob/matmul-pep/doc/neps/return-of-revenge-of-matmul-pep.rst#choice-of-operation
 
; the other important reason that that section doesn't talk about as much 
as it could is that numpy has n-dimensional arrays, while matrix 
multiplication is only really natural for 2d arrays.)

-n

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

Reply via email to