inverse distance weighting interpolation
问题 I would like to compute a weight as reciprocal of a distance for something like inverse distance weighting interpolation. double wgt = 0, wgt_tmp, result = 0; for (int i = 0; i < num; i++) { wgt_tmp = 1.0/dist[i]; wgt += wgt_tmp; result += wgt_tmp * values[i]; } results /= wgt; However the distance can be 0 and I need to make the weight suitable for computation. If there is only one distance dist[i] is 0 , I would like its corresponding value values[i] to be dominant . If there are several