cancel
Showing results for 
Search instead for 
Did you mean: 

Archives Discussions

divij
Journeyman III

[solved]dot() geometric built in function

Using dot() built in function

Hey all,

I am currently using dot function as follows: (Code 1)

But I want to calculate sum0 in one go, e.g. (Code 2)

 

Code two isn't working the way I want it. Any ideas as to how to calculate sum0 in one statement itself?

Thanks.

Code1: float4 sum0,a0,b1,b2,b3,b4; for(int =0;i<10;i++){ sum0.x+=dot(a0,b0); sum0.y+=dot(a0,b1); sum0.z+=dot(a0,b2); sum0.w+=dot(a0,b3); } code2: float4 sum0,a0,b1,b2,b3,b4; for(int =0;i<10;i++){ sum0+=(dot(a0,b0),dot(a0,b1),dot(a0,b2),dot(a0,b3)); }

0 Likes
1 Reply
divij
Journeyman III

Ok, I got the mistake.

The correct way to do it is:

 

float4 sum0,a0,b1,b2,b3,b4; for(int =0;i<10;i++){ sum0+=(float4)(dot(a0,b0),dot(a0,b1),dot(a0,b2),dot(a0,b3)); }

0 Likes