Skip to content

PMVector/PMMatrix >> #dot: does not compute a dot product. #29

Closed

Description

@emdonahue

Currently, #* computes the dot product:
#(1 2) asPMVector * #(2 1) asPMVector. "4"

and #dot: computes elementwise multiplication:
#(1 2) asPMVector dot: #(2 1) asPMVector. "a PMVector(2 2)"

#dot: should probably be renamed to something like #elementwiseMultiply: or maybe a shorter binary message.

Activity

  1. olekscode commented on May 18, 2017

    @olekscode
    Member

    I think I could swap them.
    But wouldn't it silently break all the code that has ever used this multiplication?

  2. emdonahue commented on May 18, 2017

    @emdonahue
    Author

    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.

  3. SergeStinckwich commented on May 18, 2017

    @SergeStinckwich
    Member

    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.

  4. emdonahue commented on May 18, 2017

    @emdonahue
    Author

    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.

  5. nicolas-cellier-aka-nice commented on Aug 2, 2017

    @nicolas-cellier-aka-nice
    Contributor

    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)

  6. hemalvarambhia commented on Apr 24, 2019

    @hemalvarambhia
    Contributor

    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?

  7. SergeStinckwich commented on Apr 24, 2019

    @SergeStinckwich
    Member

    yes better to be more precise. Maybe hadamardProduct ?

  8. hemalvarambhia commented on Apr 30, 2019

    @hemalvarambhia
    Contributor

    I think we can introduce hadamardProduct as you say and deprecate the dot message, after your mentioning your concern about silent breaks.

  9. added this to the 1.0 milestone on May 29, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions