public final float apply(float x, float y, float z) {
        // Skew input space to relative coordinate in simplex cell
        s = (x + y + z) * onethird;
        i = fastfloor(x+s);
        j = fastfloor(y+s);
        k = fastfloor(z+s);
 
        // Unskew cell origin back to (x, y , z) space
        s = (i + j + k) * onesixth;
        u = x - i + s;
        v = y - j + s;
        w = z - k + s;
 
        A[0] = A[1] = A[2] = 0;
 
        // For 3D case, the simplex shape is a slightly irregular tetrahedron.
        // Determine which simplex we're in
        int hi = u >= w ? u >= v ? 0 : 1 : v >= w ? 1 : 2;
        int lo = u < w ? u < v ? 0 : 1 : v < w ? 1 : 2;
 
        return k(hi) + k(3 - hi - lo) + k(lo) + k(0);
    }