NAME sqrdc - compute the QR factorization of a general matrix A. It is typical to follow a call to xQRDC with a call to xQRSL to solve Ax = b or to xPODI to compute the determinant of A. SYNOPSIS SUBROUTINE DQRDC (DA, LDA, N, P, DQRAUX, IPIVOT, DWORK, JOB) SUBROUTINE SQRDC (SA, LDA, N, P, SQRAUX, IPIVOT, SWORK, JOB) SUBROUTINE ZQRDC (ZA, LDA, N, P, ZQRAUX, IPIVOT, ZWORK, JOB) SUBROUTINE CQRDC (CA, LDA, N, P, CQRAUX, IPIVOT, CWORK, JOB) #include <sunperf.h> void dqrdc(double *dx, int ldx, int n, int p, double *qraux, int *jpivot, int job) ; void sqrdc(float *sx, int ldx, int n, int p, float *qraux, int *jpivot, int job) ; void zqrdc(doublecomplex *zx, int ldx, int n, int p, doub- lecomplex *qraux, int *jpivot, int job) ; void cqrdc(complex *cx, int ldx, int n, int p, complex *qraux, int *jpivot, int job) ; ARGUMENTS xA On entry, the matrix A. On exit, the upper trian- gle of A contains the matrix R and the strict lower triangle of A contains information that will allow construction of the matrix Q. If pivoting was requested, A contains the factorization of the original matrix A permuted by the requested pivots. LDA Leading dimension of the array A as specified in a dimension or type statement. LDA >= max(1,N). N Number of rows in the matrix A. N >= 0. P Number of columns in the matrix A. P >= 0. xQRAUX On exit, contains information required to con- struct the orthogonal matrix Q. IPIVOT If JOB selected no pivoting, then IPIVOT is not referenced. If JOB selected pivoting, then on entry to the subroutines, IPIVOT contains integers representing array indices that control the selec- tion of pivot elements from the diagonal of A according to the system below: IPIVOT(k) > 0 A(k,k) is an initial element. IPIVOT(k) = 0 A(k,k) is a free element. IPIVOT(k) < 0 A(k,k) is a final element. Before the decomposition is computed, symmetric row and column interchanges are used to move ini- tial elements to the beginning of A and final ele- ments to the end of A. During the computation, symmetric row and column interchanges are used to move the largest remaining free diagonal element into the pivot position. On exit, IPIVOT(k) con- tains the index of the diagonal element of A that was moved into the kth position. xWORK Scratch array with a dimension of N. WORK is not referenced if JOB = 0. JOB Determines how the factorization is done: 0 with no pivoting not 0 with pivoting SAMPLE PROGRAM PROGRAM TEST IMPLICIT NONE C INTEGER IDOB, IDORSD, IDOXB, LDA, N, NCOLA, NOPIV, NROWA PARAMETER (IDOB = 100) PARAMETER (IDORSD = 10) PARAMETER (IDOXB = 1) PARAMETER (N = 3) PARAMETER (LDA = N) PARAMETER (NCOLA = 2) PARAMETER (NOPIV = 0) PARAMETER (NROWA = N) C DOUBLE PRECISION A(LDA,NCOLA), B(NCOLA), NULL(N), QRAUX(N) DOUBLE PRECISION RESID(N), WORK(N), Y(N) INTEGER ICOL, INFO, IROW, JOB, JPIVOT C EXTERNAL DQRDC, DQRSL C C Initialize the array A to store the matrix A shown below. C Initialize the array Y to store the vector y shown below. C C 1 1 1 C A = 1 0 y = 0 C 0 1 -5 C DATA A / 1.0D0, 1.0D0, 0.0D0, 1.0D0, 0.0D0, 1.0D0 / DATA Y / 1.0D0, 0.0D0, -5.0D0 / C PRINT 1000 PRINT 1010, ((A(IROW,ICOL), ICOL = 1, NCOLA), IROW = 1, NROWA) PRINT 1020 PRINT 1030, Y JOB = NOPIV CALL DQRDC (A, LDA, NROWA, NCOLA, QRAUX, JPIVOT, WORK, JOB) JOB = IDOB + IDORSD + IDOXB CALL DQRSL (A, LDA, NROWA, NCOLA, QRAUX, Y, NULL, NULL, B, $ RESID, NULL, JOB, INFO) IF (INFO .EQ. 0) THEN PRINT 1040 PRINT 1050, B PRINT 1060 PRINT 1050, RESID ELSE PRINT 1070 END IF C 1000 FORMAT (1X, 'A:') 1010 FORMAT (2(3X, F4.1)) 1020 FORMAT (/1X, 'y:') 1030 FORMAT (3X, F4.1) 1040 FORMAT (/1X, 'Least squares solution:') 1050 FORMAT (3X, F4.1) 1060 FORMAT (/1X, 'Residual:') 1070 FORMAT (1X, 'A is singular.') C END SAMPLE OUTPUT A: 1.0 1.0 1.0 0.0 0.0 1.0 y: 1.0 0.0 -5.0 Least squares solution: 2.0 -3.0 Residual: 2.0 -2.0 -2.0
Закладки на сайте Проследить за страницей |
Created 1996-2024 by Maxim Chirkov Добавить, Поддержать, Вебмастеру |