Minor re-expression in quadratic partitioning code.

Details:
- Minor change to quadratic equation solution code that avoids
  recomputation of the sqrt() parameter when the compiler is not
  smart enough to perform this optimization automatically.
This commit is contained in:
Field G. Van Zee
2015-11-03 10:30:08 -06:00
parent 0694b722f7
commit 3e6dd11467

View File

@@ -461,14 +461,15 @@ dim_t bli_get_range_width_l( doff_t diagoff_j,
const double c = -0.5 * ( ( double )diagoff_j *
( ( double )diagoff_j + 1.0 )
) - area_per_thr;
const double r = b * b - 4.0 * a * c;
// If the quadratic solution is not imaginary, round it and use that
// as our width, but make sure it didn't round to zero. Otherwise,
// discard the quadratic solution and leave width, as previously
// computed, unchanged.
if ( b * b - 4.0 * a * c >= 0 )
if ( r >= 0.0 )
{
const double x = ( -b + sqrt( b * b - 4.0 * a * c ) ) / ( 2.0 * a );
const double x = ( -b + sqrt( r ) ) / ( 2.0 * a );
width = ( dim_t )bli_round( x );
if ( width == 0 ) width = 1;