I want to compute the kronecker delta (i = j returns 1, otherwise 0) for each element of a stream of type uint4. If I recall correctly, conditionals operate only on the first element of a vector type, so anything based on a conditional is out. I tried abs(sign(i - j)) but abs() will not accept a uint4, presumably because it has a conditional buried in it. The best I've come up with is:
kernel uint4 kronecker_delta(uint4 i<>, uint j<>
int4 k_d = sign((int4) i - (int4)j);
return (uint4)(k_d * k_d);
My Brook+ experience is near zero, so I wonder if I'm missing some much easier/faster way to do this.