public static Pair<Double, Double> improveExtremum (double[] y, int nx, int ixmid, int interpolation, boolean isMaximum) {
	//struct improve_params params;
	double result;
        double ixmid_real;
	if (ixmid <=0) {return new Pair(y[0],0.0);}
	if (ixmid >=(nx-1)) { return new Pair(y[nx-1],(nx-1)*1.0); }
	if (interpolation <= NUM_PEAK_INTERPOLATE_NONE){ return new Pair(y[ixmid],1.0*ixmid);}
	if (interpolation == NUM_PEAK_INTERPOLATE_PARABOLIC) {
		double dy = 0.5 * (y [ixmid + 1] - y [ixmid - 1]);
		double d2y = 2 * y [ixmid] - y [ixmid - 1] - y [ixmid + 1];
		ixmid_real = ixmid + dy / d2y;
		return new Pair(y [ixmid] + 0.5 * dy * dy / d2y, ixmid_real);
	}
	/* Sinc interpolation. */
	
	int depth = interpolation == NUM_PEAK_INTERPOLATE_SINC70 ? 70 : 700;
	int ixmax = nx;
        Pair<Double,Double> pair = minimize_brent (ixmid - 1, ixmid + 1,y, depth, ixmax, isMaximum, 1e-10);
        ixmid_real = pair.first;
        result = pair.second;
	return new Pair(isMaximum ? - result : result, ixmid_real);
}