private ExtremumType extremumType ( int n , double [ ] alpha_extreme , HyperBoundingBox interval ) { // return the type of the global extremum if ( n == alpha_extreme . length - 1 ) { return extremumType ; } // create random alpha values 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 + // "\nf_l " + f_l + "\nf_c " + f_c + "\nf_r " + f_r + "\np " + vec + // "\nalpha " + FormatUtil . format ( alpha_extreme_c ) + // "\nalpha_l " + FormatUtil . format ( alpha_extreme_l ) + // "\nalpha_r " + FormatUtil . format ( alpha_extreme_r ) + "\nn " + n ) ; // + "box min " + FormatUtil.format(interval.getMin()) + "\n" // + "box max " + FormatUtil.format(interval.getMax()) + "\n" }
Returns the type of the extremum at the specified alpha values .