C++ Logo

std-proposals

Advanced search

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

From: Patrik Tegelberg <patrik_at_[hidden]>
Date: Tue, 10 May 2022 15:13:36 +0200

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.

 

Matlab uses .* for their elementwise operations. They also use ./ and .^ so it is an established convention. But both dot and asterisk have other meanings in C++, maybe ยค would be pretty, if we are allowed to use it.

The symbol is not that important, the important thing is to get another operator with multiplication precedence.

 

Best regards

Patrik Tegelberg

 

Sent from Mail for Windows

 

Received on 2022-05-10 13:13:42