18 January 2017 08:53:07 PM LINPACK_S_PRB C version Test the LINPACK_S library. TEST01 SCHDC computes the Cholesky decomposition, For a general matrix. The number of equations is N = 4 The matrix A: 2.000000 -1.000000 0.000000 0.000000 -1.000000 2.000000 -1.000000 0.000000 0.000000 -1.000000 2.000000 -1.000000 0.000000 0.000000 -1.000000 2.000000 Decompose the matrix. The Cholesky factor U: 1.414214 -0.707107 0.000000 0.000000 0.000000 1.224745 -0.816497 0.000000 0.000000 0.000000 1.154701 -0.866025 0.000000 0.000000 0.000000 1.118034 The product U' * U: 2.000000 -1.000000 0.000000 0.000000 -1.000000 2.000000 -1.000000 0.000000 0.000000 -1.000000 2.000000 -1.000000 0.000000 0.000000 -1.000000 2.000000 TEST02 For a general matrix, SCHEX can shift columns in a Cholesky factorization. The number of equations is N = 5 The matrix A: 2.000000 -1.000000 0.000000 0.000000 0.000000 -1.000000 2.000000 -1.000000 0.000000 0.000000 0.000000 -1.000000 2.000000 -1.000000 0.000000 0.000000 0.000000 -1.000000 2.000000 -1.000000 0.000000 0.000000 0.000000 -1.000000 2.000000 The vector Z: 1.000000 2.000000 3.000000 4.000000 5.000000 Decompose the matrix. The Cholesky factor U: 1.414214 -0.707107 0.000000 0.000000 0.000000 0.000000 1.224745 -0.816497 0.000000 0.000000 0.000000 0.000000 1.154701 -0.866025 0.000000 0.000000 0.000000 0.000000 1.118034 -0.894427 0.000000 0.000000 0.000000 0.000000 1.095445 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.414213 -0.707107 0.000000 -0.707107 0.000000 0.000000 -1.224745 0.816497 0.408248 -0.000000 0.000000 0.000000 1.154701 -0.288675 0.000000 0.000000 0.000000 0.000000 1.118034 -0.894427 0.000000 0.000000 0.000000 0.000000 1.095445 The shifted vector Z: 1.294789 -2.170197 2.759306 4.000000 5.000000 The shifted product U' * U: 2.000000 -1.000000 0.000000 -1.000000 0.000000 -1.000000 2.000000 -1.000000 0.000000 0.000000 0.000000 -1.000000 2.000000 0.000000 0.000000 -1.000000 0.000000 0.000000 2.000000 -1.000000 0.000000 0.000000 0.000000 -1.000000 2.000000 TEST03 For a general matrix, SCHUD updates a Cholesky decomposition. In this example, we use SCHUD 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 0.999913 2 2.000000 3 3.000132 4 3.999943 5 4.999849 ...... .............. 16 15.999761 17 17.000233 18 18.000259 19 18.999846 20 19.999695 TEST04 For a general banded matrix, SGBCO 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.023302 TEST05 For a general banded matrix, SGBFA computes the LU factors, SGBSL 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.000000 2 1.000000 3 1.000000 4 1.000000 5 1.000000 ...... .............. 6 1.000000 7 1.000000 8 1.000000 9 1.000000 10 1.000000 TEST06 For a general banded matrix, SGBFA factors the matrix, SGBDI 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.000000 0.000000 4 5.000000 0.000000 8 9.000000 0.000000 16 1.700000 1.000000 32 3.300003 1.000000 64 6.500012 1.000000 128 1.289996 2.000000 TEST07 For a general banded matrix, SGBFA computes the LU factors, SGBSL 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 0.999999 2 0.999999 3 0.999999 4 0.999999 5 0.999999 ...... .............. 96 1.000000 97 0.999999 98 0.999999 99 1.000000 100 0.999999 TEST08 SGECO computes the LU factors and computes its reciprocal condition number; SGESL solves a factored linear system. The matrix size is N = 3 Factor the matrix. The reciprocal matrix condition number = 0.023404 Solve the linear system. Solution returned by SGESL (Should be (1,1,1)) 0.999999 1.000000 1.000000 Call SGESL for a new right hand side for the same, factored matrix. Solve a linear system. Solution returned by SGESL (should be (1,0,0)) 1.000000 0.000000 0.000000 Call SGESL for transposed problem. Call SGESL to solve a transposed linear system. Solution returned by SGESL (should be (-1,0,1)) -1.000000 0.000000 1.000000 TEST09 For a general banded matrix, SGEFA computes the LU factors; SGEDI computes the inverse and determinant. The matrix size is N = 3 Factor the matrix. Get the inverse and determinant. The determinant = 2.700000 * 10^1.000000 The inverse matrix: -1.777778 0.888889 -0.111111 1.555555 -0.777778 0.222222 -0.111111 0.222222 -0.111111 TEST10 For a general banded matrix, SGEFA computes the LU factors; SGESL solves a factored linear system; The number of equations is N = 3 The matrix A: 1.000000 2.000000 3.000000 4.000000 5.000000 6.000000 7.000000 8.000000 0.000000 The right hand side B: 6.000000 15.000000 15.000000 Factor the matrix. SGESL returns the solution: (Should be (1,1,1)) 0.999999 1.000000 1.000000 TEST11 For a general banded matrix, SGEFA computes the LU factors; SGESL 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 0.999990 2 0.999988 3 0.999990 4 0.999990 5 0.999990 ...... .............. 96 0.999989 97 0.999989 98 0.999989 99 0.999989 100 0.999989 TEST12 For a general tridiagonal matrix, SGTSL 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.000002 2 2.000004 3 3.000005 4 4.000007 5 5.000009 ...... .............. 96 96.000092 97 97.000076 98 98.000061 99 99.000038 100 100.000023 TEST13 For a positive definite symmetric banded matrix, SPBCO estimates the reciprocal condition number. The matrix size is N = 10 Estimate the condition. Reciprocal condition = 0.020492 TEST14 For a positive definite symmetric banded matrix, SPBDI 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.000000 0.000000 4 5.000000 0.000000 8 9.000004 0.000000 16 1.700000 1.000000 32 3.299984 1.000000 64 6.499890 1.000000 128 1.289971 2.000000 TEST15 For a positive definite symmetric banded matrix, SPBFA computes the LU factors. SPBSL 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.000000 2 1.000000 3 1.000000 4 1.000000 5 0.999999 ...... .............. 6 0.999999 7 1.000000 8 1.000000 9 1.000000 10 1.000000 TEST16 For a positive definite symmetric banded matrix, SPOCO estimates the reciprocal condition number. The matrix size is N = 5 Estimate the condition. Reciprocal condition = 0.067568 TEST17 For a positive definite symmetric matrix, SPOFA computes the LU factors. SPODI computes the inverse or determinant. The matrix size is N = 5 Factor the matrix. Get the determinant and inverse. Determinant = 6.000000 * 10^0.000000 First row of inverse: 0.833333 0.666667 0.500000 0.333333 0.166667 TEST18 For a positive definite symmetric matrix, SPOFA computes the LU factors. SPOSL 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.000000 2 2.000001 3 3.000002 4 4.000002 5 5.000002 ...... .............. 16 16.000013 17 17.000013 18 18.000011 19 19.000011 20 20.000006 TEST19 For a positive definite symmetric packed matrix, SPPCO estimates the reciprocal condition number. The matrix size is N = 5 Estimate the condition number. Reciprocal condition number = 0.067568 TEST20 For a positive definite symmetric packed matrix, SPPFA computes the LU factors. SPPDI computes the inverse or determinant. The matrix size is N = 5 Factor the matrix. Get the determinant and inverse. Determinant = 6.000000 * 10^0.000000 The inverse matrix: 0.833333 0.666667 0.500000 0.333333 0.166667 0.666667 1.333333 1.000000 0.666667 0.333333 0.500000 1.000000 1.500000 1.000000 0.500000 0.333333 0.666667 1.000000 1.333333 0.666667 0.166667 0.333333 0.500000 0.666667 0.833333 TEST21 For a positive definite symmetric packed matrix, SPPFA computes the LU factors. SPPSL 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.000000 2 2.000001 3 3.000002 4 4.000002 5 5.000002 ...... .............. 16 16.000013 17 17.000013 18 18.000011 19 19.000011 20 20.000006 TEST22 For a positive definite symmetric tridiagonal matrix, SPTSL 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 0.999999 2 1.999999 3 2.999998 4 3.999998 5 4.999997 ...... .............. 16 15.999997 17 16.999998 18 18.000000 19 19.000000 20 20.000000 SQRDC_TEST SQRDC computes the QR decomposition of a rectangular matrix, but does not return Q and R explicitly. Show how Q and R can be recovered using SQRSL. The matrix A: 1.000000 1.000000 0.000000 1.000000 0.000000 1.000000 0.000000 1.000000 1.000000 Decompose the matrix. The packed matrix A which describes Q and R: -1.414214 -0.707107 -0.707107 0.707107 1.224745 0.408248 0.000000 -0.816497 1.154701 The QRAUX vector, containing some additional information defining Q: 1.707107 1.577350 0.000000 The R factor: -1.414214 -0.707107 -0.707107 0.000000 1.224745 0.408248 0.000000 0.000000 1.154701 The Q factor: -0.707107 0.408248 -0.577350 -0.707107 -0.408248 0.577350 0.000000 0.816497 0.577350 The product Q * R: 1.000000 1.000000 -0.000000 1.000000 -0.000000 1.000000 0.000000 1.000000 1.000000 SQRSL_TEST SQRSL solves a rectangular linear system A*x=b in the least squares sense after A has been factored by SQRDC. The matrix A: 1.000000 1.000000 1.000000 1.000000 2.000000 4.000000 1.000000 3.000000 9.000000 1.000000 4.000000 16.000000 1.000000 5.000000 25.000000 Decompose the matrix. X X(expected): -3.02 -3.02 4.49143 4.49143 -0.728571 -0.728571 TEST24 For a symmetric indefinite matrix, SSICO estimates the reciprocal condition number. The matrix size is N = 100 Estimate the condition. Estimated reciprocal condition = 0.000252 TEST25 For a symmetric indefinite matrix, SSIFA factor a symmetric indefinite matrix; SSISL solves a factored linear system, 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.000002 2 2.000005 3 3.000007 4 4.000009 5 5.000010 ...... .............. 96 95.999969 97 96.999985 98 97.999992 99 99.000000 100 100.000000 TEST26 For a symmetric indefinite packed matrix, SSPCO estimates the reciprocal condition number. The matrix size is N = 100 Estimate the condition. Estimated reciprocal condition = 0.000000 TEST27 For a symmetric indefinite packed matrix, SSPFA computes the LU factors, SSPSL solves a factored linear system, 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.000002 2 2.000005 3 3.000007 4 4.000009 5 5.000010 ...... .............. 96 95.999969 97 96.999985 98 97.999992 99 99.000000 100 100.000000 SSVDC_TEST For an MxN matrix A in general storage, SSVDC 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.094545 0.956318 0.109957 0.754673 0.013617 0.829509 0.043829 0.797287 0.859097 0.561695 0.633966 0.001838 0.840847 0.415307 0.061727 0.897504 0.123104 0.066119 0.449539 0.350752 0.007512 Decompose the matrix. Singular values: 2 2.228984 3 1.031752 4 0.606304 5 0.441098 Left Singular Vector Matrix U: -0.214893 0.070269 0.351627 0.141528 -0.569749 -0.693251 -0.493857 0.399434 0.040847 -0.765911 -0.032738 0.084834 -0.621035 -0.122005 -0.541178 0.351135 -0.341570 0.258051 -0.378730 -0.803888 0.211678 -0.195040 0.319591 -0.159192 -0.394186 0.417037 0.113540 0.424627 0.652486 -0.227508 -0.159444 0.021774 0.723959 0.227388 -0.172534 0.607053 Right Singular Vector Matrix V: -0.637670 0.018636 -0.196482 -0.744597 -0.212197 -0.404587 0.887338 -0.062549 -0.612157 0.593962 0.159467 0.497036 -0.416669 -0.695106 -0.385482 0.441157 The product U * S * V' (should equal A): 0.218418 0.257578 0.401306 0.094545 0.956318 0.109957 0.754674 0.013617 0.829509 0.043829 0.797287 0.859097 0.561695 0.633966 0.001839 0.840848 0.415307 0.061727 0.897504 0.123104 0.066119 0.449539 0.350752 0.007512 TEST29 For a triangular matrix, STRCO computes the LU factors and computes its reciprocal condition number. The matrix size is N = 5 Lower triangular matrix A: 0.218418 0.000000 0.000000 0.000000 0.000000 0.956318 0.257578 0.000000 0.000000 0.000000 0.829509 0.109957 0.401306 0.000000 0.000000 0.561695 0.043829 0.754673 0.094545 0.000000 0.415307 0.633966 0.797287 0.013617 0.260303 The reciprocal condition number = 0.004820 Upper triangular matrix A: 0.912484 0.692066 0.597917 0.574366 0.714471 0.000000 0.561662 0.188955 0.367027 0.117707 0.000000 0.000000 0.761492 0.617205 0.299329 0.000000 0.000000 0.000000 0.361529 0.825003 0.000000 0.000000 0.000000 0.000000 0.824660 The reciprocal condition number = 0.061401 TEST30 For a triangular matrix, STRDI computes the determinant or inverse. The matrix size is N = 5 Lower triangular matrix A: 0.218418 0.000000 0.000000 0.000000 0.000000 0.956318 0.257578 0.000000 0.000000 0.000000 0.829509 0.109957 0.401306 0.000000 0.000000 0.561695 0.043829 0.754673 0.094545 0.000000 0.415307 0.633966 0.797287 0.013617 0.260303 The determinant = 5.556355 * 10^(-4.000000). The inverse matrix: 4.578371 0.000000 0.000000 0.000000 0.000000 -16.998270 3.882322 0.000000 0.000000 0.000000 -4.806119 -1.063745 2.491862 0.000000 0.000000 19.043028 6.691244 -19.890499 10.577002 0.000000 47.819046 -6.547228 -6.591866 -0.553301 3.841677 Upper triangular matrix A: 0.912484 0.692066 0.597917 0.574366 0.714471 0.000000 0.561662 0.188955 0.367027 0.117707 0.000000 0.000000 0.761492 0.617205 0.299329 0.000000 0.000000 0.000000 0.361529 0.825003 0.000000 0.000000 0.000000 0.000000 0.824660 The determinant = 1.163546 * 10^(-1.000000). The inverse matrix: 1.095910 -1.350353 -0.525426 0.526812 -1.093052 0.000000 1.780429 -0.441791 -1.053275 0.959944 0.000000 0.000000 1.313211 -2.241925 1.766198 0.000000 0.000000 0.000000 2.766032 -2.767182 0.000000 0.000000 0.000000 0.000000 1.212621 TEST31 For a triangular matrix, STRSL 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.000000 2 2.000000 3 3.000000 4 4.000000 5 5.000000 For a lower triangular matrix A, solve A' * x = b The solution (should be 1,2,3,4,5): 1 0.999999 2 2.000001 3 2.999999 4 4.000000 5 5.000000 For an upper triangular matrix A, solve A * x = b The solution (should be 1,2,3,4,5): 1 1.000000 2 2.000000 3 3.000001 4 3.999999 5 5.000000 For an upper triangular matrix A, solve A' * x = b The solution (should be 1,2,3,4,5): 1 1.000000 2 2.000000 3 3.000000 4 4.000000 5 5.000000 LINPACK_S_PRB Normal end of execution. 18 January 2017 08:53:07 PM