Skip to content

Commit e38b42a

Browse files
committed
This is related to #135
Since the order of multiplication in Fortran is left to right, the expression MAXITR*N*N*UNFL first computes MAXITR*N*N as an INTEGER. This causes INTEGER overflow for N>=18919. To avoid the problem, rewrite as: MAXITR*(N*(N*UNFL))
1 parent 42fe66c commit e38b42a

2 files changed

Lines changed: 4 additions & 4 deletions

File tree

SRC/dbdsqr.f

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -411,12 +411,12 @@ SUBROUTINE DBDSQR( UPLO, N, NCVT, NRU, NCC, D, E, VT, LDVT, U,
411411
40 CONTINUE
412412
50 CONTINUE
413413
SMINOA = SMINOA / SQRT( DBLE( N ) )
414-
THRESH = MAX( TOL*SMINOA, MAXITR*N*N*UNFL )
414+
THRESH = MAX( TOL*SMINOA, MAXITR*(N*(N*UNFL)) )
415415
ELSE
416416
*
417417
* Absolute accuracy desired
418418
*
419-
THRESH = MAX( ABS( TOL )*SMAX, MAXITR*N*N*UNFL )
419+
THRESH = MAX( ABS( TOL )*SMAX, MAXITR*(N*(N*UNFL)) )
420420
END IF
421421
*
422422
* Prepare for main iteration loop for the singular values

SRC/sbdsqr.f

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -410,12 +410,12 @@ SUBROUTINE SBDSQR( UPLO, N, NCVT, NRU, NCC, D, E, VT, LDVT, U,
410410
40 CONTINUE
411411
50 CONTINUE
412412
SMINOA = SMINOA / SQRT( REAL( N ) )
413-
THRESH = MAX( TOL*SMINOA, MAXITR*N*N*UNFL )
413+
THRESH = MAX( TOL*SMINOA, MAXITR*(N*(N*UNFL)) )
414414
ELSE
415415
*
416416
* Absolute accuracy desired
417417
*
418-
THRESH = MAX( ABS( TOL )*SMAX, MAXITR*N*N*UNFL )
418+
THRESH = MAX( ABS( TOL )*SMAX, MAXITR*(N*(N*UNFL)) )
419419
END IF
420420
*
421421
* Prepare for main iteration loop for the singular values

0 commit comments

Comments
 (0)