# Re: [std-proposals] Add operator for element wise multiplication.

From: Patrik Tegelberg <patrik_at_[hidden]>
Date: Sun, 15 May 2022 09:47:24 +0200

Thanks Sebastian. Yes, I saw that (named op with precedence), nice. It may well be the way to go. I am not too keen on the added code complexity. Maybe it is not that bad.

I feel I messed up the introduction of this proposal. I should have been clearer that I only meant for the extra operator to be for user overloading. I thought that just adding an extra operator to the list of operators available for overloading would be a smallish job.

I also thought that since vector math is ubiquitous it would be warranted to add the one missing operator.

Who is doing the proposal about linear algebra? Maybe I can convince them to add this as part of their proposal. It would fit nicely in there.

For now I am going with my usual work around. “vector * scalar” and “vector * vector” does the right thing, and I do not need “vector.scale(vector)” often enough to warrant the added code complexity of the named operator idiom.

Actually, when implemented like that, as member functions it almost looks like a named operator. It is the “cross(vector, vector)” that makes it extra hard to read. And I have been getting along in the libraries where I had to adapt to that also. So maybe I should give it a rest.

Sent from Mail for Windows

From: Sebastian Wittmeier via Std-Proposals
Sent: Saturday, 14 May 2022 23:54
To: std-proposals_at_[hidden]
Cc: Sebastian Wittmeier
Subject: [std-proposals] Add operator for element wise multiplication.

Hi Patrick,

if you look at the last paragraph of the Named Operator documentation, you see that you can use named operators with different precedence depending on the precedence of the delimiter.

So you could define and use

*                 // for standard operator, one of the below

*dot*

*cross*

*elem*

*outer*

With * for dot product:

a = b * c  * d  *elem*  e  *cross*  f

Or use % for the customized ones:

a = b * c  * d  %elem%  e  %cross%  f

Best,

Sebastian

--

Sebastian Wittmeier