1 *> \brief \b DGSVJ0 pre-processor for the routine dgesvj.
3 * =========== DOCUMENTATION ===========
5 * Online html documentation available at
6 * http://www.netlib.org/lapack/explore-html/
9 *> Download DGSVJ0 + dependencies
10 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/dgsvj0.f">
12 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/dgsvj0.f">
14 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/dgsvj0.f">
21 * SUBROUTINE DGSVJ0( JOBV, M, N, A, LDA, D, SVA, MV, V, LDV, EPS,
22 * SFMIN, TOL, NSWEEP, WORK, LWORK, INFO )
24 * .. Scalar Arguments ..
25 * INTEGER INFO, LDA, LDV, LWORK, M, MV, N, NSWEEP
26 * DOUBLE PRECISION EPS, SFMIN, TOL
29 * .. Array Arguments ..
30 * DOUBLE PRECISION A( LDA, * ), SVA( N ), D( N ), V( LDV, * ),
40 *> DGSVJ0 is called from DGESVJ as a pre-processor and that is its main
41 *> purpose. It applies Jacobi rotations in the same way as DGESVJ does, but
42 *> it does not check convergence (stopping criterion). Few tuning
43 *> parameters (marked by [TP]) are available for the implementer.
51 *> JOBV is CHARACTER*1
52 *> Specifies whether the output from this procedure is used
53 *> to compute the matrix V:
54 *> = 'V': the product of the Jacobi rotations is accumulated
55 *> by postmulyiplying the N-by-N array V.
56 *> (See the description of V.)
57 *> = 'A': the product of the Jacobi rotations is accumulated
58 *> by postmulyiplying the MV-by-N array V.
59 *> (See the descriptions of MV and V.)
60 *> = 'N': the Jacobi rotations are not accumulated.
66 *> The number of rows of the input matrix A. M >= 0.
72 *> The number of columns of the input matrix A.
78 *> A is DOUBLE PRECISION array, dimension (LDA,N)
79 *> On entry, M-by-N matrix A, such that A*diag(D) represents
82 *> A_onexit * D_onexit represents the input matrix A*diag(D)
83 *> post-multiplied by a sequence of Jacobi rotations, where the
84 *> rotation threshold and the total number of sweeps are given in
85 *> TOL and NSWEEP, respectively.
86 *> (See the descriptions of D, TOL and NSWEEP.)
92 *> The leading dimension of the array A. LDA >= max(1,M).
97 *> D is DOUBLE PRECISION array, dimension (N)
98 *> The array D accumulates the scaling factors from the fast scaled
100 *> On entry, A*diag(D) represents the input matrix.
101 *> On exit, A_onexit*diag(D_onexit) represents the input matrix
102 *> post-multiplied by a sequence of Jacobi rotations, where the
103 *> rotation threshold and the total number of sweeps are given in
104 *> TOL and NSWEEP, respectively.
105 *> (See the descriptions of A, TOL and NSWEEP.)
108 *> \param[in,out] SVA
110 *> SVA is DOUBLE PRECISION array, dimension (N)
111 *> On entry, SVA contains the Euclidean norms of the columns of
112 *> the matrix A*diag(D).
113 *> On exit, SVA contains the Euclidean norms of the columns of
114 *> the matrix onexit*diag(D_onexit).
120 *> If JOBV .EQ. 'A', then MV rows of V are post-multipled by a
121 *> sequence of Jacobi rotations.
122 *> If JOBV = 'N', then MV is not referenced.
127 *> V is DOUBLE PRECISION array, dimension (LDV,N)
128 *> If JOBV .EQ. 'V' then N rows of V are post-multipled by a
129 *> sequence of Jacobi rotations.
130 *> If JOBV .EQ. 'A' then MV rows of V are post-multipled by a
131 *> sequence of Jacobi rotations.
132 *> If JOBV = 'N', then V is not referenced.
138 *> The leading dimension of the array V, LDV >= 1.
139 *> If JOBV = 'V', LDV .GE. N.
140 *> If JOBV = 'A', LDV .GE. MV.
145 *> EPS is DOUBLE PRECISION
146 *> EPS = DLAMCH('Epsilon')
151 *> SFMIN is DOUBLE PRECISION
152 *> SFMIN = DLAMCH('Safe Minimum')
157 *> TOL is DOUBLE PRECISION
158 *> TOL is the threshold for Jacobi rotations. For a pair
159 *> A(:,p), A(:,q) of pivot columns, the Jacobi rotation is
160 *> applied only if DABS(COS(angle(A(:,p),A(:,q)))) .GT. TOL.
166 *> NSWEEP is the number of sweeps of Jacobi rotations to be
172 *> WORK is DOUBLE PRECISION array, dimension (LWORK)
178 *> LWORK is the dimension of WORK. LWORK .GE. M.
184 *> = 0 : successful exit.
185 *> < 0 : if INFO = -i, then the i-th argument had an illegal value
191 *> \author Univ. of Tennessee
192 *> \author Univ. of California Berkeley
193 *> \author Univ. of Colorado Denver
196 *> \date November 2015
198 *> \ingroup doubleOTHERcomputational
200 *> \par Further Details:
201 * =====================
203 *> DGSVJ0 is used just to enable DGESVJ to call a simplified version of
204 *> itself to work on a submatrix of the original matrix.
206 *> \par Contributors:
209 *> Zlatko Drmac (Zagreb, Croatia) and Kresimir Veselic (Hagen, Germany)
211 *> \par Bugs, Examples and Comments:
212 * =================================
214 *> Please report all bugs and send interesting test examples and comments to
215 *> drmac@math.hr. Thank you.
217 * =====================================================================
218 SUBROUTINE DGSVJ0( JOBV, M, N, A, LDA, D, SVA, MV, V, LDV, EPS,
219 $ SFMIN, TOL, NSWEEP, WORK, LWORK, INFO )
221 * -- LAPACK computational routine (version 3.6.0) --
222 * -- LAPACK is a software package provided by Univ. of Tennessee, --
223 * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
226 * .. Scalar Arguments ..
227 INTEGER INFO, LDA, LDV, LWORK, M, MV, N, NSWEEP
228 DOUBLE PRECISION EPS, SFMIN, TOL
231 * .. Array Arguments ..
232 DOUBLE PRECISION A( LDA, * ), SVA( N ), D( N ), V( LDV, * ),
236 * =====================================================================
238 * .. Local Parameters ..
239 DOUBLE PRECISION ZERO, HALF, ONE
240 PARAMETER ( ZERO = 0.0D0, HALF = 0.5D0, ONE = 1.0D0)
242 * .. Local Scalars ..
243 DOUBLE PRECISION AAPP, AAPP0, AAPQ, AAQQ, APOAQ, AQOAP, BIG,
244 $ BIGTHETA, CS, MXAAPQ, MXSINJ, ROOTBIG, ROOTEPS,
245 $ ROOTSFMIN, ROOTTOL, SMALL, SN, T, TEMP1, THETA,
247 INTEGER BLSKIP, EMPTSW, i, ibr, IERR, igl, IJBLSK, ir1,
248 $ ISWROT, jbc, jgl, KBL, LKAHEAD, MVL, NBL,
249 $ NOTROT, p, PSKIPPED, q, ROWSKIP, SWBAND
250 LOGICAL APPLV, ROTOK, RSVEC
253 DOUBLE PRECISION FASTR( 5 )
255 * .. Intrinsic Functions ..
256 INTRINSIC DABS, MAX, DBLE, MIN, DSIGN, DSQRT
258 * .. External Functions ..
259 DOUBLE PRECISION DDOT, DNRM2
262 EXTERNAL IDAMAX, LSAME, DDOT, DNRM2
264 * .. External Subroutines ..
265 EXTERNAL DAXPY, DCOPY, DLASCL, DLASSQ, DROTM, DSWAP
267 * .. Executable Statements ..
269 * Test the input parameters.
271 APPLV = LSAME( JOBV, 'A' )
272 RSVEC = LSAME( JOBV, 'V' )
273 IF( .NOT.( RSVEC .OR. APPLV .OR. LSAME( JOBV, 'N' ) ) ) THEN
275 ELSE IF( M.LT.0 ) THEN
277 ELSE IF( ( N.LT.0 ) .OR. ( N.GT.M ) ) THEN
279 ELSE IF( LDA.LT.M ) THEN
281 ELSE IF( ( RSVEC.OR.APPLV ) .AND. ( MV.LT.0 ) ) THEN
283 ELSE IF( ( RSVEC.AND.( LDV.LT.N ) ).OR.
284 $ ( APPLV.AND.( LDV.LT.MV ) ) ) THEN
286 ELSE IF( TOL.LE.EPS ) THEN
288 ELSE IF( NSWEEP.LT.0 ) THEN
290 ELSE IF( LWORK.LT.M ) THEN
298 CALL XERBLA( 'DGSVJ0', -INFO )
304 ELSE IF( APPLV ) THEN
307 RSVEC = RSVEC .OR. APPLV
309 ROOTEPS = DSQRT( EPS )
310 ROOTSFMIN = DSQRT( SFMIN )
313 ROOTBIG = ONE / ROOTSFMIN
314 BIGTHETA = ONE / ROOTEPS
315 ROOTTOL = DSQRT( TOL )
317 * -#- Row-cyclic Jacobi SVD algorithm with column pivoting -#-
319 EMPTSW = ( N*( N-1 ) ) / 2
323 * -#- Row-cyclic pivot strategy with de Rijk's pivoting -#-
327 *[TP] SWBAND is a tuning parameter. It is meaningful and effective
328 * if SGESVJ is used as a computational routine in the preconditioned
329 * Jacobi SVD algorithm SGESVJ. For sweeps i=1:SWBAND the procedure
333 *[TP] KBL is a tuning parameter that defines the tile size in the
334 * tiling of the p-q loops of pivot pairs. In general, an optimal
335 * value of KBL depends on the matrix dimensions and on the
336 * parameters of the computer's memory.
339 IF( ( NBL*KBL ).NE.N )NBL = NBL + 1
341 BLSKIP = ( KBL**2 ) + 1
342 *[TP] BLKSKIP is a tuning parameter that depends on SWBAND and KBL.
344 ROWSKIP = MIN( 5, KBL )
345 *[TP] ROWSKIP is a tuning parameter.
348 *[TP] LKAHEAD is a tuning parameter.
352 DO 1993 i = 1, NSWEEP
364 igl = ( ibr-1 )*KBL + 1
366 DO 1002 ir1 = 0, MIN( LKAHEAD, NBL-ibr )
370 DO 2001 p = igl, MIN( igl+KBL-1, N-1 )
372 * .. de Rijk's pivoting
373 q = IDAMAX( N-p+1, SVA( p ), 1 ) + p - 1
375 CALL DSWAP( M, A( 1, p ), 1, A( 1, q ), 1 )
376 IF( RSVEC )CALL DSWAP( MVL, V( 1, p ), 1,
388 * Column norms are periodically updated by explicit
391 * Some BLAS implementations compute DNRM2(M,A(1,p),1)
392 * as DSQRT(DDOT(M,A(1,p),1,A(1,p),1)), which may result in
393 * overflow for ||A(:,p)||_2 > DSQRT(overflow_threshold), and
394 * undeflow for ||A(:,p)||_2 < DSQRT(underflow_threshold).
395 * Hence, DNRM2 cannot be trusted, not even in the case when
396 * the true norm is far from the under(over)flow boundaries.
397 * If properly implemented DNRM2 is available, the IF-THEN-ELSE
398 * below should read "AAPP = DNRM2( M, A(1,p), 1 ) * D(p)".
400 IF( ( SVA( p ).LT.ROOTBIG ) .AND.
401 $ ( SVA( p ).GT.ROOTSFMIN ) ) THEN
402 SVA( p ) = DNRM2( M, A( 1, p ), 1 )*D( p )
406 CALL DLASSQ( M, A( 1, p ), 1, TEMP1, AAPP )
407 SVA( p ) = TEMP1*DSQRT( AAPP )*D( p )
415 IF( AAPP.GT.ZERO ) THEN
419 DO 2002 q = p + 1, MIN( igl+KBL-1, N )
423 IF( AAQQ.GT.ZERO ) THEN
426 IF( AAQQ.GE.ONE ) THEN
427 ROTOK = ( SMALL*AAPP ).LE.AAQQ
428 IF( AAPP.LT.( BIG / AAQQ ) ) THEN
429 AAPQ = ( DDOT( M, A( 1, p ), 1, A( 1,
430 $ q ), 1 )*D( p )*D( q ) / AAQQ )
433 CALL DCOPY( M, A( 1, p ), 1, WORK, 1 )
434 CALL DLASCL( 'G', 0, 0, AAPP, D( p ),
435 $ M, 1, WORK, LDA, IERR )
436 AAPQ = DDOT( M, WORK, 1, A( 1, q ),
440 ROTOK = AAPP.LE.( AAQQ / SMALL )
441 IF( AAPP.GT.( SMALL / AAQQ ) ) THEN
442 AAPQ = ( DDOT( M, A( 1, p ), 1, A( 1,
443 $ q ), 1 )*D( p )*D( q ) / AAQQ )
446 CALL DCOPY( M, A( 1, q ), 1, WORK, 1 )
447 CALL DLASCL( 'G', 0, 0, AAQQ, D( q ),
448 $ M, 1, WORK, LDA, IERR )
449 AAPQ = DDOT( M, WORK, 1, A( 1, p ),
454 MXAAPQ = MAX( MXAAPQ, DABS( AAPQ ) )
456 * TO rotate or NOT to rotate, THAT is the question ...
458 IF( DABS( AAPQ ).GT.TOL ) THEN
461 * ROTATED = ROTATED + ONE
473 THETA = -HALF*DABS( AQOAP-APOAQ )/AAPQ
475 IF( DABS( THETA ).GT.BIGTHETA ) THEN
478 FASTR( 3 ) = T*D( p ) / D( q )
479 FASTR( 4 ) = -T*D( q ) / D( p )
480 CALL DROTM( M, A( 1, p ), 1,
481 $ A( 1, q ), 1, FASTR )
482 IF( RSVEC )CALL DROTM( MVL,
486 SVA( q ) = AAQQ*DSQRT( MAX( ZERO,
487 $ ONE+T*APOAQ*AAPQ ) )
488 AAPP = AAPP*DSQRT( MAX( ZERO,
489 $ ONE-T*AQOAP*AAPQ ) )
490 MXSINJ = MAX( MXSINJ, DABS( T ) )
494 * .. choose correct signum for THETA and rotate
496 THSIGN = -DSIGN( ONE, AAPQ )
497 T = ONE / ( THETA+THSIGN*
498 $ DSQRT( ONE+THETA*THETA ) )
499 CS = DSQRT( ONE / ( ONE+T*T ) )
502 MXSINJ = MAX( MXSINJ, DABS( SN ) )
503 SVA( q ) = AAQQ*DSQRT( MAX( ZERO,
504 $ ONE+T*APOAQ*AAPQ ) )
505 AAPP = AAPP*DSQRT( MAX( ZERO,
506 $ ONE-T*AQOAP*AAPQ ) )
508 APOAQ = D( p ) / D( q )
509 AQOAP = D( q ) / D( p )
510 IF( D( p ).GE.ONE ) THEN
511 IF( D( q ).GE.ONE ) THEN
513 FASTR( 4 ) = -T*AQOAP
516 CALL DROTM( M, A( 1, p ), 1,
519 IF( RSVEC )CALL DROTM( MVL,
520 $ V( 1, p ), 1, V( 1, q ),
523 CALL DAXPY( M, -T*AQOAP,
526 CALL DAXPY( M, CS*SN*APOAQ,
532 CALL DAXPY( MVL, -T*AQOAP,
542 IF( D( q ).GE.ONE ) THEN
543 CALL DAXPY( M, T*APOAQ,
546 CALL DAXPY( M, -CS*SN*AQOAP,
552 CALL DAXPY( MVL, T*APOAQ,
561 IF( D( p ).GE.D( q ) ) THEN
562 CALL DAXPY( M, -T*AQOAP,
565 CALL DAXPY( M, CS*SN*APOAQ,
581 CALL DAXPY( M, T*APOAQ,
592 $ T*APOAQ, V( 1, p ),
605 * .. have to use modified Gram-Schmidt like transformation
606 CALL DCOPY( M, A( 1, p ), 1, WORK, 1 )
607 CALL DLASCL( 'G', 0, 0, AAPP, ONE, M,
608 $ 1, WORK, LDA, IERR )
609 CALL DLASCL( 'G', 0, 0, AAQQ, ONE, M,
610 $ 1, A( 1, q ), LDA, IERR )
611 TEMP1 = -AAPQ*D( p ) / D( q )
612 CALL DAXPY( M, TEMP1, WORK, 1,
614 CALL DLASCL( 'G', 0, 0, ONE, AAQQ, M,
615 $ 1, A( 1, q ), LDA, IERR )
616 SVA( q ) = AAQQ*DSQRT( MAX( ZERO,
618 MXSINJ = MAX( MXSINJ, SFMIN )
620 * END IF ROTOK THEN ... ELSE
622 * In the case of cancellation in updating SVA(q), SVA(p)
623 * recompute SVA(q), SVA(p).
624 IF( ( SVA( q ) / AAQQ )**2.LE.ROOTEPS )
626 IF( ( AAQQ.LT.ROOTBIG ) .AND.
627 $ ( AAQQ.GT.ROOTSFMIN ) ) THEN
628 SVA( q ) = DNRM2( M, A( 1, q ), 1 )*
633 CALL DLASSQ( M, A( 1, q ), 1, T,
635 SVA( q ) = T*DSQRT( AAQQ )*D( q )
638 IF( ( AAPP / AAPP0 ).LE.ROOTEPS ) THEN
639 IF( ( AAPP.LT.ROOTBIG ) .AND.
640 $ ( AAPP.GT.ROOTSFMIN ) ) THEN
641 AAPP = DNRM2( M, A( 1, p ), 1 )*
646 CALL DLASSQ( M, A( 1, p ), 1, T,
648 AAPP = T*DSQRT( AAPP )*D( p )
654 * A(:,p) and A(:,q) already numerically orthogonal
655 IF( ir1.EQ.0 )NOTROT = NOTROT + 1
656 PSKIPPED = PSKIPPED + 1
659 * A(:,q) is zero column
660 IF( ir1.EQ.0 )NOTROT = NOTROT + 1
661 PSKIPPED = PSKIPPED + 1
664 IF( ( i.LE.SWBAND ) .AND.
665 $ ( PSKIPPED.GT.ROWSKIP ) ) THEN
666 IF( ir1.EQ.0 )AAPP = -AAPP
675 * bailed out of q-loop
681 IF( ( ir1.EQ.0 ) .AND. ( AAPP.EQ.ZERO ) )
682 $ NOTROT = NOTROT + MIN( igl+KBL-1, N ) - p
687 * end of doing the block ( ibr, ibr )
691 *........................................................
692 * ... go to the off diagonal blocks
694 igl = ( ibr-1 )*KBL + 1
696 DO 2010 jbc = ibr + 1, NBL
698 jgl = ( jbc-1 )*KBL + 1
700 * doing the block at ( ibr, jbc )
703 DO 2100 p = igl, MIN( igl+KBL-1, N )
707 IF( AAPP.GT.ZERO ) THEN
711 DO 2200 q = jgl, MIN( jgl+KBL-1, N )
715 IF( AAQQ.GT.ZERO ) THEN
718 * -#- M x 2 Jacobi SVD -#-
720 * -#- Safe Gram matrix computation -#-
722 IF( AAQQ.GE.ONE ) THEN
723 IF( AAPP.GE.AAQQ ) THEN
724 ROTOK = ( SMALL*AAPP ).LE.AAQQ
726 ROTOK = ( SMALL*AAQQ ).LE.AAPP
728 IF( AAPP.LT.( BIG / AAQQ ) ) THEN
729 AAPQ = ( DDOT( M, A( 1, p ), 1, A( 1,
730 $ q ), 1 )*D( p )*D( q ) / AAQQ )
733 CALL DCOPY( M, A( 1, p ), 1, WORK, 1 )
734 CALL DLASCL( 'G', 0, 0, AAPP, D( p ),
735 $ M, 1, WORK, LDA, IERR )
736 AAPQ = DDOT( M, WORK, 1, A( 1, q ),
740 IF( AAPP.GE.AAQQ ) THEN
741 ROTOK = AAPP.LE.( AAQQ / SMALL )
743 ROTOK = AAQQ.LE.( AAPP / SMALL )
745 IF( AAPP.GT.( SMALL / AAQQ ) ) THEN
746 AAPQ = ( DDOT( M, A( 1, p ), 1, A( 1,
747 $ q ), 1 )*D( p )*D( q ) / AAQQ )
750 CALL DCOPY( M, A( 1, q ), 1, WORK, 1 )
751 CALL DLASCL( 'G', 0, 0, AAQQ, D( q ),
752 $ M, 1, WORK, LDA, IERR )
753 AAPQ = DDOT( M, WORK, 1, A( 1, p ),
758 MXAAPQ = MAX( MXAAPQ, DABS( AAPQ ) )
760 * TO rotate or NOT to rotate, THAT is the question ...
762 IF( DABS( AAPQ ).GT.TOL ) THEN
764 * ROTATED = ROTATED + 1
772 THETA = -HALF*DABS( AQOAP-APOAQ )/AAPQ
773 IF( AAQQ.GT.AAPP0 )THETA = -THETA
775 IF( DABS( THETA ).GT.BIGTHETA ) THEN
777 FASTR( 3 ) = T*D( p ) / D( q )
778 FASTR( 4 ) = -T*D( q ) / D( p )
779 CALL DROTM( M, A( 1, p ), 1,
780 $ A( 1, q ), 1, FASTR )
781 IF( RSVEC )CALL DROTM( MVL,
785 SVA( q ) = AAQQ*DSQRT( MAX( ZERO,
786 $ ONE+T*APOAQ*AAPQ ) )
787 AAPP = AAPP*DSQRT( MAX( ZERO,
788 $ ONE-T*AQOAP*AAPQ ) )
789 MXSINJ = MAX( MXSINJ, DABS( T ) )
792 * .. choose correct signum for THETA and rotate
794 THSIGN = -DSIGN( ONE, AAPQ )
795 IF( AAQQ.GT.AAPP0 )THSIGN = -THSIGN
796 T = ONE / ( THETA+THSIGN*
797 $ DSQRT( ONE+THETA*THETA ) )
798 CS = DSQRT( ONE / ( ONE+T*T ) )
800 MXSINJ = MAX( MXSINJ, DABS( SN ) )
801 SVA( q ) = AAQQ*DSQRT( MAX( ZERO,
802 $ ONE+T*APOAQ*AAPQ ) )
803 AAPP = AAPP*DSQRT( MAX( ZERO,
804 $ ONE-T*AQOAP*AAPQ ) )
806 APOAQ = D( p ) / D( q )
807 AQOAP = D( q ) / D( p )
808 IF( D( p ).GE.ONE ) THEN
810 IF( D( q ).GE.ONE ) THEN
812 FASTR( 4 ) = -T*AQOAP
815 CALL DROTM( M, A( 1, p ), 1,
818 IF( RSVEC )CALL DROTM( MVL,
819 $ V( 1, p ), 1, V( 1, q ),
822 CALL DAXPY( M, -T*AQOAP,
825 CALL DAXPY( M, CS*SN*APOAQ,
829 CALL DAXPY( MVL, -T*AQOAP,
841 IF( D( q ).GE.ONE ) THEN
842 CALL DAXPY( M, T*APOAQ,
845 CALL DAXPY( M, -CS*SN*AQOAP,
849 CALL DAXPY( MVL, T*APOAQ,
860 IF( D( p ).GE.D( q ) ) THEN
861 CALL DAXPY( M, -T*AQOAP,
864 CALL DAXPY( M, CS*SN*APOAQ,
880 CALL DAXPY( M, T*APOAQ,
891 $ T*APOAQ, V( 1, p ),
904 IF( AAPP.GT.AAQQ ) THEN
905 CALL DCOPY( M, A( 1, p ), 1, WORK,
907 CALL DLASCL( 'G', 0, 0, AAPP, ONE,
908 $ M, 1, WORK, LDA, IERR )
909 CALL DLASCL( 'G', 0, 0, AAQQ, ONE,
910 $ M, 1, A( 1, q ), LDA,
912 TEMP1 = -AAPQ*D( p ) / D( q )
913 CALL DAXPY( M, TEMP1, WORK, 1,
915 CALL DLASCL( 'G', 0, 0, ONE, AAQQ,
916 $ M, 1, A( 1, q ), LDA,
918 SVA( q ) = AAQQ*DSQRT( MAX( ZERO,
920 MXSINJ = MAX( MXSINJ, SFMIN )
922 CALL DCOPY( M, A( 1, q ), 1, WORK,
924 CALL DLASCL( 'G', 0, 0, AAQQ, ONE,
925 $ M, 1, WORK, LDA, IERR )
926 CALL DLASCL( 'G', 0, 0, AAPP, ONE,
927 $ M, 1, A( 1, p ), LDA,
929 TEMP1 = -AAPQ*D( q ) / D( p )
930 CALL DAXPY( M, TEMP1, WORK, 1,
932 CALL DLASCL( 'G', 0, 0, ONE, AAPP,
933 $ M, 1, A( 1, p ), LDA,
935 SVA( p ) = AAPP*DSQRT( MAX( ZERO,
937 MXSINJ = MAX( MXSINJ, SFMIN )
940 * END IF ROTOK THEN ... ELSE
942 * In the case of cancellation in updating SVA(q)
943 * .. recompute SVA(q)
944 IF( ( SVA( q ) / AAQQ )**2.LE.ROOTEPS )
946 IF( ( AAQQ.LT.ROOTBIG ) .AND.
947 $ ( AAQQ.GT.ROOTSFMIN ) ) THEN
948 SVA( q ) = DNRM2( M, A( 1, q ), 1 )*
953 CALL DLASSQ( M, A( 1, q ), 1, T,
955 SVA( q ) = T*DSQRT( AAQQ )*D( q )
958 IF( ( AAPP / AAPP0 )**2.LE.ROOTEPS ) THEN
959 IF( ( AAPP.LT.ROOTBIG ) .AND.
960 $ ( AAPP.GT.ROOTSFMIN ) ) THEN
961 AAPP = DNRM2( M, A( 1, p ), 1 )*
966 CALL DLASSQ( M, A( 1, p ), 1, T,
968 AAPP = T*DSQRT( AAPP )*D( p )
975 PSKIPPED = PSKIPPED + 1
980 PSKIPPED = PSKIPPED + 1
984 IF( ( i.LE.SWBAND ) .AND. ( IJBLSK.GE.BLSKIP ) )
990 IF( ( i.LE.SWBAND ) .AND.
991 $ ( PSKIPPED.GT.ROWSKIP ) ) THEN
1004 IF( AAPP.EQ.ZERO )NOTROT = NOTROT +
1005 $ MIN( jgl+KBL-1, N ) - jgl + 1
1006 IF( AAPP.LT.ZERO )NOTROT = 0
1012 * end of the jbc-loop
1014 *2011 bailed out of the jbc-loop
1015 DO 2012 p = igl, MIN( igl+KBL-1, N )
1016 SVA( p ) = DABS( SVA( p ) )
1020 *2000 :: end of the ibr-loop
1023 IF( ( SVA( N ).LT.ROOTBIG ) .AND. ( SVA( N ).GT.ROOTSFMIN ) )
1025 SVA( N ) = DNRM2( M, A( 1, N ), 1 )*D( N )
1029 CALL DLASSQ( M, A( 1, N ), 1, T, AAPP )
1030 SVA( N ) = T*DSQRT( AAPP )*D( N )
1033 * Additional steering devices
1035 IF( ( i.LT.SWBAND ) .AND. ( ( MXAAPQ.LE.ROOTTOL ) .OR.
1036 $ ( ISWROT.LE.N ) ) )SWBAND = i
1038 IF( ( i.GT.SWBAND+1 ) .AND. ( MXAAPQ.LT.DBLE( N )*TOL ) .AND.
1039 $ ( DBLE( N )*MXAAPQ*MXSINJ.LT.TOL ) ) THEN
1043 IF( NOTROT.GE.EMPTSW )GO TO 1994
1046 * end i=1:NSWEEP loop
1047 * #:) Reaching this point means that the procedure has comleted the given
1048 * number of iterations.
1052 * #:) Reaching this point means that during the i-th sweep all pivots were
1053 * below the given tolerance, causing early exit.
1056 * #:) INFO = 0 confirms successful iterations.
1059 * Sort the vector D.
1060 DO 5991 p = 1, N - 1
1061 q = IDAMAX( N-p+1, SVA( p ), 1 ) + p - 1
1069 CALL DSWAP( M, A( 1, p ), 1, A( 1, q ), 1 )
1070 IF( RSVEC )CALL DSWAP( MVL, V( 1, p ), 1, V( 1, q ), 1 )