From e38b42afcd22481b780cdccae45756dd3117edd8 Mon Sep 17 00:00:00 2001 From: Julien Langou Date: Thu, 23 Mar 2017 15:43:42 -0400 Subject: [PATCH] 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)) --- SRC/dbdsqr.f | 4 ++-- SRC/sbdsqr.f | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/SRC/dbdsqr.f b/SRC/dbdsqr.f index 0e46e71..d3630f3 100644 --- a/SRC/dbdsqr.f +++ b/SRC/dbdsqr.f @@ -411,12 +411,12 @@ 40 CONTINUE 50 CONTINUE SMINOA = SMINOA / SQRT( DBLE( N ) ) - THRESH = MAX( TOL*SMINOA, MAXITR*N*N*UNFL ) + THRESH = MAX( TOL*SMINOA, MAXITR*(N*(N*UNFL)) ) ELSE * * Absolute accuracy desired * - THRESH = MAX( ABS( TOL )*SMAX, MAXITR*N*N*UNFL ) + THRESH = MAX( ABS( TOL )*SMAX, MAXITR*(N*(N*UNFL)) ) END IF * * Prepare for main iteration loop for the singular values diff --git a/SRC/sbdsqr.f b/SRC/sbdsqr.f index 1456010..38fd1a0 100644 --- a/SRC/sbdsqr.f +++ b/SRC/sbdsqr.f @@ -410,12 +410,12 @@ 40 CONTINUE 50 CONTINUE SMINOA = SMINOA / SQRT( REAL( N ) ) - THRESH = MAX( TOL*SMINOA, MAXITR*N*N*UNFL ) + THRESH = MAX( TOL*SMINOA, MAXITR*(N*(N*UNFL)) ) ELSE * * Absolute accuracy desired * - THRESH = MAX( ABS( TOL )*SMAX, MAXITR*N*N*UNFL ) + THRESH = MAX( ABS( TOL )*SMAX, MAXITR*(N*(N*UNFL)) ) END IF * * Prepare for main iteration loop for the singular values -- 2.7.4