Fix integer overflow in threshold calculation

Related to lapack issue 135, the threshold calculation can overflow as well as the multiplication is evaluated from left to right.
Without explicit parentheses, the calculation would overflow for N >= 18919
This commit is contained in:
Martin Kroeker 2017-03-24 15:47:36 +01:00 committed by GitHub
parent fd3f3b02ce
commit 0ada2c02e2
1 changed files with 2 additions and 2 deletions

View File

@ -410,12 +410,12 @@
40 CONTINUE 40 CONTINUE
50 CONTINUE 50 CONTINUE
SMINOA = SMINOA / SQRT( REAL( N ) ) SMINOA = SMINOA / SQRT( REAL( N ) )
THRESH = MAX( TOL*SMINOA, MAXITR*N*N*UNFL ) THRESH = MAX( TOL*SMINOA, MAXITR*(N*(N*UNFL)) )
ELSE ELSE
* *
* Absolute accuracy desired * Absolute accuracy desired
* *
THRESH = MAX( ABS( TOL )*SMAX, MAXITR*N*N*UNFL ) THRESH = MAX( ABS( TOL )*SMAX, MAXITR*(N*(N*UNFL)) )
END IF END IF
* *
* Prepare for main iteration loop for the singular values * Prepare for main iteration loop for the singular values