 // ----------------------------------------------------------------------------
 /* Ray potential function which computes the increment to the current voxel */
 template<typename TVolumetric>
-__device__ void rayPotential(TCompute realDistance, TCompute depthMapDistance, TVolumetric& res)
-{
-  TCompute diff = (realDistance - depthMapDistance);
-
-  TCompute absolute = abs(diff);
+__device__ void rayPotential(TypeCompute realDistance, TypeCompute depthMapDistance, TVolumetric& res)
+{
+  TypeCompute diff = (realDistance - depthMapDistance);
+
+  TypeCompute absoluteDiff = abs(diff);
   // Can't divide by zero
-  int sign = diff != 0 ? diff / absolute : 0;
-
-  if (absolute > c_rayPotentialDelta)
+  int sign = diff != 0 ? diff / absoluteDiff : 0;
+
+  if (absoluteDiff > c_rayPotentialDelta)
     res = diff > 0 ? 0 : -c_rayPotentialEta*c_rayPotentialRho;
-  else if (abs(diff) > c_rayPotentialThick)
+  else if (absoluteDiff > c_rayPotentialThick)
     res = c_rayPotentialRho*sign;
   else
     res = (c_rayPotentialRho / c_rayPotentialThick)* diff;

  dim3 dimGrid(1, ch_gridDims[1] - 1, ch_gridDims[2] - 1); // nb blocks on a grid

  // Create device data from host value
  TCompute *d_depthMap, *d_matrixK, *d_matrixRT;
  CudaErrorCheck(cudaMalloc((void**)&d_depthMap, nbPixelOnDepthMap * sizeof(TCompute)));
  CudaErrorCheck(cudaMalloc((void**)&d_matrixK, Mat4x4 * sizeof(TCompute)));
  CudaErrorCheck(cudaMalloc((void**)&d_matrixRT, Mat4x4 * sizeof(TCompute)));


  for (int i = 0; i < nbDepthMap; i++)
    {

/* Compute the voxel Id on a 1D table according to its 3D coordinates
  coordinates : 3D coordinates
*/
__device__ int computeVoxelIDGrid(int coordinates[SizePoint3D])
{
  int dimX = c_gridDims.x - 1;
  int dimY = c_gridDims.y - 1;
