 ////////////////////////////////////////////////////////////////////////////////
 inline __device__ float3 roundAndExpand(float3 v, ushort * w)
 {
-    v.x = rintf(__saturatef(v.x) * 31.0f);
-    v.y = rintf(__saturatef(v.y) * 63.0f);
-    v.z = rintf(__saturatef(v.z) * 31.0f);
-    *w = ((ushort)v.x << 11) | ((ushort)v.y << 5) | (ushort)v.z;
-    v.x *= 0.03227752766457f; // approximate integer bit expansion.
-    v.y *= 0.01583151765563f;
-    v.z *= 0.03227752766457f;
-    return v;
+	v.x = rintf(__saturatef(v.x) * 31.0f);
+	v.y = rintf(__saturatef(v.y) * 63.0f);
+	v.z = rintf(__saturatef(v.z) * 31.0f);
+	*w = ((ushort)v.x << 11) | ((ushort)v.y << 5) | (ushort)v.z;
+	v.x *= 0.03227752766457f; // approximate integer bit expansion.
+	v.y *= 0.01583151765563f;
+	v.z *= 0.03227752766457f;
+	return v;
 }
 
 

	
	__shared__ uint s_permutations[160];

    for(int i = 0; i < 16; i++)
    {
		int pidx = idx + NUM_THREADS * i;
		if (pidx >= 992) break;
        
        ushort start, end;
        uint permutation = permutations[pidx];
        if (pidx < 160) s_permutations[pidx] = permutation;
                
        float error = evalPermutation4(colors, colorSum, permutation, &start, &end);
        
        if (error < bestError)
        {
            bestError = error;
            bestPermutation = permutation;
            bestStart = start;
            bestEnd = end;
        }
    }

    if (bestStart < bestEnd)
    {
        swap(bestEnd, bestStart);
        bestPermutation ^= 0x55555555;    // Flip indices.
    }

    for(int i = 0; i < 3; i++)
    {
		int pidx = idx + NUM_THREADS * i;
        if (pidx >= 160) break;
        
        ushort start, end;
        uint permutation = s_permutations[pidx];
        float error = evalPermutation3(colors, colorSum, permutation, &start, &end);
        
        if (error < bestError)
        {
            bestError = error;
            bestPermutation = permutation;
            bestStart = start;
            bestEnd = end;
            
            if (bestStart > bestEnd)
            {
                swap(bestEnd, bestStart);
                bestPermutation ^= (~bestPermutation >> 1) & 0x55555555;    // Flip indices.
            }
        }
    }

	errors[idx] = bestError;
}


inline __device__ uchar roundAndExpand(float a)
{
	return rintf(__saturatef(a) * 255.0f);
}
*/
/*
