This subroutine solves a symmetric, positive definite or negative definite linear system, using the two-term conjugate gradient method, with or without preconditioning by an incomplete Cholesky factorization, for a sparse matrix stored in compressed-diagonal storage mode. Matrix A and vectors x and b are used:
where A, x, and b contain long-precision real numbers.
Fortran | CALL DSDCG (iopt, m, nd, ad, lda, la, b, x, iparm, rparm, aux1, naux1, aux2, naux2) |
C and C++ | dsdcg (iopt, m, nd, ad, lda, la, b, x, iparm, rparm, aux1, naux1, aux2, naux2); |
PL/I | CALL DSDCG (iopt, m, nd, ad, lda, la, b, x, iparm, rparm, aux1, naux1, aux2, naux2); |
If iopt = 0, all the nonzero diagonals of the sparse matrix are stored in compressed-diagonal storage mode.
If iopt = 1, the sparse matrix, stored in compressed-diagonal storage mode, is symmetric. Only the main diagonal and one of each pair of identical diagonals are stored in array AD.
Specified as: a fullword integer; iopt = 0 or 1.
If m > 0, then nd > 0.
If m = 0, then nd >= 0.
Specified as: an lda by (at least) nd array, containing long-precision real numbers.
Specified as: a one-dimensional array of (at least) length nd, containing fullword integers, where 1-m <= (elements of LA) <= m-1.
If IPARM(1) > 0, IPARM(1) is the maximum number of iterations allowed.
If IPARM(1) = 0, the following default values are used:
If IPARM(2) = 0, the conjugate gradient iterative procedure is stopped when:
where r = b-Ax is the residual and epsilon is the desired relative accuracy. epsilon is stored in RPARM(1).
If IPARM(2) = 1, the conjugate gradient iterative procedure is stopped when:
where lambda is an estimate to the minimum eigenvalue of the iteration matrix. lambda is computed adaptively by this program and, on output, is stored in RPARM(2).
If IPARM(2) = 2, the conjugate gradient iterative procedure is stopped when:
where lambda is a predetermined estimate to the minimum eigenvalue of the iteration matrix. This eigenvalue estimate, on input, is stored in RPARM(2) and may be obtained by an earlier call to this subroutine with the same matrix.
If IPARM(3) = 0, the system is not preconditioned.
If IPARM(3) = 10, the system is preconditioned by an incomplete Cholesky factorization.
If IPARM(3) = -10, the system is preconditioned by an incomplete Cholesky factorization, where the factorization matrix was computed in an earlier call to this subroutine and is stored in aux2.
Specified as: an array of (at least) length 4, containing fullword integers, where:
RPARM(1) > 0, is the relative accuracy epsilon used in the stopping criterion.
RPARM(2) > 0, is the estimate of the smallest eigenvalue, lambda, of the iteration matrix. It is only used when IPARM(2) = 2.
RPARM(3), see On Return.
Specified as: a one-dimensional array of (at least) length 3, containing long-precision real numbers.
If naux1 = 0 and error 2015 is unrecoverable, aux1 is ignored.
Otherwise, it is a storage work area used by this subroutine, which is available for use by the calling program between calls to this subroutine. Its size is specified by naux1.
Specified as: an area of storage, containing long-precision real numbers.
Specified as: a fullword integer, where:
If naux = 0 and error 2015 is unrecoverable, DSDCG dynamically allocates the work area used by this subroutine. The work area is deallocated before control is returned to the calling program.
Otherwise, it must have at least the following value, where:
If IPARM(2) = 0 or 2, use naux1 >= 3m.
If IPARM(2) = 1 and IPARM(1) <> 0, use naux1 >= 3m+2(IPARM(1)).
If IPARM(2) = 1 and IPARM(1) = 0, use naux1 >= 3m+600.
If iopt = 0, use naux2 >= m(1.5nd+2)1.5+2(m+6).
If iopt = 1, use naux2 >= m(3nd+2)+8.
IPARM(1) is unchanged.
IPARM(2) is unchanged.
IPARM(3) is unchanged.
IPARM(4) contains the number of iterations performed by this subroutine.
Returned as: a one-dimensional array of length 4, containing fullword integers.
RPARM(1) is unchanged.
RPARM(2) is unchanged if IPARM(2) = 0 or 2. If IPARM(2) = 1, RPARM(2) contains lambda, an estimate of the smallest eigenvalue of the iteration matrix.
RPARM(3) contains the estimate of the error of the solution. If the process converged, RPARM(3) <= epsilon.
Returned as: a one-dimensional array of length 3, containing long-precision real numbers; lambda > 0.
If IPARM(3) = 10, aux2 contains the incomplete Cholesky factorization of matrix A.
If IPARM(3) = -10, aux2 is unchanged.
See Notes for additional information on aux2. Returned as: an area of storage, containing long-precision real numbers.
where lambda is an estimate of the minimum eigenvalue of the iteration matrix, which is either estimated adaptively or given by the user. As a result, if you specify a larger epsilon, the algorithm takes fewer iterations to converge to a solution. If you specify a smaller epsilon, the algorithm requires more iterations and computer time, but converges to a more precise solution. If the value you specify is unreasonably small, the algorithm may fail to converge within the number of iterations it is allowed to perform.
The sparse positive definite or negative definite linear system:
is solved, where:
The system is solved using the two-term conjugate gradient method, with or without preconditioning by an incomplete Cholesky factorization. In both cases, the matrix is scaled by the square root of the diagonal.
See references [62] and [68]. [36].
Error 2015 is unrecoverable, naux1 = 0, and unable to allocate work area.
The following errors, with their corresponding return codes, can occur in this subroutine. Where a value of i is indicated, it can be determined at run time by use of the ESSL error-handling facilities. To obtain this information, you must use ERRSET to change the number of allowable errors for that particular error code in the ESSL error option table; otherwise, the default value causes your program to terminate when the error occurs. For details, see What Can You Do about ESSL Computational Errors?.
This example finds the solution of the linear system Ax = b for sparse matrix A, which is stored in compressed-diagonal storage mode in arrays AD and LA. The system is solved using the two-term conjugate gradient method. In this example, IOPT = 0.. Matrix A is:
* * | 2.0 0.0 -1.0 0.0 0.0 0.0 0.0 0.0 0.0 | | 0.0 2.0 0.0 -1.0 0.0 0.0 0.0 0.0 0.0 | | -1.0 0.0 2.0 0.0 -1.0 0.0 0.0 0.0 0.0 | | 0.0 -1.0 0.0 2.0 0.0 -1.0 0.0 0.0 0.0 | | 0.0 0.0 -1.0 0.0 2.0 0.0 -1.0 0.0 0.0 | | 0.0 0.0 0.0 -1.0 0.0 2.0 0.0 -1.0 0.0 | | 0.0 0.0 0.0 0.0 -1.0 0.0 2.0 0.0 -1.0 | | 0.0 0.0 0.0 0.0 0.0 -1.0 0.0 2.0 0.0 | | 0.0 0.0 0.0 0.0 0.0 0.0 -1.0 0.0 2.0 | * *
IOPT M ND AD LDA LA B X IPARM RPARM AUX1 NAUX1 AUX2 NAUX2 | | | | | | | | | | | | | | CALL DSDCG( 0 , 9 , 3 , AD , 9 , LA , B , X , IPARM , RPARM , AUX1 , 283 , AUX2 , 0 )
IPARM(1) = 20 IPARM(2) = 0 IPARM(3) = 0 RPARM(1) = 1.D-7
* * | 2.0 0.0 -1.0 | | 2.0 0.0 -1.0 | | 2.0 -1.0 -1.0 | | 2.0 -1.0 -1.0 | AD = | 2.0 -1.0 -1.0 | | 2.0 -1.0 -1.0 | | 2.0 -1.0 -1.0 | | 2.0 -1.0 0.0 | | 2.0 -1.0 0.0 | * *
LA = (0, -2, 2) B = (1.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 1.0) X = (0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0)
X = (1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0) IPARM(4) = 5 RPARM(2) = 0 RPARM(3) = 0.46D-16
This example finds the solution of the linear system Ax = b for the same sparse matrix A as in Example 1, which is stored in compressed-diagonal storage mode in arrays AD and LA. The system is solved using the two-term conjugate gradient method. In this example, IOPT = 1, indicating that the matrix is symmetric, and only the main diagonal and one of each pair of identical diagonals are stored in array AD.
IOPT M ND AD LDA LA B X IPARM RPARM AUX1 NAUX1 AUX2 NAUX2 | | | | | | | | | | | | | | CALL DSDCG( 1 , 9 , 2 , AD , 9 , LA , B , X , IPARM , RPARM , AUX1 , 283 , AUX2 , 80 )
IPARM(1) = 20 IPARM(2) = 0 IPARM(3) = 10 RPARM(1) = 1.D-7
* * | 2.0 0.0 | | 2.0 0.0 | | 2.0 -1.0 | | 2.0 -1.0 | AD = | 2.0 -1.0 | | 2.0 -1.0 | | 2.0 -1.0 | | 2.0 -1.0 | | 2.0 -1.0 | * *
LA = (0, -2) B = (1.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 1.0) X = (0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0)
X = (1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0) IPARM(4) = 1 RPARM(2) = 0 RPARM(3) = 0.89D-16