No. You would need a zeroing routing that takes element size and stride as additional parameters, because the .x or .y components are not contiguous in memory.
I don’t think you can do it with that function, can you not just write another one? you could just write the cuda kernel that accepts an array of float2, a size of the array and a parameter that says if you want to use x or y components. Then in the kernel you just make it check whether you want x or y then only update those components.
eg
settozero(float2 data, int size, bool xory){
...
if (xory){
data[i].x = 0;
}
else {
data[i].y = 0;
}
Thanks for the reply. Yeah actually the parameter solution is i think the best way to do so. I was considering it but didn’t know whether or not there was another ‘more elegant’ way to do that.