04 March 2022 01:59:26 PM LINPACK_D_TEST C++ version Test the LINPACK_D library. TEST01 For a general matrix, DCHDC computes the Cholesky decomposition. The number of equations is N = 4 The matrix A: 2 -1 0 0 -1 2 -1 0 0 -1 2 -1 0 0 -1 2 Decompose the matrix. The Cholesky factor U: 1.41421 -0.707107 0 0 0 1.22474 -0.816497 0 0 0 1.1547 -0.866025 0 0 0 1.11803 The product U' * U: 2 -1 0 0 -1 2 -1 0 0 -1 2 -1 0 0 -1 2 TEST02 For a general matrix, DCHEX can shift columns in a Cholesky factorization. The number of equations is N = 5 The matrix A: 2 -1 0 0 0 -1 2 -1 0 0 0 -1 2 -1 0 0 0 -1 2 -1 0 0 0 -1 2 The vector Z: 1 2 3 4 5 Decompose the matrix. The Cholesky factor U: 1.41421 -0.707107 0 0 0 0 1.22474 -0.816497 0 0 0 0 1.1547 -0.866025 0 0 0 0 1.11803 -0.894427 0 0 0 0 1.09545 Right circular shift columns K = 1 through L = 3 Left circular shift columns K+1 = 2 through L = 3 The shifted Cholesky factor U: 1.41421 -0.707107 0 -0.707107 0 0 -1.22474 0.816497 0.408248 -0 0 0 1.1547 -0.288675 0 0 0 0 1.11803 -0.894427 0 0 0 0 1.09545 The shifted vector Z: 1.29479 -2.1702 2.75931 4 5 The shifted product U' * U: 2 -1 0 -1 0 -1 2 -1 0 0 0 -1 2 5.55112e-17 0 -1 0 5.55112e-17 2 -1 0 0 0 -1 2 TEST03 For a general matrix, DCHUD updates a Cholesky decomposition. In this example, we use DCHUD to solve a least squares problem R * b = z. The number of equations is P = 20 Solution vector # 1 (Should be (1,2,3...,n)) 1 1 2 2 3 3 4 4 5 5 ...... .............. 16 16 17 17 18 18 19 19 20 20 TEST04 For a general banded matrix, DGBCO estimates the reciprocal condition number. The matrix size is N = 10 The bandwidth of the matrix is 3 Estimate the condition. Estimated reciprocal condition = 0.0233017 TEST05 For a general banded matrix, DGBFA computes the LU factors, DGBSL solves a factored linear system. The matrix size is N = 10 The bandwidth of the matrix is 3 Factor the matrix. Solve the linear system. The first and last 5 entries of solution: (Should be (1,1,1,1,1,...,1,1)) 1 1 2 1 3 1 4 1 5 1 ...... .............. 6 1 7 1 8 1 9 1 10 1 TEST06 For a general banded matrix, DGBFA factors the matrix, DGBDI computes the determinant as det = MANTISSA * 10^EXPONENT Find the determinant of the -1,2,-1 matrix for N = 2, 4, 8, 16, 32, 64, 128. (For this matrix, det ( A ) = N + 1.) The bandwidth of the matrix is 3 N Mantissa Exponent 2 3 0 4 5 0 8 9 0 16 1.7 1 32 3.3 1 64 6.5 1 128 1.29 2 TEST07 For a general banded matrix, DGBFA computes the LU factors, DGBSL solves a factored linear system. The matrix size is N = 100 The bandwidth of the matrix is 51 Factor the matrix. Solve the linear system. The first and last 5 entries of solution: (Should be (1,1,1,1,1,...,1,1)) 1 1 2 1 3 1 4 1 5 1 ...... .............. 96 1 97 1 98 1 99 1 100 1 TEST08 For a general matrix, DGECO computes the LU factors and computes its reciprocal condition number; DGESL solves a factored linear system. The matrix size is N = 3 Factor the matrix. The reciprocal matrix condition number = 0.0234043 Solve the linear system. Solution returned by DGESL (Should be (1,1,1)) 1 1 1 Call DGESL for a new right hand side for the same, factored matrix. Solve a linear system. Solution returned by DGESL (should be (1,0,0)) 1 0 0 Call DGESL for transposed problem. Call DGESL to solve a transposed linear system. Solution returned by DGESL (should be (-1,0,1)) -1 -3.94746e-16 1 TEST09 For a general banded matrix, DGEFA computes the LU factors; DGEDI computes the inverse and determinant. The matrix size is N = 3 Factor the matrix. Get the inverse and determinant. The determinant = 2.7 * 10^1 The inverse matrix: -1.77778 0.888889 -0.111111 1.55556 -0.777778 0.222222 -0.111111 0.222222 -0.111111 TEST10 DGEFA computes the LU factors; DGESL solves a factored linear system; tor a general banded matrix. The number of equations is N = 3 The matrix A: 1 2 3 4 5 6 7 8 0 The right hand side B: 6 15 15 Factor the matrix. DGESL returns the solution: (Should be (1,1,1)) 1 1 1 TEST11 For a general banded matrix, DGEFA computes the LU factors; DGESL solves a factored linear system; The matrix size is N = 100 Factor the matrix. Solve the factored system. The first and last 5 entries of solution: (Should be (1,1,1,1,1,...,1,1)) 1 1 2 1 3 1 4 1 5 1 ...... .............. 96 1 97 1 98 1 99 1 100 1 TEST12 For a general tridiagonal matrix, DGTSL factors and solves a linear system. The matrix size is N = 100 Factor the matrix and solve the system. The first and last 5 entries of solution: (Should be (1,2,3,4,5,...,n-1,n)) 1 1 2 2 3 3 4 4 5 5 ...... .............. 96 96 97 97 98 98 99 99 100 100 TEST13 For a positive definite symmetric banded matrix, DPBCO estimates the reciprocal condition number. The matrix size is N = 10 Estimate the condition. Reciprocal condition = 0.0204918 TEST14 For a positive definite symmetric banded matrix, DPBDI computes the determinant as det = MANTISSA * 10^EXPONENT Find the determinant of the -1,2,-1 matrix for N = 2, 4, 8, 16, 32, 64, 128. (For this matrix, det ( A ) = N + 1.) N Mantissa Exponent 2 3 0 4 5 0 8 9 0 16 1.7 1 32 3.3 1 64 6.5 1 128 1.29 2 TEST15 For a positive definite symmetric banded matrix, DPBFA computes the LU factors. DPBSL solves a factored linear system. The matrix size is N = 10 Factor the matrix. Solve the linear system. The first and last 5 entries of solution: (Should be (1,1,1,1,1,...,1,1)) 1 1 2 1 3 1 4 1 5 1 ...... .............. 6 1 7 1 8 1 9 1 10 1 TEST16 For a positive definite symmetric banded matrix, DPOCO estimates the reciprocal condition number. The matrix size is N = 5 Estimate the condition. Reciprocal condition = 0.0675676 TEST17 For a positive definite symmetric matrix, DPOFA computes the LU factors. DPODI computes the inverse or determinant. The matrix size is N = 5 Factor the matrix. Get the determinant and inverse. Determinant = 6 * 10^0 First row of inverse: 0.833333 0.666667 0.5 0.333333 0.166667 TEST18 For a positive definite symmetric matrix, DPOFA computes the LU factors. DPOSL solves a factored linear system. The matrix size is N = 20 Factor the matrix. The first and last 5 entries of solution: (Should be (1,2,3,4,5,...,n-1,n)) 1 1 2 2 3 3 4 4 5 5 ...... .............. 16 16 17 17 18 18 19 19 20 20 TEST19 For a positive definite symmetric packed matrix, DPPCO estimates the reciprocal condition number. The matrix size is N = 5 Estimate the condition number. Reciprocal condition number = 0.0675676 TEST20 For a positive definite symmetric packed matrix, DPPFA computes the LU factors. DPPDI computes the inverse or determinant. The matrix size is N = 5 Factor the matrix. Get the determinant and inverse. Determinant = 6 * 10^0 The inverse matrix: 0.833333 0.666667 0.5 0.333333 0.166667 0.666667 1.33333 1 0.666667 0.333333 0.5 1 1.5 1 0.5 0.333333 0.666667 1 1.33333 0.666667 0.166667 0.333333 0.5 0.666667 0.833333 TEST21 For a positive definite symmetric packed matrix, DPPFA computes the LU factors. DPPSL solves a factored linear system. The matrix size is N = 20 Factor the matrix. The first and last 5 entries of solution: (Should be (1,2,3,4,5,...,n-1,n)) 1 1 2 2 3 3 4 4 5 5 ...... .............. 16 16 17 17 18 18 19 19 20 20 TEST22 For a positive definite symmetric tridiagonal matrix, DPTSL factors and solves a linear system. The matrix size is N = 20 Factor the matrix and solve the system. The first and last 5 entries of solution: (Should be (1,2,3,4,5,...,n-1,n)) 1 1 2 2 3 3 4 4 5 5 ...... .............. 16 16 17 17 18 18 19 19 20 20 DQRDC_TEST DQRDC computes the QR decomposition of a general matrix, but does not return Q and R explicitly. Show how Q and R can be recovered using DQRSL. The matrix A: 1 1 0 1 0 1 0 1 1 Decompose the matrix. The packed matrix A which describes Q and R: -1.41421 -0.707107 -0.707107 0.707107 1.22474 0.408248 0 -0.816497 1.1547 The QRAUX vector, containing some additional information defining Q: 1.70711 1.57735 0 The R factor: -1.41421 -0.707107 -0.707107 0 1.22474 0.408248 0 0 1.1547 The Q factor: -0.707107 0.408248 -0.57735 -0.707107 -0.408248 0.57735 0 0.816497 0.57735 The product Q * R: 1 1 -2.22045e-16 1 -5.55112e-17 1 0 1 1 DQRSL_TEST DQRSL solves a rectangular linear system A*x=b in the least squares sense after A has been factored by DQRDC. The matrix A: 1 1 1 1 2 4 1 3 9 1 4 16 1 5 25 Decompose the matrix. X X(expected): -3.02 -3.02 4.49143 4.49143 -0.728571 -0.728571 TEST24 For a symmetric indefinite matrix, DSICO estimates the reciprocal condition number. The matrix size is N = 100 Estimate the condition. Estimated reciprocal condition = 0.000251699 TEST25 DSIFA factor a symmetric indefinite matrix; DSISL solves a factored linear system, for a symmetric indefinite matrix. The matrix size is N = 100 Factor the matrix. Solve the linear system. The first and last 5 entries of solution: (Should be (1,2,3,4,5,...,n-1,n)) 1 1 2 2 3 3 4 4 5 5 ...... .............. 96 96 97 97 98 98 99 99 100 100 TEST26 For a symmetric indefinite packed matrix, DSPCO estimates the reciprocal condition number. The matrix size is N = 100 Estimate the condition. Estimated reciprocal condition = 1.4272e-07 TEST27 DSPFA computes the LU factors, DSPSL solves a factored linear system, for a symmetric indefinite packed matrix, The matrix size is N = 100 Factor the matrix. Solve the linear system. The first and last 5 entries of solution: (Should be (1,2,3,4,5,...,n-1,n)) 1 1 2 2 3 3 4 4 5 5 ...... .............. 96 96 97 97 98 98 99 99 100 100 DSVDC_TEST For an MxN matrix A in general storage, DSVDC computes the singular value decomposition: A = U * S * V' Matrix rows M = 6 Matrix columns N = 4 The matrix A: 0.218418 0.257578 0.401306 0.0945448 0.956318 0.109957 0.754673 0.0136169 0.829509 0.043829 0.797287 0.859097 0.561695 0.633966 0.00183837 0.840847 0.415307 0.0617272 0.897504 0.123104 0.0661187 0.449539 0.350752 0.00751236 Decompose the matrix. Singular values: 2 2.22898 3 1.03175 4 0.606304 5 0.441098 Left Singular Vector Matrix U: -0.214893 0.0702687 0.351627 0.141528 -0.569749 -0.693252 -0.493857 0.399434 0.0408471 -0.765911 -0.0327378 0.0848342 -0.621035 -0.122005 -0.541178 0.351135 -0.34157 0.258051 -0.37873 -0.803888 0.211678 -0.19504 0.319591 -0.159192 -0.394186 0.417037 0.11354 0.424627 0.652486 -0.227508 -0.159444 0.0217747 0.72396 0.227388 -0.172534 0.607053 Right Singular Vector Matrix V: -0.63767 0.0186361 -0.196482 -0.744597 -0.212197 -0.404587 0.887338 -0.0625492 -0.612157 0.593962 0.159466 0.497035 -0.416669 -0.695105 -0.385482 0.441157 The product U * S * V' (should equal A): 0.218418 0.257578 0.401306 0.0945448 0.956318 0.109957 0.754673 0.0136169 0.829509 0.043829 0.797287 0.859097 0.561695 0.633966 0.00183837 0.840847 0.415307 0.0617272 0.897504 0.123104 0.0661187 0.449539 0.350752 0.00751236 TEST29 For a triangular matrix, DTRCO computes the LU factors and computes its reciprocal condition number. The matrix size is N = 5 Lower triangular matrix A: 0.218418 0 0 0 0 0.956318 0.257578 0 0 0 0.829509 0.109957 0.401306 0 0 0.561695 0.043829 0.754673 0.0945448 0 0.415307 0.633966 0.797287 0.0136169 0.260303 The reciprocal condition number = 0.00481996 Upper triangular matrix A: 0.912484 0.692066 0.597917 0.574366 0.714471 0 0.561662 0.188955 0.367027 0.117707 0 0 0.761492 0.617205 0.299329 0 0 0 0.361529 0.825003 0 0 0 0 0.82466 The reciprocal condition number = 0.0614011 TEST30 For a triangular matrix, DTRDI computes the determinant or inverse. The matrix size is N = 5 Lower triangular matrix A: 0.218418 0 0 0 0 0.956318 0.257578 0 0 0 0.829509 0.109957 0.401306 0 0 0.561695 0.043829 0.754673 0.0945448 0 0.415307 0.633966 0.797287 0.0136169 0.260303 The determinant = 5.55635 * 10^(-4). The inverse matrix: 4.57837 0 0 0 0 -16.9983 3.88232 0 0 0 -4.80612 -1.06375 2.49186 0 0 19.043 6.69125 -19.8905 10.577 0 47.819 -6.54723 -6.59187 -0.553301 3.84168 Upper triangular matrix A: 0.912484 0.692066 0.597917 0.574366 0.714471 0 0.561662 0.188955 0.367027 0.117707 0 0 0.761492 0.617205 0.299329 0 0 0 0.361529 0.825003 0 0 0 0 0.82466 The determinant = 1.16355 * 10^(-1). The inverse matrix: 1.09591 -1.35035 -0.525426 0.526812 -1.09305 0 1.78043 -0.441791 -1.05328 0.959944 0 0 1.31321 -2.24193 1.7662 0 0 0 2.76603 -2.76718 0 0 0 0 1.21262 TEST31 For a triangular matrix, DTRSL solves a linear system. The matrix size is N = 5 For a lower triangular matrix A, solve A * x = b The solution (should be 1,2,3,4,5): 1 1 2 2 3 3 4 4 5 5 For a lower triangular matrix A, solve A' * x = b The solution (should be 1,2,3,4,5): 1 1 2 2 3 3 4 4 5 5 For an upper triangular matrix A, solve A * x = b The solution (should be 1,2,3,4,5): 1 1 2 2 3 3 4 4 5 5 For an upper triangular matrix A, solve A' * x = b The solution (should be 1,2,3,4,5): 1 1 2 2 3 3 4 4 5 5 LINPACK_D_TEST Normal end of execution. 04 March 2022 01:59:26 PM