Hey !

One thing I really like in Matlab is the operator.* , but well it doesn't
exist in general purpose languages :P
I think that operator* is mostly convenient for nested expressions.
However, since nested expressions often introduce temporaries that are
particularly expensive, I think that defining operator* may lead to bad
performance, leading some user to not realize that they are creating a lot
temporaries when they write i.e. A = B*C*D*E  , while A = prod(B,
prod(C,prod(D,E))) is much more explicit in this regard. However, chosing
elementwise product for operator* would be super misleading in the case of
the matrix product (if someone writes A = B*C and ends up with some
elementwise product, he will be wtf'ed !).
Basically, i would personally leave all operator*(matrix,matrix),
operator*(matrix,vector) and operator*(vector,vector) undefined, but it's
just my personal opinion :) i'm not experienced with python and it might be
a great disappointment for the userbase if our syntax is too verbose (if
they are writing in python, they probably care a lot about verbosity!)

Best regards,
Philippe


2013/8/3 Toby St Clere Smithe <m...@tsmithe.net>

> Hi all,
>
> Suppose we have vectors v1 and v2. Then, we have four options for the
> semantics of "v1 * v2":
>
> 1) Element-wise product
> 2) Dot product
> 3) Outer product
> 4) Leave undefined
>
> Most of the time, in the rest of PyViennaCL, I've chosen semantics for
> the * operator that make sense given the context. For instance, for
> matrices m1 and m2, "m1 * m2" is the matrix product (not element-wise).
>
> So, I don't want to choose option (1), even though NumPy does this in
> places. NumPy is actually quite inconsistent: its "array" type is
> elementwise for all operators (*, /, +, etc; providing matrix product
> semantics for the "dot" method), but its "matrix" type has various
> semantics -- / is elementwise, but * is not, being the matrix product.
>
> This leaves (2) to (4). It seems ViennaCL itself leaves the * operator
> undefined, leaving the user to be explicit. I think I'm leaning towards
> this choice, for consistency, and to minimise confusion. But then why
> should I define the * operator for /any/ type? I think the answer is
> that, when someone has m1 and m2, "m1 * m2" is an operation they will
> want to be convenient -- more so than elementwise multiplication, or
> either the inner or outer product of vectors.
>
> But I'm not sure, hence this post.
>
>
> Best,
>
> Toby
>
>
>
> ------------------------------------------------------------------------------
> Get your SQL database under version control now!
> Version control is standard for application code, but databases havent
> caught up. So what steps can you take to put your SQL databases under
> version control? Why should you start doing it? Read more to find out.
> http://pubads.g.doubleclick.net/gampad/clk?id=49501711&iu=/4140/ostg.clktrk
> _______________________________________________
> ViennaCL-devel mailing list
> ViennaCL-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/viennacl-devel
>
------------------------------------------------------------------------------
Get your SQL database under version control now!
Version control is standard for application code, but databases havent 
caught up. So what steps can you take to put your SQL databases under 
version control? Why should you start doing it? Read more to find out.
http://pubads.g.doubleclick.net/gampad/clk?id=49501711&iu=/4140/ostg.clktrk
_______________________________________________
ViennaCL-devel mailing list
ViennaCL-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/viennacl-devel

Reply via email to