如何在 Thrust 中实现此功能?
for (i=0;i<n;i++)
if (i==pos)
h1[i]=1/h1[i];
else
h1[i]=-h1[i]/value;
在CUDA中,我这样做了:
__global__ void inverse_1(double* h1, double value, int pos, int N)
{
int i = blockDim.x * blockIdx.x + threadIdx.x;
if (i < N){
if (i == pos)
h1[i] = 1 / h1[i];
else
h1[i] = -h1[i] / value;
}
}
谢谢!