function dasum ( n, dx, incx ) c*********************************************************************72 c cc DASUM takes the sum of the absolute values. c c Discussion: c c This routine uses double precision real arithmetic. c c Modified: c c 18 December 2008 c c Author: c c Jack Dongarra, Jim Bunch, Cleve Moler, Pete Stewart c c Reference: c c Jack Dongarra, Jim Bunch, Cleve Moler, Pete Stewart, c LINPACK User's Guide, c SIAM, 1979, c ISBN13: 978-0-898711-72-1, c LC: QA214.L56. c c Charles Lawson, Richard Hanson, David Kincaid, Fred Krogh, c Basic Linear Algebra Subprograms for FORTRAN usage, c ACM Transactions on Mathematical Software, c Volume 5, Number 3, pages 308-323, 1979. c c Parameters: c c Input, integer N, the number of entries in the vector. c c Input, double precision X(*), the vector to be examined. c c Input, integer INCX, the increment between successive entries of X. c INCX must not be negative. c c Output, double precision DASUM, the sum of the absolute values of X. c implicit none double precision dasum double precision dtemp double precision dx(*) integer i integer incx integer m integer n integer nincx dasum = 0.0D+00 dtemp = 0.0D+00 if( n .le. 0 ) then return end if if ( incx .le. 0 ) then return end if if ( incx .ne. 1 ) then nincx = n * incx do i = 1, nincx, incx dtemp = dtemp + dabs ( dx(i) ) end do else m = mod ( n, 6 ) do i = 1,m dtemp = dtemp + dabs ( dx(i) ) end do do i = m + 1, n, 6 dtemp = dtemp & + dabs ( dx(i) ) & + dabs ( dx(i+1) ) & + dabs ( dx(i+2) ) & + dabs ( dx(i+3) ) & + dabs ( dx(i+4) ) & + dabs ( dx(i+5) ) end do end if dasum = dtemp return end subroutine daxpy ( n, da, dx, incx, dy, incy ) c*********************************************************************72 c cc DAXPY computes constant times a vector plus a vector. c c Discussion: c c This routine uses double precision real arithmetic. c c This routine uses unrolled loops for increments equal to one. c c Modified: c c 18 December 2008 c c Author: c c Jack Dongarra c c Reference: c c Jack Dongarra, Jim Bunch, Cleve Moler, Pete Stewart, c LINPACK User's Guide, c SIAM, 1979, c ISBN13: 978-0-898711-72-1, c LC: QA214.L56. c c Charles Lawson, Richard Hanson, David Kincaid, Fred Krogh, c Basic Linear Algebra Subprograms for FORTRAN usage, c ACM Transactions on Mathematical Software, c Volume 5, Number 3, pages 308-323, 1979. c c Parameters: c c Input, integer N, the number of elements in DX and DY. c c Input, double precision DA, the multiplier of DX. c c Input, double precision DX(*), the first vector. c c Input, integer INCX, the increment between successive entries of DX. c c Input/output, double precision DY(*), the second vector. c On output, DY(*) has been replaced by DY(*) + DA * DX(*). c c Input, integer INCY, the increment between successive entries of DY. c implicit none double precision da double precision dx(*) double precision dy(*) integer i integer incx integer incy integer ix integer iy integer m integer n if ( n .le. 0 ) then return end if if ( da .eq. 0.0d0 ) then return end if if ( incx .ne. 1 .or. incy .ne. 1 ) then ix = 1 iy = 1 if ( incx .lt. 0 ) ix = (-n+1)*incx + 1 if ( incy .lt. 0 ) iy = (-n+1)*incy + 1 do i = 1, n dy(iy) = dy(iy) + da*dx(ix) ix = ix + incx iy = iy + incy end do else m = mod(n,4) do i = 1, m dy(i) = dy(i) + da*dx(i) end do do i = m + 1, n, 4 dy(i) = dy(i) + da*dx(i) dy(i + 1) = dy(i + 1) + da*dx(i + 1) dy(i + 2) = dy(i + 2) + da*dx(i + 2) dy(i + 3) = dy(i + 3) + da*dx(i + 3) end do end if return end subroutine dcopy ( n, dx, incx, dy, incy ) c*********************************************************************72 c cc DCOPY copies a vector. c c Discussion: c c This routine uses double precision real arithmetic. c c The routine uses unrolled loops for increments equal to one. c c Modified: c c 07 July 2007 c c Author: c c Jack Dongarra c c Reference: c c Jack Dongarra, Jim Bunch, Cleve Moler, Pete Stewart, c LINPACK User's Guide, c SIAM, 1979, c ISBN13: 978-0-898711-72-1, c LC: QA214.L56. c c Charles Lawson, Richard Hanson, David Kincaid, Fred Krogh, c Basic Linear Algebra Subprograms for FORTRAN usage, c ACM Transactions on Mathematical Software, c Volume 5, Number 3, pages 308-323, 1979. c c Parameters: c c Input, integer N, the number of elements in DX and DY. c c Input, double precision DX(*), the first vector. c c Input, integer INCX, the increment between successive entries of DX. c c Output, double precision DY(*), the second vector. c c Input, integer INCY, the increment between successive entries of DY. c implicit none double precision dx(*) double precision dy(*) integer i integer incx integer incy integer ix integer iy integer m integer n if ( n .le. 0 ) then return end if if(incx.eq.1.and.incy.eq.1)go to 20 c c code for unequal increments or equal increments not equal to 1 c ix = 1 iy = 1 if(incx.lt.0)ix = (-n+1)*incx + 1 if(incy.lt.0)iy = (-n+1)*incy + 1 do i = 1,n dy(iy) = dx(ix) ix = ix + incx iy = iy + incy end do return c c code for both increments equal to 1 c c c clean-up loop c 20 m = mod(n,7) do i = 1,m dy(i) = dx(i) end do do i = m + 1, n, 7 dy(i) = dx(i) dy(i + 1) = dx(i + 1) dy(i + 2) = dx(i + 2) dy(i + 3) = dx(i + 3) dy(i + 4) = dx(i + 4) dy(i + 5) = dx(i + 5) dy(i + 6) = dx(i + 6) end do return end function ddot ( n, dx, incx, dy, incy ) c*********************************************************************72 c cc DDOT forms the dot product of two vectors. c c Discussion: c c This routine uses double precision real arithmetic. c c This routine uses unrolled loops for increments equal to one. c c Modified: c c 07 July 2007 c c Author: c c Jack Dongarra c c Reference: c c Jack Dongarra, Jim Bunch, Cleve Moler, Pete Stewart, c LINPACK User's Guide, c SIAM, 1979, c ISBN13: 978-0-898711-72-1, c LC: QA214.L56. c c Charles Lawson, Richard Hanson, David Kincaid, Fred Krogh, c Basic Linear Algebra Subprograms for FORTRAN usage, c ACM Transactions on Mathematical Software, c Volume 5, Number 3, pages 308-323, 1979. c c Parameters: c c Input, integer N, the number of entries in the vectors. c c Input, double precision DX(*), the first vector. c c Input, integer INCX, the increment between successive entries in DX. c c Input, double precision DY(*), the second vector. c c Input, integer INCY, the increment between successive entries in DY. c c Output, double precision DDOT, the sum of the product of the c corresponding entries of DX and DY. c implicit none double precision ddot double precision dx(*) double precision dy(*) double precision dtemp integer i,incx,incy,ix,iy,m,n ddot = 0.0d0 dtemp = 0.0d0 if(n.le.0)return if(incx.eq.1.and.incy.eq.1)go to 20 c c code for unequal increments or equal increments not equal to 1 c ix = 1 iy = 1 if(incx.lt.0)ix = (-n+1)*incx + 1 if(incy.lt.0)iy = (-n+1)*incy + 1 do i = 1,n dtemp = dtemp + dx(ix)*dy(iy) ix = ix + incx iy = iy + incy end do ddot = dtemp return c c code for both increments equal to 1 c c c clean-up loop c 20 m = mod(n,5) if( m .eq. 0 ) go to 40 do i = 1,m dtemp = dtemp + dx(i)*dy(i) end do if( n .lt. 5 ) go to 60 40 continue do i = m+1, n, 5 dtemp = dtemp + dx(i)*dy(i) + dx(i + 1)*dy(i + 1) + & dx(i + 2)*dy(i + 2) + dx(i + 3)*dy(i + 3) + dx(i + 4)*dy(i + 4) end do 60 ddot = dtemp return end function dmach ( job ) c*********************************************************************72 c cc DMACH computes machine parameters of floating point arithmetic. c c Discussion: c c This routine uses double precision real arithmetic. c c Assume the computer has c c B = base of arithmetic; c T = number of base B digits; c L = smallest possible exponent; c U = largest possible exponent; c c then c c EPS = B**(1-T) c TINY = 100.0 * B**(-L+T) c HUGE = 0.01 * B**(U-T) c c Modified: c c 07 July 2007 c c Reference: c c Jack Dongarra, Jim Bunch, Cleve Moler, Pete Stewart, c LINPACK User's Guide, c SIAM, 1979, c ISBN13: 978-0-898711-72-1, c LC: QA214.L56. c c Charles Lawson, Richard Hanson, David Kincaid, Fred Krogh, c Basic Linear Algebra Subprograms for FORTRAN usage, c ACM Transactions on Mathematical Software, c Volume 5, Number 3, pages 308-323, 1979. c c Parameters: c c Input, integer JOB: c 1, EPS is desired; c 2, TINY is desired; c 3, HUGE is desired. c c Output, double precision DMACH, the requested value. c implicit none double precision dmach integer job double precision eps,tiny,huge,s eps = 1.0d0 10 eps = eps/2.0d0 s = 1.0d0 + eps if (s .gt. 1.0d0) go to 10 eps = 2.0d0*eps s = 1.0d0 20 tiny = s s = s/16.0d0 if (s*1.0 .ne. 0.0d0) go to 20 tiny = (tiny/eps)*100.0 huge = 1.0d0/tiny if (job .eq. 1) dmach = eps if (job .eq. 2) dmach = tiny if (job .eq. 3) dmach = huge return end function dnrm2 ( n, x, incx ) c*********************************************************************72 c cc DNRM2 returns the euclidean norm of a vector. c c Discussion: c c This routine uses double precision real arithmetic. c c DNRM2 ( X ) = sqrt ( X' * X ) c c Author: c c Sven Hammarling c c Reference: c c Jack Dongarra, Jim Bunch, Cleve Moler, Pete Stewart, c LINPACK User's Guide, c SIAM, 1979, c ISBN13: 978-0-898711-72-1, c LC: QA214.L56. c c Charles Lawson, Richard Hanson, David Kincaid, Fred Krogh, c Basic Linear Algebra Subprograms for FORTRAN usage, c ACM Transactions on Mathematical Software, c Volume 5, Number 3, pages 308-323, 1979. c c Parameters: c c Input, integer N, the number of entries in the vector. c c Input, double precision X(*), the vector whose norm is to be computed. c c Input, integer INCX, the increment between successive entries of X. c c Output, double precision DNRM2, the Euclidean norm of X. c implicit none integer incx, n double precision dnrm2 double precision x( * ) double precision one , zero parameter ( one = 1.0d+0, zero = 0.0d+0 ) integer ix double precision absxi, norm, scale, ssq intrinsic abs, sqrt if( n.lt.1 .or. incx.lt.1 )then norm = zero else if( n.eq.1 )then norm = abs( x( 1 ) ) else scale = zero ssq = one c c The following loop is equivalent to this call to the LAPACK c auxiliary routine: c call dlassq( n, x, incx, scale, ssq ) c do ix = 1, 1 + ( n - 1 )*incx, incx if( x( ix ).ne.zero )then absxi = abs( x( ix ) ) if( scale.lt.absxi )then ssq = one + ssq*( scale/absxi )**2 scale = absxi else ssq = ssq + ( absxi/scale )**2 end if end if end do norm = scale * sqrt( ssq ) end if dnrm2 = norm return end subroutine drot ( n, dx, incx, dy, incy, c, s ) c*********************************************************************72 c cc DROT applies a plane rotation. c c Discussion: c c This routine uses double precision real arithmetic. c c Modified: c c 07 July 2007 c c Author: c c Jack Dongarra c c Reference: c c Jack Dongarra, Jim Bunch, Cleve Moler, Pete Stewart, c LINPACK User's Guide, c SIAM, 1979, c ISBN13: 978-0-898711-72-1, c LC: QA214.L56. c c Charles Lawson, Richard Hanson, David Kincaid, Fred Krogh, c Basic Linear Algebra Subprograms for FORTRAN usage, c ACM Transactions on Mathematical Software, c Volume 5, Number 3, pages 308-323, 1979. c c Parameters: c c Input, integer N, the number of entries in the vectors. c c Input/output, double precision X(*), one of the vectors to be rotated. c c Input, integer INCX, the increment between successive entries of X. c c Input/output, double precision Y(*), one of the vectors to be rotated. c c Input, integer INCY, the increment between successive elements of Y. c c Input, double precision C, S, parameters (presumably the cosine and c sine of some angle) that define a plane rotation. c implicit none double precision dx(*),dy(*),dtemp,c,s integer i,incx,incy,ix,iy,n if(n.le.0)return if(incx.eq.1.and.incy.eq.1)go to 20 c c code for unequal increments or equal increments not equal to 1 c ix = 1 iy = 1 if(incx.lt.0)ix = (-n+1)*incx + 1 if(incy.lt.0)iy = (-n+1)*incy + 1 do i = 1,n dtemp = c*dx(ix) + s*dy(iy) dy(iy) = c*dy(iy) - s*dx(ix) dx(ix) = dtemp ix = ix + incx iy = iy + incy end do return c c code for both increments equal to 1 c 20 do i = 1,n dtemp = c*dx(i) + s*dy(i) dy(i) = c*dy(i) - s*dx(i) dx(i) = dtemp end do return end subroutine drotg ( da, db, c, s ) c*********************************************************************72 c cc DROTG constructs a Givens plane rotation. c c Discussion: c c This routine uses double precision real arithmetic. c c Given values A and B, this routine computes c c SIGMA = sign ( A ) if abs ( A ) > abs ( B ) c = sign ( B ) if abs ( A ) <= abs ( B ); c c R = SIGMA * ( A * A + B * B ); c c C = A / R if R is not 0 c = 1 if R is 0; c c S = B / R if R is not 0, c 0 if R is 0. c c The computed numbers then satisfy the equation c c ( C S ) ( A ) = ( R ) c ( -S C ) ( B ) = ( 0 ) c c The routine also computes c c Z = S if abs ( A ) > abs ( B ), c = 1 / C if abs ( A ) <= abs ( B ) and C is not 0, c = 1 if C is 0. c c The single value Z encodes C and S, and hence the rotation: c c If Z = 1, set C = 0 and S = 1; c If abs ( Z ) < 1, set C = sqrt ( 1 - Z * Z ) and S = Z; c if abs ( Z ) > 1, set C = 1/ Z and S = sqrt ( 1 - C * C ); c c Modified: c c 07 July 2007 c c Author: c c Jack Dongarra c c Reference: c c Jack Dongarra, Jim Bunch, Cleve Moler, Pete Stewart, c LINPACK User's Guide, c SIAM, 1979, c ISBN13: 978-0-898711-72-1, c LC: QA214.L56. c c Charles Lawson, Richard Hanson, David Kincaid, Fred Krogh, c Basic Linear Algebra Subprograms for FORTRAN usage, c ACM Transactions on Mathematical Software, c Volume 5, Number 3, pages 308-323, 1979. c c Parameters: c c Input/output, double precision SA, SB. On input, SA and SB are the values c A and B. On output, SA is overwritten with R, and SB is c overwritten with Z. c c Output, double precision C, S, the cosine and sine of the c Givens rotation. c implicit none double precision da,db,c,s,roe,scale,r,z roe = db if( dabs(da) .gt. dabs(db) ) roe = da scale = dabs(da) + dabs(db) if( scale .eq. 0.0d0 ) then c = 1.0d0 s = 0.0d0 r = 0.0d0 z = 0.0d0 else r = scale*dsqrt((da/scale)**2 + (db/scale)**2) r = dsign(1.0d0,roe)*r c = da/r s = db/r z = 1.0d0 if( dabs(da) .gt. dabs(db) ) z = s if( dabs(db) .ge. dabs(da) .and. c .ne. 0.0d0 ) z = 1.0d0/c end if da = r db = z return end SUBROUTINE DROTM(N,DX,INCX,DY,INCY,DPARAM) cc DROTM applies a modified Givens rotation matrix. * .. Scalar Arguments .. INTEGER INCX,INCY,N * .. * .. Array Arguments .. DOUBLE PRECISION DPARAM(5),DX(*),DY(*) * .. * * Purpose * ======= * * APPLY THE MODIFIED GIVENS TRANSFORMATION, H, TO THE 2 BY N MATRIX * * (DX**T) , WHERE **T INDICATES TRANSPOSE. THE ELEMENTS OF DX ARE IN * (DY**T) * * DX(LX+I*INCX), I = 0 TO N-1, WHERE LX = 1 IF INCX .GE. 0, ELSE * LX = (-INCX)*N, AND SIMILARLY FOR SY USING LY AND INCY. * WITH DPARAM(1)=DFLAG, H HAS ONE OF THE FOLLOWING FORMS.. * * DFLAG=-1.D0 DFLAG=0.D0 DFLAG=1.D0 DFLAG=-2.D0 * * (DH11 DH12) (1.D0 DH12) (DH11 1.D0) (1.D0 0.D0) * H=( ) ( ) ( ) ( ) * (DH21 DH22), (DH21 1.D0), (-1.D0 DH22), (0.D0 1.D0). * SEE DROTMG FOR A DESCRIPTION OF DATA STORAGE IN DPARAM. * * Arguments * ========= * * N (input) INTEGER * number of elements in input vector(s) * * DX (input/output) DOUBLE PRECISION array, dimension N * double precision vector with N elements * * INCX (input) INTEGER * storage spacing between elements of DX * * DY (input/output) DOUBLE PRECISION array, dimension N * double precision vector with N elements * * INCY (input) INTEGER * storage spacing between elements of DY * * DPARAM (input/output) DOUBLE PRECISION array, dimension 5 * DPARAM(1)=DFLAG * DPARAM(2)=DH11 * DPARAM(3)=DH21 * DPARAM(4)=DH12 * DPARAM(5)=DH22 * * ===================================================================== * * .. Local Scalars .. DOUBLE PRECISION DFLAG,DH11,DH12,DH21,DH22,TWO,W,Z,ZERO INTEGER I,KX,KY,NSTEPS * .. * .. Data statements .. DATA ZERO,TWO/0.D0,2.D0/ * .. * DFLAG = DPARAM(1) IF (N.LE.0 .OR. (DFLAG+TWO.EQ.ZERO)) RETURN IF (INCX.EQ.INCY.AND.INCX.GT.0) THEN * NSTEPS = N*INCX IF (DFLAG.LT.ZERO) THEN DH11 = DPARAM(2) DH12 = DPARAM(4) DH21 = DPARAM(3) DH22 = DPARAM(5) DO I = 1,NSTEPS,INCX W = DX(I) Z = DY(I) DX(I) = W*DH11 + Z*DH12 DY(I) = W*DH21 + Z*DH22 END DO ELSE IF (DFLAG.EQ.ZERO) THEN DH12 = DPARAM(4) DH21 = DPARAM(3) DO I = 1,NSTEPS,INCX W = DX(I) Z = DY(I) DX(I) = W + Z*DH12 DY(I) = W*DH21 + Z END DO ELSE DH11 = DPARAM(2) DH22 = DPARAM(5) DO I = 1,NSTEPS,INCX W = DX(I) Z = DY(I) DX(I) = W*DH11 + Z DY(I) = -W + DH22*Z END DO END IF ELSE KX = 1 KY = 1 IF (INCX.LT.0) KX = 1 + (1-N)*INCX IF (INCY.LT.0) KY = 1 + (1-N)*INCY * IF (DFLAG.LT.ZERO) THEN DH11 = DPARAM(2) DH12 = DPARAM(4) DH21 = DPARAM(3) DH22 = DPARAM(5) DO I = 1,N W = DX(KX) Z = DY(KY) DX(KX) = W*DH11 + Z*DH12 DY(KY) = W*DH21 + Z*DH22 KX = KX + INCX KY = KY + INCY END DO ELSE IF (DFLAG.EQ.ZERO) THEN DH12 = DPARAM(4) DH21 = DPARAM(3) DO I = 1,N W = DX(KX) Z = DY(KY) DX(KX) = W + Z*DH12 DY(KY) = W*DH21 + Z KX = KX + INCX KY = KY + INCY END DO ELSE DH11 = DPARAM(2) DH22 = DPARAM(5) DO I = 1,N W = DX(KX) Z = DY(KY) DX(KX) = W*DH11 + Z DY(KY) = -W + DH22*Z KX = KX + INCX KY = KY + INCY END DO END IF END IF RETURN END SUBROUTINE DROTMG(DD1,DD2,DX1,DY1,DPARAM) cc DROTMG generates a modified Givens rotation matrix. * .. Scalar Arguments .. DOUBLE PRECISION DD1,DD2,DX1,DY1 * .. * .. Array Arguments .. DOUBLE PRECISION DPARAM(5) * .. * * Purpose * ======= * * CONSTRUCT THE MODIFIED GIVENS TRANSFORMATION MATRIX H WHICH ZEROS * THE SECOND COMPONENT OF THE 2-VECTOR (DSQRT(DD1)*DX1,DSQRT(DD2)* * DY2)**T. * WITH DPARAM(1)=DFLAG, H HAS ONE OF THE FOLLOWING FORMS.. * * DFLAG=-1.D0 DFLAG=0.D0 DFLAG=1.D0 DFLAG=-2.D0 * * (DH11 DH12) (1.D0 DH12) (DH11 1.D0) (1.D0 0.D0) * H=( ) ( ) ( ) ( ) * (DH21 DH22), (DH21 1.D0), (-1.D0 DH22), (0.D0 1.D0). * LOCATIONS 2-4 OF DPARAM CONTAIN DH11, DH21, DH12, AND DH22 * RESPECTIVELY. (VALUES OF 1.D0, -1.D0, OR 0.D0 IMPLIED BY THE * VALUE OF DPARAM(1) ARE NOT STORED IN DPARAM.) * * THE VALUES OF GAMSQ AND RGAMSQ SET IN THE DATA STATEMENT MAY BE * INEXACT. THIS IS OK AS THEY ARE ONLY USED FOR TESTING THE SIZE * OF DD1 AND DD2. ALL ACTUAL SCALING OF DATA IS DONE USING GAM. * * * Arguments * ========= * * DD1 (input/output) DOUBLE PRECISION * * DD2 (input/output) DOUBLE PRECISION * * DX1 (input/output) DOUBLE PRECISION * * DY1 (input) DOUBLE PRECISION * * DPARAM (input/output) DOUBLE PRECISION array, dimension 5 * DPARAM(1)=DFLAG * DPARAM(2)=DH11 * DPARAM(3)=DH21 * DPARAM(4)=DH12 * DPARAM(5)=DH22 * * ===================================================================== * * .. Local Scalars .. DOUBLE PRECISION DFLAG,DH11,DH12,DH21,DH22,DP1,DP2,DQ1,DQ2,DTEMP, $ DU,GAM,GAMSQ,ONE,RGAMSQ,TWO,ZERO * .. * .. Intrinsic Functions .. INTRINSIC DABS * .. * .. Data statements .. * DATA ZERO,ONE,TWO/0.D0,1.D0,2.D0/ DATA GAM,GAMSQ,RGAMSQ/4096.D0,16777216.D0,5.9604645D-8/ * .. IF (DD1.LT.ZERO) THEN * GO ZERO-H-D-AND-DX1.. DFLAG = -ONE DH11 = ZERO DH12 = ZERO DH21 = ZERO DH22 = ZERO * DD1 = ZERO DD2 = ZERO DX1 = ZERO ELSE * CASE-DD1-NONNEGATIVE DP2 = DD2*DY1 IF (DP2.EQ.ZERO) THEN DFLAG = -TWO DPARAM(1) = DFLAG RETURN END IF * REGULAR-CASE.. DP1 = DD1*DX1 DQ2 = DP2*DY1 DQ1 = DP1*DX1 * IF (DABS(DQ1).GT.DABS(DQ2)) THEN DH21 = -DY1/DX1 DH12 = DP2/DP1 * DU = ONE - DH12*DH21 * IF (DU.GT.ZERO) THEN DFLAG = ZERO DD1 = DD1/DU DD2 = DD2/DU DX1 = DX1*DU END IF ELSE IF (DQ2.LT.ZERO) THEN * GO ZERO-H-D-AND-DX1.. DFLAG = -ONE DH11 = ZERO DH12 = ZERO DH21 = ZERO DH22 = ZERO * DD1 = ZERO DD2 = ZERO DX1 = ZERO ELSE DFLAG = ONE DH11 = DP1/DP2 DH22 = DX1/DY1 DU = ONE + DH11*DH22 DTEMP = DD2/DU DD2 = DD1/DU DD1 = DTEMP DX1 = DY1*DU END IF END IF * PROCEDURE..SCALE-CHECK IF (DD1.NE.ZERO) THEN DO WHILE ((DD1.LE.RGAMSQ) .OR. (DD1.GE.GAMSQ)) IF (DFLAG.EQ.ZERO) THEN DH11 = ONE DH22 = ONE DFLAG = -ONE ELSE DH21 = -ONE DH12 = ONE DFLAG = -ONE END IF IF (DD1.LE.RGAMSQ) THEN DD1 = DD1*GAM**2 DX1 = DX1/GAM DH11 = DH11/GAM DH12 = DH12/GAM ELSE DD1 = DD1/GAM**2 DX1 = DX1*GAM DH11 = DH11*GAM DH12 = DH12*GAM END IF ENDDO END IF IF (DD2.NE.ZERO) THEN DO WHILE ( (DABS(DD2).LE.RGAMSQ) .OR. (DABS(DD2).GE.GAMSQ) ) IF (DFLAG.EQ.ZERO) THEN DH11 = ONE DH22 = ONE DFLAG = -ONE ELSE DH21 = -ONE DH12 = ONE DFLAG = -ONE END IF IF (DABS(DD2).LE.RGAMSQ) THEN DD2 = DD2*GAM**2 DH21 = DH21/GAM DH22 = DH22/GAM ELSE DD2 = DD2/GAM**2 DH21 = DH21*GAM DH22 = DH22*GAM END IF END DO END IF END IF IF (DFLAG.LT.ZERO) THEN DPARAM(2) = DH11 DPARAM(3) = DH21 DPARAM(4) = DH12 DPARAM(5) = DH22 ELSE IF (DFLAG.EQ.ZERO) THEN DPARAM(3) = DH21 DPARAM(4) = DH12 ELSE DPARAM(2) = DH11 DPARAM(5) = DH22 END IF 260 CONTINUE DPARAM(1) = DFLAG RETURN END subroutine dscal ( n, da, dx, incx ) c*********************************************************************72 c cc DSCAL scales a vector by a constant. c c Discussion: c c This routine uses double precision real arithmetic. c c Modified: c c 07 July 2007 c c Author: c c Jack Dongarra c c Reference: c c Jack Dongarra, Jim Bunch, Cleve Moler, Pete Stewart, c LINPACK User's Guide, c SIAM, 1979, c ISBN13: 978-0-898711-72-1, c LC: QA214.L56. c c Charles Lawson, Richard Hanson, David Kincaid, Fred Krogh, c Basic Linear Algebra Subprograms for FORTRAN usage, c ACM Transactions on Mathematical Software, c Volume 5, Number 3, pages 308-323, 1979. c c Parameters: c c Input, integer N, the number of entries in the vector. c c Input, double precision SA, the multiplier. c c Input/output, double precision X(*), the vector to be scaled. c c Input, integer INCX, the increment between successive entries of X. c implicit none double precision da double precision dx(*) integer i,incx,m,n,nincx if( n.le.0 .or. incx.le.0 )return if(incx.eq.1)go to 20 c c code for increment not equal to 1 c nincx = n*incx do i = 1,nincx,incx dx(i) = da*dx(i) end do return c c code for increment equal to 1 c c c clean-up loop c 20 m = mod(n,5) if( m .eq. 0 ) go to 40 do i = 1,m dx(i) = da*dx(i) end do if( n .lt. 5 ) return 40 continue do i = m+1, n, 5 dx(i) = da*dx(i) dx(i + 1) = da*dx(i + 1) dx(i + 2) = da*dx(i + 2) dx(i + 3) = da*dx(i + 3) dx(i + 4) = da*dx(i + 4) end do return end DOUBLE PRECISION FUNCTION DSDOT(N,SX,INCX,SY,INCY) cc DSDOT computes the inner product of two vectors with extended precision. * .. Scalar Arguments .. INTEGER INCX,INCY,N * .. * .. Array Arguments .. REAL SX(*),SY(*) * .. * * AUTHORS * ======= * Lawson, C. L., (JPL), Hanson, R. J., (SNLA), * Kincaid, D. R., (U. of Texas), Krogh, F. T., (JPL) * * Purpose * ======= * Compute the inner product of two vectors with extended * precision accumulation and result. * * Returns D.P. dot product accumulated in D.P., for S.P. SX and SY * DSDOT = sum for I = 0 to N-1 of SX(LX+I*INCX) * SY(LY+I*INCY), * where LX = 1 if INCX .GE. 0, else LX = 1+(1-N)*INCX, and LY is * defined in a similar way using INCY. * * Arguments * ========= * * N (input) INTEGER * number of elements in input vector(s) * * SX (input) REAL array, dimension(N) * single precision vector with N elements * * INCX (input) INTEGER * storage spacing between elements of SX * * SY (input) REAL array, dimension(N) * single precision vector with N elements * * INCY (input) INTEGER * storage spacing between elements of SY * * DSDOT (output) DOUBLE PRECISION * DSDOT double precision dot product (zero if N.LE.0) * * Further Details * =============== * * REFERENCES * * C. L. Lawson, R. J. Hanson, D. R. Kincaid and F. T. * Krogh, Basic linear algebra subprograms for Fortran * usage, Algorithm No. 539, Transactions on Mathematical * Software 5, 3 (September 1979), pp. 308-323. * * REVISION HISTORY (YYMMDD) * * 791001 DATE WRITTEN * 890831 Modified array declarations. (WRB) * 890831 REVISION DATE from Version 3.2 * 891214 Prologue converted to Version 4.0 format. (BAB) * 920310 Corrected definition of LX in DESCRIPTION. (WRB) * 920501 Reformatted the REFERENCES section. (WRB) * 070118 Reformat to LAPACK style (JL) * * ===================================================================== * * .. Local Scalars .. INTEGER I,KX,KY,NS * .. * .. Intrinsic Functions .. INTRINSIC DBLE * .. DSDOT = 0.0D0 IF (N.LE.0) RETURN IF (INCX.EQ.INCY .AND. INCX.GT.0) THEN * * Code for equal, positive, non-unit increments. * NS = N*INCX DO I = 1,NS,INCX DSDOT = DSDOT + DBLE(SX(I))*DBLE(SY(I)) END DO ELSE * * Code for unequal or nonpositive increments. * KX = 1 KY = 1 IF (INCX.LT.0) KX = 1 + (1-N)*INCX IF (INCY.LT.0) KY = 1 + (1-N)*INCY DO I = 1,N DSDOT = DSDOT + DBLE(SX(KX))*DBLE(SY(KY)) KX = KX + INCX KY = KY + INCY END DO END IF RETURN END subroutine dswap ( n, dx, incx, dy, incy ) c*********************************************************************72 c cc DSWAP interchanges two vectors. c c Discussion: c c This routine uses double precision real arithmetic. c c Modified: c c 07 July 2007 c c Author: c c Jack Dongarra c c Reference: c c Jack Dongarra, Jim Bunch, Cleve Moler, Pete Stewart, c LINPACK User's Guide, c SIAM, 1979, c ISBN13: 978-0-898711-72-1, c LC: QA214.L56. c c Charles Lawson, Richard Hanson, David Kincaid, Fred Krogh, c Basic Linear Algebra Subprograms for FORTRAN usage, c ACM Transactions on Mathematical Software, c Volume 5, Number 3, pages 308-323, 1979. c c Parameters: c c Input, integer N, the number of entries in the vectors. c c Input/output, double precision X(*), one of the vectors to swap. c c Input, integer INCX, the increment between successive entries of X. c c Input/output, double precision Y(*), one of the vectors to swap. c c Input, integer INCY, the increment between successive elements of Y. c implicit none double precision dx(*),dy(*),dtemp integer i,incx,incy,ix,iy,m,n if(n.le.0)return if(incx.eq.1.and.incy.eq.1)go to 20 c c code for unequal increments or equal increments not equal to 1 c ix = 1 iy = 1 if(incx.lt.0)ix = (-n+1)*incx + 1 if(incy.lt.0)iy = (-n+1)*incy + 1 do i = 1,n dtemp = dx(ix) dx(ix) = dy(iy) dy(iy) = dtemp ix = ix + incx iy = iy + incy end do return c c code for both increments equal to 1 c c c clean-up loop c 20 m = mod(n,3) if( m .eq. 0 ) go to 40 do i = 1,m dtemp = dx(i) dx(i) = dy(i) dy(i) = dtemp end do if( n .lt. 3 ) return 40 continue do i = m+1, n, 3 dtemp = dx(i) dx(i) = dy(i) dy(i) = dtemp dtemp = dx(i + 1) dx(i + 1) = dy(i + 1) dy(i + 1) = dtemp dtemp = dx(i + 2) dx(i + 2) = dy(i + 2) dy(i + 2) = dtemp end do return end function idamax ( n, dx, incx ) c*********************************************************************72 c cc IDAMAX finds the index of element having maximum absolute value. c c Discussion: c c This routine uses double precision real arithmetic. c c Modified: c c 07 July 2007 c c Author: c c Jack Dongarra c c Reference: c c Jack Dongarra, Jim Bunch, Cleve Moler, Pete Stewart, c LINPACK User's Guide, c SIAM, 1979, c ISBN13: 978-0-898711-72-1, c LC: QA214.L56. c c Charles Lawson, Richard Hanson, David Kincaid, Fred Krogh, c Basic Linear Algebra Subprograms for FORTRAN usage, c ACM Transactions on Mathematical Software, c Volume 5, Number 3, pages 308-323, 1979. c c Parameters: c c Input, integer N, the number of entries in the vector. c c Input, double precision X(*), the vector to be examined. c c Input, integer INCX, the increment between successive entries of SX. c c Output, integer IDAMAX, the index of the element of SX of maximum c absolute value. c implicit none double precision dx(*),dmax integer idamax integer i,incx,ix,n idamax = 0 if( n.lt.1 .or. incx.le.0 ) return idamax = 1 if(n.eq.1)return if(incx.eq.1)go to 20 c c code for increment not equal to 1 c ix = 1 dmax = dabs(dx(1)) ix = ix + incx do i = 2,n if ( dmax .lt. dabs ( dx(ix) ) ) then idamax = i dmax = dabs(dx(ix)) end if ix = ix + incx end do return c c code for increment equal to 1 c 20 dmax = dabs(dx(1)) do i = 2,n if( dmax .lt. dabs(dx(i)) ) then idamax = i dmax = dabs(dx(i)) end if end do return end function lsame ( ca, cb ) c*********************************************************************72 c cc LSAME returns TRUE if CA is the same letter as CB regardless of case. c c Modified: c c 07 July 2007 c c Reference: c c Jack Dongarra, Jim Bunch, Cleve Moler, Pete Stewart, c LINPACK User's Guide, c SIAM, 1979, c ISBN13: 978-0-898711-72-1, c LC: QA214.L56. c c Charles Lawson, Richard Hanson, David Kincaid, Fred Krogh, c Basic Linear Algebra Subprograms for FORTRAN usage, c ACM Transactions on Mathematical Software, c Volume 5, Number 3, pages 308-323, 1979. c c Parameters: c c Input, character CA, CB, the character to compare. c c Output, logical LSAME, is TRUE if the characters are equal, c disregarding case. c implicit none character ca, cb logical lsame intrinsic ichar integer inta, intb, zcode c c Test if the characters are equal c lsame = ca.eq.cb if( lsame ) then return end if c c Now test for equivalence if both characters are alphabetic. c zcode = ichar( 'Z' ) c c Use 'Z' rather than 'A' so that ASCII can be detected on Prime c machines, on which ICHAR returns a value with bit 8 set. c ICHAR('A') on Prime machines returns 193 which is the same as c ICHAR('A') on an EBCDIC machine. c inta = ichar( ca ) intb = ichar( cb ) if( zcode.eq.90 .or. zcode.eq.122 ) then c c ASCII is assumed - ZCODE is the ASCII code of either lower or c upper case 'Z'. c if( inta.ge.97 .and. inta.le.122 ) inta = inta - 32 if( intb.ge.97 .and. intb.le.122 ) intb = intb - 32 else if( zcode.eq.233 .or. zcode.eq.169 ) then c c EBCDIC is assumed - ZCODE is the EBCDIC code of either lower or c upper case 'Z'. c if( inta.ge.129 .and. inta.le.137 .or. & inta.ge.145 .and. inta.le.153 .or. & inta.ge.162 .and. inta.le.169 ) inta = inta + 64 if( intb.ge.129 .and. intb.le.137 .or. & intb.ge.145 .and. intb.le.153 .or. & intb.ge.162 .and. intb.le.169 ) intb = intb + 64 else if( zcode.eq.218 .or. zcode.eq.250 ) then c c ASCII is assumed, on Prime machines - ZCODE is the ASCII code c plus 128 of either lower or upper case 'Z'. c if( inta.ge.225 .and. inta.le.250 ) inta = inta - 32 if( intb.ge.225 .and. intb.le.250 ) intb = intb - 32 end if lsame = inta.eq.intb return end subroutine xerbla ( srname, info ) c*********************************************************************72 c cc XERBLA is an error handler. c c Discussion: c c XERBLA is called if an input parameter has an invalid value. c A message is printed and execution stops. c c Modified: c c 07 July 2007 c c Reference: c c Jack Dongarra, Jim Bunch, Cleve Moler, Pete Stewart, c LINPACK User's Guide, c SIAM, 1979, c ISBN13: 978-0-898711-72-1, c LC: QA214.L56. c c Charles Lawson, Richard Hanson, David Kincaid, Fred Krogh, c Basic Linear Algebra Subprograms for FORTRAN usage, c ACM Transactions on Mathematical Software, c Volume 5, Number 3, pages 308-323, 1979. c c Parameters: c c Input, character*6 SRNAME, the name of the routine which called XERBLA. c c Input, integer INFO, the position of the invalid parameter in the c parameter list of the calling routine. c implicit none integer info character*6 srname write ( *, '(a,a6,a,i2,a)' ) ' ** On entry to ', srname, & ' parameter number ', info, ' had an illegal value.' stop end