   factor_sum = 0;
 
   for(int32_t i=0; i < 8; i++){
-      weight_sum0 = 4.0 - std::abs(val[i]-val_curr);
-      weight_sum0 = max(weight_sum0, 0.0);
-      weight_sum += weight_sum0;
-      factor_sum += val_curr*weight_sum0;
+    weight_sum0 = 4.0f - fabs(val[i]-val_curr);
+    weight_sum0 = max(0.0f, weight_sum0);
+    weight_sum += weight_sum0;
+    factor_sum += val[i]*weight_sum0;
   }
   
   if (weight_sum>0) {

  float factor_sum = 0;

  for(int32_t i=0; i < 8; i++){
      weight_sum0 = 4.0 - std::abs(val[i]-val_curr);
      weight_sum0 = max(weight_sum0, 0.0);
      weight_sum += weight_sum0;
      factor_sum += val_curr*weight_sum0;
  }
  
  if (weight_sum>0) {

            factor_sum2 += val[i]*weight_sum0;
        }

        if (weight_sum2>0) {
          float d = factor_sum2/weight_sum2;
          if (d>=0) *(D_tmp+v*D_width+(u-3)) = d;
