Any reason to not just use a function? (like np.dot etc)

My understanding is that in python '*' means elementwise multiplication, so 
even if you could monkeypatch numpys __mul__ method to do the right thing 
wouldn't you be changing the semantics?

Gabriel

On Friday, October 7, 2016 at 3:51:11 AM UTC-6, Sisyphuss wrote:

> In Julia, we can do multiple dispatch for operators, that is the 
> interpreter can identify:
> float + integer
> integer + integer
> integer + float
> float + float
> as well as *user-defined* data structure.
>
> Recently, I am working on Python (I have no choice because Spark hasn't 
> yet a Julia binding). I intended to do the same thing -- multiplication -- 
> between a Numpy matrix and self-defined Low-rank matrix. Of course, I 
> defined the `__rmul__ ` method for Low-rank matrix. However, it seems to me 
> that the Numpy matrix intercepts the `*` operator as its `__mul__` method, 
> which expects the argument on the right side of `*` to be a scalar.
>
> I would like to know if there is anyway around?
>
>

Reply via email to