Yes:
Add two vector and multiply by a third.
Method 1:
Note no actually computation is done until the .Evaluate Method.
Method 2:
In this case this code would compile to a program that generates the actual implementation.
Method 3:
This would then be compiled to the code required
Method 4:
C++
openCL
openGL ES
OpenCL and OpenGL ES have significant differences not shown here so would need separate implementations.
Add two vector and multiply by a third.
Method 1:
Code:
Vector<int, 16> a, b, c;
auto temp = VecMath::Add(a,b);
Vector<int, 16> result = VecMath::Multiply(temp, c).Evaluate();
Note no actually computation is done until the .Evaluate Method.
Method 2:
Code:
Vector<int, 16> a, b, c;
Vector<int, 16> result = (a + b) * c;
Method 3:
Code:
a :: Vector Int 16
b :: Vector Int 16
c :: Vector Int 16
result = (a + b) * c
Method 4:
C++
Code:
int a[16], b[16], c[16];
int result[16];
for (int i = 0; i < 16; i++) result[i] = (a[i] + b[i]) * c[i];
openCL
Code:
int16 a, b, c;
int16 result;
result = (a + b) * c;
openGL ES
Code:
int16 a, b, c;
int16 result;
result = (a + b) * c;
OpenCL and OpenGL ES have significant differences not shown here so would need separate implementations.