SUBROUTINE ZGER(A,INT,N,NC,EMACH) C ------------------------------------------------------------------ C ZGER IS A STANDARD SUBROUTINE TO PERFORM GAUSSIAN ELIMINATION ON C A NC*NC MATRIX 'A' PRIOR TO INVERSION FOR THE MATRIX PROBLEM C WHERE THE MATRIX A MULTIPLIES A VECTOR X ON THE RIGHT: C C X*A=B C C ZGER MAKES AN LOWER DIAGONAL MATRIX AND HAS ONLY 23 PROGRAM LINES! C THIS ROUTINE DOES NOT BOTHER ABOUT ELEMENTS DIRECTLY ABOVE C THE MATRIX DIAGONAL AS THEY ARE NOT USED EXPLICITLY IN AN C ACCOMAPANYING ZSER ROUTINE. C C INT RECORDS PIVOTING DETAILS OF THE GAUSS ELIMINATION. C EMACH IS A CUTOFF ON THE MATRIX ELEMENTS C ------------------------------------------------------------------ IMPLICIT NONE C C .. SCALAR ARGUMENTS .. C INTEGER N,NC REAL*8 EMACH C C .. ARRAY ARGUMENTS .. C INTEGER INT(NC) COMPLEX*16 A(NC,NC) C C .. LOCAL SCALARS .. C INTEGER I,II,IN,J,K COMPLEX*16 YR,DUM C C .. INTRINSIC FUNCTIONS .. C * INTRINSIC ABS C ------------------------------------------------------------------ C DO 10 II=2,N I=II-1 !from 1 to N-1 YR=A(I,I) IN=I * * PIVOTING: * Finding an element with the largest magnitude in the I-th row * to the right of the matrix diagonal (I,I)-element * (including the diag. element): DO 2 J=II,N !J from I+1 to N IF(ABS(YR)-ABS(A(I,J)))1,2,2 1 YR=A(I,J) IN=J 2 CONTINUE INT(I)=IN !The largest element in the I-th row to the right of !the matrix diagonal (I,I)-element is !in the IN-th column and is denoted by YR * * Executing pivoting: IF(IN-I)3,5,3 !If IN.NE.I exchange the I-th and IN-th columns on the 3 DO 4 J=I,N !right of and including the matrix diagonal (I,I)-element DUM=A(J,I) !Only column parts below and including I-th component A(J,I)=A(J,IN) !are exchanged - the remaining are ignored. 4 A(J,IN)=DUM 5 IF(ABS(YR)-EMACH)10,10,6 * For J from I+1 to N, the A(I,J)/A(I,I) multiple of * the Ith column is subtracted from the Jth column, * as if it were the Gaussian elimination of matrix elements * in the Ith row to the right of the diagonal (I,I)-element, * but with the following differences: * 1) only the elements of the Jth column below the Ith element * are affected by the subtraction, * and * 2) the subtraction is performed if and only if both * A(I,I) and A(I,J) are sufficiently large!!! * * 3) Additionally, A(I,I) is not rescaled to 1 * 6 DO 9 J=II,N !J from I+1 to N IF(ABS(A(I,J))-EMACH)9,9,7 7 A(I,J)=A(I,J)/YR DO 8 K=II,N 8 A(K,J)=A(K,J)-A(I,J)*A(K,I) !In Jth column from I+1 to N, 9 CONTINUE !the elements above the (I+1)th !element are not affected * 10 CONTINUE !end of "column loop" RETURN END C (C) Copr. 03/2003 Alexander Moroz