NAME cchex - compute the Cholesky decomposition of a symmetric positive definite matrix A. SYNOPSIS SUBROUTINE DCHEX (DA, LDA, N, K, L, DZ, LDZ, NZ, DCOS, DSIN, JOB) SUBROUTINE SCHEX (SA, LDA, N, K, L, SZ, LDZ, NZ, SCOS, SSIN, JOB) SUBROUTINE CCHEX (ZA, LDA, N, K, L, ZZ, LDZ, NZ, DCOS, DSIN, JOB) SUBROUTINE ZCHEX (CA, LDA, N, K, L, CZ, LDZ, NZ, SCOS, SSIN, JOB) #include <sunperf.h> void dchex (double *r, int ldr, int p, int k, int l, double *dz, int ldz, int nz, double *dc, double *s, int job); void schex (float *r, int ldr, int p, int k, int l, float *sz, int ldz, int nz, float *sc, float *s, int job); void cchex (complex *r, int ldr, int p, int k, int l, com- plex *cz, int ldz, int nz, float *c, complex *s, int job); void zchex (doublecomplex *r, int ldr, int p, int k, int l, doublecomplex *zz, int ldz, int nz, double *dc, doublecomplex *s, int job); ARGUMENTS xA On entry, the upper triangle of the matrix A. On exit, the upper triangle of A contains the upper triangle of the updated factor. The strict lower triangle of A is not referenced. LDA Leading dimension of the array A as specified in a dimension or type statement. LDA >= max(1,N). N Order of the matrix A. N >= 0. K First column to be permuted. 1 <= K <= L. L Last column to be permuted; must be strictly greater than K. K <= L <= N. xZ Array of vectors into which the transformation U is multiplied. Not used if NZ = 0. LDZ Leading dimension of the array Z as specified in a dimension or type statement. LDZ >= max(1,N). NZ Number of columns in the matrix Z. NZ >= 0. xCOS Cosines of the transforming rotations. xSIN Sines of the transforming rotations. JOB Determines the type of permutation: 1 right circular shift 2 left circular shift SAMPLE PROGRAM PROGRAM TEST IMPLICIT NONE C INTEGER ISHFRT, LDA, N, NULL, NZ PARAMETER (ISHFRT = 1) PARAMETER (N = 4) PARAMETER (LDA = N) PARAMETER (NULL = 1) PARAMETER (NZ = 0) C DOUBLE PRECISION A(LDA,N), ANULL, C(N), S(N), WORK(N) INTEGER ICOL, INFO, IPIVOT(N), IROW, JOB, K C EXTERNAL DCHDC, DCHEX C C Initialize the arrays A and Z to store the matrices C A and Z shown below and initialize X and Y to store C the vectors x and y shown below. C C 4 3 2 1 1 C A = 3 4 3 2 x = 1 C 2 3 4 3 1 C 1 2 3 4 1 C DATA A / 4.0D0, 3*8D8, 3.0D0, 4.0D0, 2*8D8, 2.0D0, $ 3.0D0, 4.0D0, 8D8, 1.0D0, 2.0D0, 3.0D0, $ 4.0D0 / C PRINT 1000 DO 100, IROW = 1, N PRINT 1010, (A(ICOL,IROW), ICOL = 1, IROW), $ (A(IROW,ICOL), ICOL = IROW + 1, N) 100 CONTINUE PRINT 1020 PRINT 1010, ((A(IROW,ICOL), ICOL = 1, N), IROW = 1, N) CALL DCHDC (A, LDA, N, WORK, IPIVOT, JOB, INFO) IF (INFO .EQ. N) THEN PRINT 1030 PRINT 1010, A(1,1), A(1,2), A(1,3), A(1,4) PRINT 1040, A(2,2), A(2,3), A(2,4) PRINT 1050, A(3,3), A(3,4) PRINT 1060, A(4,4) K = 1 ANULL = 0.0D0 JOB = ISHFRT CALL DCHEX (A, LDA, N, K, N, ANULL, NULL, NZ, C, $ S, JOB) PRINT 1070 PRINT 1010, A(1,1), A(1,2), A(1,3), A(1,4) PRINT 1040, A(2,2), A(2,3), A(2,4) PRINT 1050, A(3,3), A(3,4) PRINT 1060, A(4,4) PRINT 1080 PRINT 1090, (C(IROW), S(IROW), IROW = 1, N) ELSE PRINT 1100 END IF C 1000 FORMAT (1X, 'A in full form:') 1010 FORMAT (4(3X, F7.3)) 1020 FORMAT (/1X, 'A in symmetric form ', $ ' (* in unused entries)') 1030 FORMAT (/1X, 'Upper Cholesky factor:') 1040 FORMAT (10X, 3(3X, F7.3)) 1050 FORMAT (20X, 2(3X, F7.3)) 1060 FORMAT (30X, 1(3X, F7.3)) 1070 FORMAT (1X, 'Updated Cholesky factor:') 1080 FORMAT (/1X, 'Cosine', 3X, ' Sine') 1090 FORMAT (1X, F6.3, 3X, F6.3) 1100 FORMAT (/1X, 'A is not positive definite.') C END SAMPLE OUTPUT A in full form: 4.000 3.000 2.000 1.000 3.000 4.000 3.000 2.000 2.000 3.000 4.000 3.000 1.000 2.000 3.000 4.000 A in symmetric form (* in unused entries) 4.000 3.000 2.000 1.000 ******* 4.000 3.000 2.000 ******* ******* 4.000 3.000 ******* ******* ******* 4.000 Upper Cholesky factor: 2.000 1.500 1.000 0.500 1.323 1.134 0.945 1.309 1.091 1.291 Updated Cholesky factor: 2.000 0.500 1.000 1.500 -1.936 -1.291 -0.645 -1.155 -0.577 -1.000 Cosine Sine 0.645 0.764 0.488 0.873 0.250 0.968 0.000 2.000
Закладки на сайте Проследить за страницей |
Created 1996-2024 by Maxim Chirkov Добавить, Поддержать, Вебмастеру |