You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
PMVector/PMMatrix >> #dot: does not compute a dot product. #29
Yes, for that reason I think swap is a bad idea. Moreover, #* is a natural message for dot product because that is what we would expect, from the mathematical notation, to be polymorphic with scalars. Still, having #dot: not compute the dot product is probably not ideal under any circumstances. My thought would be to leave the default multiplication #* as the dot product, make #dot: just delegate to #*, and add a new method for elementwise multiplication.
We can try to swap because I don't silent breaks ;-) we have also a lot of tests to cover these kind of changes. Before that we can have a look to dot: implementors if they are any others.
I don't think we should swap. I didn't fully think it through before I made that suggestion. Dot product IS the default multiplication for matrices and vectors, so it makes sense to leave #* as the dot product. I think all we need to do is rename #dot: to something like #elementwiseMultiply: or maybe some shorter binary message.
Indeed, dot: is misleading and should be renamed...
But I never saw * used for dot product elsewhere. Usually it can be array product (element-wise), or matrix product (matrix*vector), or external product in a space vector (scalar*vector).
If * is both dot product and scalar product, then (u*v)*w ~= u*(v*w)
I had a quick look at wikipedia and this binary operation is referred to as the Hadamard product (or Schur product/entrywise product) and the symbol used to refer to it is a circle with a dot inside it. Could we call the message circleDot instead of dot?
Activity
olekscode commentedon May 18, 2017
I think I could swap them.
But wouldn't it silently break all the code that has ever used this multiplication?
emdonahue commentedon May 18, 2017
Yes, for that reason I think swap is a bad idea. Moreover, #* is a natural message for dot product because that is what we would expect, from the mathematical notation, to be polymorphic with scalars. Still, having #dot: not compute the dot product is probably not ideal under any circumstances. My thought would be to leave the default multiplication #* as the dot product, make #dot: just delegate to #*, and add a new method for elementwise multiplication.
SergeStinckwich commentedon May 18, 2017
We can try to swap because I don't silent breaks ;-) we have also a lot of tests to cover these kind of changes. Before that we can have a look to dot: implementors if they are any others.
emdonahue commentedon May 18, 2017
I don't think we should swap. I didn't fully think it through before I made that suggestion. Dot product IS the default multiplication for matrices and vectors, so it makes sense to leave #* as the dot product. I think all we need to do is rename #dot: to something like #elementwiseMultiply: or maybe some shorter binary message.
nicolas-cellier-aka-nice commentedon Aug 2, 2017
Indeed, dot: is misleading and should be renamed...
But I never saw
*used for dot product elsewhere. Usually it can be array product (element-wise), or matrix product (matrix*vector), or external product in a space vector (scalar*vector).If
*is both dot product and scalar product, then(u*v)*w ~= u*(v*w)hemalvarambhia commentedon Apr 24, 2019
I had a quick look at wikipedia and this binary operation is referred to as the Hadamard product (or Schur product/entrywise product) and the symbol used to refer to it is a circle with a dot inside it. Could we call the message
circleDotinstead ofdot?SergeStinckwich commentedon Apr 24, 2019
yes better to be more precise. Maybe
hadamardProduct?hemalvarambhia commentedon Apr 30, 2019
I think we can introduce
hadamardProductas you say and deprecate thedotmessage, after your mentioning your concern about silent breaks.