C++ Logo

std-proposals

Advanced search

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

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

I have used GLM, and may still go with GLM again just because it has the same implementation as the Vulkan shader language. I agree that having the same notation is appealing. But there must be something about GLM that does not agree with me since I am writing my own stuff rather that uncommenting a few lines in my stdafx.h.

 

I do know that CryEngine has the same overload for the cross product (%) as I do. They have overloaded ^ to mean inner product and use * for element wise. But, ^ has the wrong precedence and parentheses are not nice. There are a some that think like me.

 

Sent from Mail for Windows

 

From: Jason McKesson via Std-Proposals
Sent: Tuesday, 10 May 2022 17:11
To: std-proposals_at_[hidden]
Cc: Jason McKesson
Subject: Re: [std-proposals] Add operator for element wise multiplication.

 

On Tue, May 10, 2022 at 9:13 AM 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.

 

It should be noted that shader languages that have built-in

vector/matrix functionality do not attempt to create new operators for

these. With the exception of explicit matrix multiplication, all

operators are element-wise. All other operations are performed by

function calls.

 

Many popular C++ matrix libraries (I checked Eigen and GLM) follow

this convention as well. So I'm not sure if it's a good idea to add

operators for something we have so much precedent in today.

--

Std-Proposals mailing list

Std-Proposals_at_[hidden]

https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals

 

Received on 2022-05-10 15:36:27