private static double EvalSegmentedFn(final cmsToneCurve g, double R)
	{
	    int i;
	    for (i = g.nSegments-1; i >= 0 ; --i)
	    {
	        // Check for domain
	        if ((R > g.Segments[i].x0) && (R <= g.Segments[i].x1))
	        {
	            // Type == 0 means segment is sampled
	            if (g.Segments[i].Type == 0)
	            {
	                float R1 = (float)(R - g.Segments[i].x0);
	                float[] Out = new float[1];
	                // Setup the table (TODO: clean that)
	                g.SegInterp[i].Table = g.Segments[i].SampledPoints;
	                g.SegInterp[i].Interpolation.getFloat().run(new float[]{R1}, Out, g.SegInterp[i]);
	                return Out[0];
	            }
	            else
	            {
	            	return g.Evals[i].run(g.Segments[i].Type, g.Segments[i].Params, R);
	            }
	        }
	    }
	    return MINUS_INF;
	}
private static double EvalSegmentedFn(final cmsToneCurve g, double R)
	{
	    int i;
	    for (i = g.nSegments-1; i >= 0 ; --i)
	    {
	       
	        if ((R > g.Segments[i].x0) && (R <= g.Segments[i].x1))
	        {
	           
	            if (g.Segments[i].Type == 0)
	            {
	                float R1 = (float)(R - g.Segments[i].x0);
	                float[] Out = new float[1];
	               
	                g.SegInterp[i].Table = g.Segments[i].SampledPoints;
	                g.SegInterp[i].Interpolation.getFloat().run(new float[]{R1}, Out, g.SegInterp[i]);
	                return Out[0];
	            }
	            else
	            {
	            	return g.Evals[i].run(g.Segments[i].Type, g.Segments[i].Params, R);
	            }
	        }
	    }
	    return MINUS_INF;
	}
private static double evalsegmentedfn(final cmstonecurve g, double r) { int i; for (i = g.nsegments-1; i >= 0 ; --i) { if ((r > g.segments[i].x0) && (r <= g.segments[i].x1)) { if (g.segments[i].type == 0) { float r1 = (float)(r - g.segments[i].x0); float[] out = new float[1]; g.seginterp[i].table = g.segments[i].sampledpoints; g.seginterp[i].interpolation.getfloat().run(new float[]{r1}, out, g.seginterp[i]); return out[0]; } else { return g.evals[i].run(g.segments[i].type, g.segments[i].params, r); } } } return minus_inf; }