private ExtremumType extremumType(int n,double[] alpha_extreme,HyperBoundingBox interval){
  if (n == alpha_extreme.length - 1) {
    return extremumType;
  }
  double[] alpha_extreme_l=new double[alpha_extreme.length];
  double[] alpha_extreme_r=new double[alpha_extreme.length];
  double[] alpha_extreme_c=new double[alpha_extreme.length];
  System.arraycopy(alpha_extreme,0,alpha_extreme_l,0,alpha_extreme.length);
  System.arraycopy(alpha_extreme,0,alpha_extreme_r,0,alpha_extreme.length);
  System.arraycopy(alpha_extreme,0,alpha_extreme_c,0,alpha_extreme.length);
  double[] centroid=SpatialUtil.centroid(interval);
  for (int i=0; i < n; i++) {
    alpha_extreme_l[i]=centroid[i];
    alpha_extreme_r[i]=centroid[i];
    alpha_extreme_c[i]=centroid[i];
  }
  double intervalLength=interval.getMax(n) - interval.getMin(n);
  alpha_extreme_l[n]=Math.random() * intervalLength + interval.getMin(n);
  alpha_extreme_r[n]=Math.random() * intervalLength + interval.getMin(n);
  double f_c=function(alpha_extreme_c);
  double f_l=function(alpha_extreme_l);
  double f_r=function(alpha_extreme_r);
  if (f_l < f_c) {
    if (f_r < f_c || Math.abs(f_r - f_c) < DELTA) {
      return ExtremumType.MAXIMUM;
    }
  }
  if (f_r < f_c) {
    if (f_l < f_c || Math.abs(f_l - f_c) < DELTA) {
      return ExtremumType.MAXIMUM;
    }
  }
  if (f_l > f_c) {
    if (f_r > f_c || Math.abs(f_r - f_c) < DELTA) {
      return ExtremumType.MINIMUM;
    }
  }
  if (f_r > f_c) {
    if (f_l > f_c || Math.abs(f_l - f_c) < DELTA) {
      return ExtremumType.MINIMUM;
    }
  }
  if (Math.abs(f_l - f_c) < DELTA && Math.abs(f_r - f_c) < DELTA) {
    return ExtremumType.CONSTANT;
  }
  throw new IllegalArgumentException("Houston, we have a problem!\n" + this + "\n"+ "f_l "+ f_l+ "\n"+ "f_c "+ f_c+ "\n"+ "f_r "+ f_r+ "\n"+ "p "+ vec.toArray()+ "\n"+ "alpha   "+ FormatUtil.format(alpha_extreme_c)+ "\n"+ "alpha_l "+ FormatUtil.format(alpha_extreme_l)+ "\n"+ "alpha_r "+ FormatUtil.format(alpha_extreme_r)+ "\n"+ "n "+ n);
}

private ExtremumType extremumType ( int n , double [ ] alpha_extreme , HyperBoundingBox interval ) { if ( n == alpha_extreme . length - 1 ) { return extremumType ; } double [ ] alpha_extreme_l = new double [ alpha_extreme . length ] ; double [ ] alpha_extreme_r = new double [ alpha_extreme . length ] ; double [ ] alpha_extreme_c = new double [ alpha_extreme . length ] ; System . arraycopy ( alpha_extreme , 0 , alpha_extreme_l , 0 , alpha_extreme . length ) ; System . arraycopy ( alpha_extreme , 0 , alpha_extreme_r , 0 , alpha_extreme . length ) ; System . arraycopy ( alpha_extreme , 0 , alpha_extreme_c , 0 , alpha_extreme . length ) ; double [ ] centroid = SpatialUtil . centroid ( interval ) ; for ( int i = 0 ; i < n ; i ++ ) { alpha_extreme_l [ i ] = centroid [ i ] ; alpha_extreme_r [ i ] = centroid [ i ] ; alpha_extreme_c [ i ] = centroid [ i ] ; } double intervalLength = interval . getMax ( n ) - interval . getMin ( n ) ; alpha_extreme_l [ n ] = Math . random ( ) * intervalLength + interval . getMin ( n ) ; alpha_extreme_r [ n ] = Math . random ( ) * intervalLength + interval . getMin ( n ) ; double f_c = function ( alpha_extreme_c ) ; double f_l = function ( alpha_extreme_l ) ; double f_r = function ( alpha_extreme_r ) ; if ( f_l < f_c ) { if ( f_r < f_c || Math . abs ( f_r - f_c ) < DELTA ) { return ExtremumType . MAXIMUM ; } } if ( f_r < f_c ) { if ( f_l < f_c || Math . abs ( f_l - f_c ) < DELTA ) { return ExtremumType . MAXIMUM ; } } if ( f_l > f_c ) { if ( f_r > f_c || Math . abs ( f_r - f_c ) < DELTA ) { return ExtremumType . MINIMUM ; } } if ( f_r > f_c ) { if ( f_l > f_c || Math . abs ( f_l - f_c ) < DELTA ) { return ExtremumType . MINIMUM ; } } if ( Math . abs ( f_l - f_c ) < DELTA && Math . abs ( f_r - f_c ) < DELTA ) { return ExtremumType . CONSTANT ; } throw new IllegalArgumentException ( "Houston, we have a problem!\n" + this + "\n" + "f_l " + f_l + "\n" + "f_c " + f_c + "\n" + "f_r " + f_r + "\n" + "p " + vec . toArray ( ) + "\n" + "alpha   " + FormatUtil . format ( alpha_extreme_c ) + "\n" + "alpha_l " + FormatUtil . format ( alpha_extreme_l ) + "\n" + "alpha_r " + FormatUtil . format ( alpha_extreme_r ) + "\n" + "n " + n ) ; }
returns the type of the extremum at the specified alpha values .
