C++ Logo

std-proposals

Advanced search

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

From: Mohit Saini <mohitsaini1196_at_[hidden]>
Date: Tue, 10 May 2022 14:32:08 +0100
Take a look at std::inner_product
<https://en.cppreference.com/w/cpp/algorithm/inner_product> .

I would think a cleaner option is to implement them like std::inner_product
only.


*Let's not pollute std::vector.*

On Tue, May 10, 2022 at 2:13 PM Patrik Tegelberg via Std-Proposals <
std-proposals_at_[hidden]> 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.
>
>
>
> Best regards
>
> Patrik Tegelberg
>
>
>
> Sent from Mail <https://go.microsoft.com/fwlink/?LinkId=550986> for
> Windows
>
>
> --
> Std-Proposals mailing list
> Std-Proposals_at_[hidden]
> https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals
>


-- 
Mohit Saini

Received on 2022-05-10 13:32:26