Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

support multiplication of two float3 operands #68

Open
sahooora opened this issue Jan 7, 2021 · 2 comments
Open

support multiplication of two float3 operands #68

sahooora opened this issue Jan 7, 2021 · 2 comments

Comments

@sahooora
Copy link

sahooora commented Jan 7, 2021

Hi,

Thanks for your work.

I have a C code with variables in float3 data type. So I included float3.h header file in my code and compiled it with g++. It seems that the library doesn't support the multiplication of two float3 operands, am I right?

For example for the following line:
((float3*)((float*)compute1 + (0)))[0] = (((float3*)((float*)compute1 + (0)))[0] + (((float3*)((float*)placeholder + (0)))[0] * ((float3*)((float*)placeholder1 + ((y_outer_x_outer_fused * 3))))[0]));

I get this error:

error: no match for ‘operator*’ (operand types are ‘math::float3’ and ‘math::float3’)
       ((float3*)((float*)compute1 + (0)))[0] = (((float3*)((float*)compute1 + (0)))[0] + (((float3*)((float*)placeholder + (0)))[0] * ((float3*)((float*)placeholder1 + ((y_outer_x_outer_fused * 3))))[0]));
                                                                                           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@juj
Copy link
Owner

juj commented Jan 7, 2021

That is true, float3 * float3 is not supported by default. The rationale behind that back in the time was that point-wise multiplication is not a mathematically defined operation in linear spaces, and would possibly be a programming bug. There is a #define MATH_ENABLE_UNCOMMON_OPERATIONS that you can enable at command line to enable float3 * float3.

See

#ifdef MATH_ENABLE_UNCOMMON_OPERATIONS

Instead, by default the more explicit form oneFloat3.Mul(anotherFloat3) is used, so to be explicit when point-wise multiplication is taking place.

In hindsight it is possible that no confusion would arise from enabling it by default, but back then that was the thinking.

@sahooora
Copy link
Author

sahooora commented Jan 7, 2021

Thanks.
It's solved.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants