On Tue, 10 May 2022 at 14:13, Patrik Tegelberg via Std-Proposals <std-proposals@lists.isocpp.org> 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.

 

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.


Have you considered implementing the named operator idiom? https://github.com/klmr/named-operator