C++ Logo


Advanced search

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

From: Patrik Tegelberg <patrik_at_[hidden]>
Date: Tue, 10 May 2022 16:32:01 +0200

Thank you Björn. Compact mathematical notation is what this proposal is about. I wrote this but did not respond to all:

I am all for not polluting. I was thinking that the added operator would be for overloading only. It would not necessarily have to be defined for existing containers.

std::inner_product does not address the problem I am experiencing. My proposal is about enhanced readability of math expressions. I want to write  a = b * c  * d  .*  e  %  f;   instead of a = d.scale(std::inner_product(b.begin, b.end, c.begin, 0)).hadamard(e).cross(f);

I do the linear algebra implementation myself, for now, that is not the problem.


Sent from Mail for Windows


From: Bjorn Reese via Std-Proposals
Sent: Tuesday, 10 May 2022 16:22
To: Patrik Tegelberg via Std-Proposals
Cc: Bjorn Reese
Subject: Re: [std-proposals] Add operator for element wise multiplication.


On 5/10/22 15:13, Patrik Tegelberg via Std-Proposals wrote:

> I often use vector math and usually make a small vector class

> overloading the math operators. I always lack a good option for element

> wise multiplication (Hadamard product). Divide becomes element wise

> divide, multiplication becomes the dot product and % becomes the cross

> product. There are no more operators with the correct precedence to

> overload. I suggest making another symbol, with multiplication

> precedence, available for overloading.


There is a proposal to add linear algebra, although they focus on the

functionality, not a compact mathematical notation:




Std-Proposals mailing list




Received on 2022-05-10 14:32:07