templates_test 27-Mar-2006 23:19:35 TEMPLATES_TEST Test the MATLAB TEMPLATES routines. BICG_TEST: BICG uses the BiConjugate Gradient iterative method to approximate the solution of a linear system A * x = b. For this example, the order of the system is N = 10 The matrix A is the simple tridiagonal -1, 2, -1. The correct solution is x = [ 1, 2, ..., n]. The right hand side b is determined by computing A * x. The exact x is then replaced by a vector of all 1's for use as a starting guess. Other parameters are set as follows: The maximum number of steps is 10. The error tolerance is 0.000100 The BICG routine has returned with FLAG = 0 This indicates that the iteration has converged. The number of iterations taken was 10 The L2 norm of the error per iteration: 1 0.877421 2 0.505777 3 0.304194 4 0.504845 5 1.548892 6 2.445262 7 1.545425 8 2.410139 9 0.003766 10 0.001623 The computed solution vector X: 1 1.000000 2 2.000000 3 3.000000 4 4.000000 5 5.000000 6 6.000000 7 7.000000 8 8.000000 9 9.000000 10 10.000000 BICG_TEST: Normal end of execution. CG_TEST: CG uses the Conjugate Gradient iterative method to approximate the solution of a linear system A * x = b. For this example, the order of the system is N = 10 The matrix A is the simple tridiagonal -1, 2, -1. The correct solution is x = [ 1, 2, ..., n]. The right hand side b is determined by computing A * x. The exact x is then replaced by a vector of all 1's for use as a starting guess. Other parameters are set as follows: The maximum number of steps is 10. The error tolerance is 0.000100 The CG routine has returned with FLAG = 1 This indicates that the iteration has NOT converged. The number of iterations taken was 10 The L2 norm of the error per iteration: 1 0.877421 2 0.505777 3 0.317250 4 0.276570 5 0.281605 6 0.301413 7 0.328768 8 0.360412 9 0.394412 10 0.429731 The computed solution vector X: 1 1.658012 2 2.652766 3 3.648294 4 4.661967 5 5.862532 6 7.722333 7 8.906764 8 5.360888 9 4.245899 10 9.711418 CG_TEST: Normal end of execution. CGS_TEST: CGS uses the Conjugate Gradient Squared iterative method to approximate the solution of a linear system A * x = b. For this example, the order of the system is N = 10 The matrix A is the simple tridiagonal -1, 2, -1. The correct solution is x = [ 1, 2, ..., n]. The right hand side b is determined by computing A * x. The exact x is then replaced by a vector of all 1's for use as a starting guess. Other parameters are set as follows: The maximum number of steps is 10. The error tolerance is 0.000100 The CGS routine has returned with FLAG = 0 This indicates that the iteration has converged. The number of iterations taken was 8 The L2 norm of the error per iteration: 1 0.877421 2 0.397385 3 0.165075 4 0.596932 5 6.180967 6 16.506721 7 6.152690 8 13.865304 The computed solution vector X: 1 0.999946 2 2.000004 3 3.000002 4 4.000001 5 5.000000 6 5.999999 7 7.000011 8 7.999981 9 9.000013 10 9.999997 CGS_TEST: Normal end of execution. CHEBY_TEST: CHEBY uses the Chebyshev iterative method to approximate the solution of a linear system A * x = b. For this example, the order of the system is N = 10 The matrix A is the simple tridiagonal -1, 2, -1. The correct solution is x = [ 1, 2, ..., n]. The right hand side b is determined by computing A * x. The exact x is then replaced by a vector of all 1's for use as a starting guess. Other parameters are set as follows: The maximum number of steps is 10. The error tolerance is 0.000100 The CHEBY routine has returned with FLAG = 1 This indicates that the iteration has NOT converged. The number of iterations taken was 10 The L2 norm of the error per iteration: 1 0.877421 2 0.866025 3 0.432534 4 0.216028 5 0.107894 6 0.053887 7 0.026914 8 0.013442 9 0.006713 10 0.003353 The computed solution vector X: 1 1.017578 2 2.000000 3 3.000000 4 4.000000 5 5.000000 6 6.000000 7 7.000000 8 8.000000 9 9.000000 10 10.000000 CHEBY_TEST: Normal end of execution. GMRES_TEST: GMRES uses the Generalized Minimum Residual iterative method to approximate the solution of a linear system A * x = b. For this example, the order of the system is N = 10 The matrix A is the simple tridiagonal -1, 2, -1. The correct solution is x = [ 1, 2, ..., n]. The right hand side b is determined by computing A * x. The exact x is then replaced by a vector of all 1's for use as a starting guess. Other parameters are set as follows: The method is restarted after every 5 steps; The maximum number of steps is 10. The error tolerance is 0.000100 The GMRES routine has returned with FLAG = 1 This indicates that the iteration has NOT converged. The number of iterations taken was 10 The L2 norm of the error per iteration: 1 0.877421 2 0.438189 3 0.215309 4 0.106321 5 0.052719 6 0.026048 7 0.026048 8 0.012780 9 0.006210 10 0.002974 The computed solution vector X: 1 0.983478 2 2.000122 3 3.003876 4 4.003476 5 5.002158 6 6.000735 7 7.000360 8 8.000121 9 9.000019 10 10.000000 GMRES_TEST: Normal end of execution. JACOBI_TEST: JACOBI uses the Jacobi iterative method to approximate the solution of a linear system A * x = b. For this example, the order of the system is N = 10 The matrix A is the simple tridiagonal -1, 2, -1. The correct solution is x = [ 1, 2, ..., n]. The right hand side b is determined by computing A * x. The exact x is then replaced by a vector of all 1's for use as a starting guess. Other parameters are set as follows: The maximum number of steps is 10. The error tolerance is 0.000100 The JACOBI routine has returned with FLAG = 1 This indicates that the iteration has NOT converged. The number of iterations taken was 10 The L2 norm of the error per iteration: 1 0.877421 2 0.823913 3 0.320256 4 0.145945 5 0.070218 6 0.034433 7 0.016946 8 0.008303 9 0.004027 10 0.001923 The computed solution vector X: 1 1.000000 2 2.000000 3 3.000000 4 4.000000 5 5.000000 6 6.000000 7 7.000000 8 8.000000 9 9.000000 10 10.000000 JACOBI_TEST: Normal end of execution. LEHMER_TEST: LEHMER generates a Lehmer matrix. The Lehmer matrix: Col: 1 2 3 4 5 Row 1 1 0.500000 0.333333 0.250000 0.200000 2 0.500000 1 0.666667 0.500000 0.400000 3 0.333333 0.666667 1 0.750000 0.600000 4 0.250000 0.500000 0.750000 1 0.800000 5 0.200000 0.400000 0.600000 0.800000 1 6 0.166667 0.333333 0.500000 0.666667 0.833333 7 0.142857 0.285714 0.428571 0.571429 0.714286 8 0.125000 0.250000 0.375000 0.500000 0.625000 9 0.111111 0.222222 0.333333 0.444444 0.555556 10 0.100000 0.200000 0.300000 0.400000 0.500000 Col: 6 7 8 9 10 Row 1 0.166667 0.142857 0.125000 0.111111 0.100000 2 0.333333 0.285714 0.250000 0.222222 0.200000 3 0.500000 0.428571 0.375000 0.333333 0.300000 4 0.666667 0.571429 0.500000 0.444444 0.400000 5 0.833333 0.714286 0.625000 0.555556 0.500000 6 1 0.857143 0.750000 0.666667 0.600000 7 0.857143 1 0.875000 0.777778 0.700000 8 0.750000 0.875000 1 0.888889 0.800000 9 0.666667 0.777778 0.888889 1 0.900000 10 0.600000 0.700000 0.800000 0.900000 1 LEHMER_TEST: Normal end of execution. MM_TO_MSM_TEST: MM_TO_MSM can read a Matrix Market file and convert the information into a Matlab Sparse Matrix. We will read the file "wathen_29_29_adg.txt". Matrix order is 29 rows by 29 columns Number of entries is 841 Matrix representation is "array" Matrix arithmetic field is "double" Matrix symmetry type is "general" Whether A is full or sparse, we can manipulate it now with MATLAB. Here we get the eigenvalues. For the Wathen matrix, these will all be positive. Eigenvalues of Wathen matrix: 7.423296 7.434898 9.004231 9.039434 11.693400 11.753095 16.261853 16.360901 16.801509 17.142453 22.799440 23.152257 24.348249 26.402152 26.847237 30.860446 35.278692 42.879390 50.489602 54.971693 57.153158 59.897490 66.032226 102.037227 175.524002 201.165822 246.091112 285.587264 372.234136 MM_TO_MSM_TEST: Normal end of execution. POISSON_TEST: POISSON generates a Poisson matrix. The Poisson matrix: Col: 1 2 3 4 5 Row 1 4 -1 0 0 -1 2 -1 4 -1 0 0 3 0 -1 4 -1 0 4 0 0 -1 4 0 5 -1 0 0 0 4 6 0 -1 0 0 -1 7 0 0 -1 0 0 8 0 0 0 -1 0 9 0 0 0 0 -1 10 0 0 0 0 0 11 0 0 0 0 0 12 0 0 0 0 0 13 0 0 0 0 0 14 0 0 0 0 0 15 0 0 0 0 0 16 0 0 0 0 0 Col: 6 7 8 9 10 Row 1 0 0 0 0 0 2 -1 0 0 0 0 3 0 -1 0 0 0 4 0 0 -1 0 0 5 -1 0 0 -1 0 6 4 -1 0 0 -1 7 -1 4 -1 0 0 8 0 -1 4 0 0 9 0 0 0 4 -1 10 -1 0 0 -1 4 11 0 -1 0 0 -1 12 0 0 -1 0 0 13 0 0 0 -1 0 14 0 0 0 0 -1 15 0 0 0 0 0 16 0 0 0 0 0 Col: 11 12 13 14 15 Row 1 0 0 0 0 0 2 0 0 0 0 0 3 0 0 0 0 0 4 0 0 0 0 0 5 0 0 0 0 0 6 0 0 0 0 0 7 -1 0 0 0 0 8 0 -1 0 0 0 9 0 0 -1 0 0 10 -1 0 0 -1 0 11 4 -1 0 0 -1 12 -1 4 0 0 0 13 0 0 4 -1 0 14 0 0 -1 4 -1 15 -1 0 0 -1 4 16 0 -1 0 0 -1 Col: 16 Row 1 0 2 0 3 0 4 0 5 0 6 0 7 0 8 0 9 0 10 0 11 0 12 -1 13 0 14 0 15 -1 16 4 POISSON_TEST: Normal end of execution. QMR_TEST: QMR uses the Quasi-Minimum Residual iterative method to approximate the solution of a linear system A * x = b. For this example, the order of the system is N = 10 The matrix A is the simple tridiagonal -1, 2, -1. The correct solution is x = [ 1, 2, ..., n]. The right hand side b is determined by computing A * x. The exact x is then replaced by a vector of all 1's for use as a starting guess. Other parameters are set as follows: The maximum number of steps is 10. The error tolerance is 0.000100 The QMR routine has returned with FLAG = 0 This indicates that the iteration has converged. The number of iterations taken was 10 The L2 norm of the error per iteration: 1 0.877421 2 0.438189 3 0.218121 4 0.136192 5 0.136382 6 0.134478 7 0.137557 8 0.144864 9 0.003773 10 0.001852 The computed solution vector X: 1 1.000000 2 2.000000 3 3.000000 4 4.000000 5 5.000000 6 6.000000 7 7.000000 8 8.000000 9 9.000000 10 10.000000 QMR_TEST: Normal end of execution. SOR_TEST: SOR uses the Successive Over-Relaxation iterative method to approximate the solution of a linear system A * x = b. For this example, the order of the system is N = 10 The matrix A is the simple tridiagonal -1, 2, -1. The correct solution is x = [ 1, 2, ..., n]. The right hand side b is determined by computing A * x. The exact x is then replaced by a vector of all 1's for use as a starting guess. Other parameters are set as follows: The maximum number of steps is 100. The error tolerance is 0.000100 The relaxation parameter W = 1.500000 The SOR routine has returned with FLAG = 0 This indicates that the iteration has converged. The number of iterations taken was 50 The L2 norm of the error per iteration: 1 0.877421 2 0.878310 3 0.523391 4 0.518431 5 0.577455 6 0.660640 7 0.761539 8 0.877187 9 1.003653 10 1.135172 11 1.264495 12 1.384239 13 1.488979 14 1.580878 15 1.655083 16 1.730295 17 1.780751 18 1.843498 19 1.867967 20 1.913663 21 1.901515 22 1.917555 23 1.845923 24 1.803451 25 1.641359 26 1.505892 27 1.260962 28 1.056683 29 0.814038 30 0.627334 31 0.456606 32 0.332306 33 0.233649 34 0.163802 35 0.112397 36 0.076701 37 0.051583 38 0.034454 39 0.022763 40 0.014932 41 0.009710 42 0.006270 43 0.004019 44 0.002560 45 0.001620 46 0.001019 47 0.000637 48 0.000396 49 0.000245 50 0.000151 The computed solution vector X: 1 1.000682 2 1.999901 3 3.000012 4 3.999999 5 5.000000 6 6.000000 7 7.000000 8 8.000000 9 9.000000 10 10.000000 SOR_TEST: Normal end of execution. WATHEN_TEST: WATHEN generates a Wathen matrix. The Wathen matrix: Col: 1 2 3 4 5 Row 1 3.477576 -3.477576 1.159192 0 0 2 -3.477576 18.547071 -3.477576 0 0 3 1.159192 -3.477576 9.942994 -6.465418 2.155139 4 0 0 -6.465418 34.482229 -6.465418 5 0 0 2.155139 -6.465418 7.849887 6 0 0 0 0 -1.384469 7 0 0 0 0 0.461490 8 -3.477576 11.591919 -4.636768 0 0 9 -4.636768 11.591919 -9.942994 21.551393 -8.620557 10 0 0 -8.620557 21.551393 -7.849887 11 0 0 0 0 -1.845959 12 1.159192 -4.636768 1.738788 0 0 13 -4.636768 9.273535 -4.636768 0 0 14 1.738788 -4.636768 3.314331 -8.620557 3.232709 15 0 0 -8.620557 17.241115 -8.620557 16 0 0 3.232709 -8.620557 2.616629 17 0 0 0 0 -1.845959 18 0 0 0 0 0.692235 19 0 0 0 0 0 20 0 0 0 0 0 21 0 0 0 0 0 22 0 0 0 0 0 23 0 0 0 0 0 24 0 0 0 0 0 25 0 0 0 0 0 26 0 0 0 0 0 27 0 0 0 0 0 28 0 0 0 0 0 29 0 0 0 0 0 Col: 6 7 8 9 10 Row 1 0 0 -3.477576 -4.636768 0 2 0 0 11.591919 11.591919 0 3 0 0 -4.636768 -9.942994 -8.620557 4 0 0 0 21.551393 21.551393 5 -1.384469 0.461490 0 -8.620557 -7.849887 6 7.383835 -1.384469 0 0 4.614897 7 -1.384469 1.384469 0 0 -1.845959 8 0 0 18.547071 9.273535 0 9 0 0 9.273535 53.029300 17.241115 10 4.614897 -1.845959 0 17.241115 41.866064 11 4.614897 -1.384469 0 0 3.691917 12 0 0 -3.477576 -4.636768 0 13 0 0 11.591919 11.591919 0 14 0 0 -4.636768 -9.942994 -8.620557 15 0 0 0 21.551393 21.551393 16 -1.845959 0.692235 0 -8.620557 -7.849887 17 3.691917 -1.845959 0 0 4.614897 18 -1.845959 0.461490 0 0 -1.845959 19 0 0 0 0 0 20 0 0 0 0 0 21 0 0 0 0 0 22 0 0 0 0 0 23 0 0 0 0 0 24 0 0 0 0 0 25 0 0 0 0 0 26 0 0 0 0 0 27 0 0 0 0 0 28 0 0 0 0 0 29 0 0 0 0 0 Col: 11 12 13 14 15 Row 1 0 1.159192 -4.636768 1.738788 0 2 0 -4.636768 9.273535 -4.636768 0 3 0 1.738788 -4.636768 3.314331 -8.620557 4 0 0 0 -8.620557 17.241115 5 -1.845959 0 0 3.232709 -8.620557 6 4.614897 0 0 0 0 7 -1.384469 0 0 0 0 8 0 -3.477576 11.591919 -4.636768 0 9 0 -4.636768 11.591919 -9.942994 21.551393 10 3.691917 0 0 -8.620557 21.551393 11 7.383835 0 0 0 0 12 0 16.497730 -16.497730 5.499243 0 13 0 -16.497730 87.987891 -16.497730 0 14 0 5.499243 -16.497730 34.924382 -18.426652 15 0 0 0 -18.426652 98.275478 16 -1.845959 0 0 6.142217 -18.426652 17 4.614897 0 0 0 0 18 -1.384469 0 0 0 0 19 0 -13.020154 43.400513 -17.360205 0 20 0 -17.360205 43.400513 -24.981388 39.870781 21 0 0 0 -15.948312 39.870781 22 0 0 0 0 0 23 0 4.340051 -17.360205 6.510077 0 24 0 -17.360205 34.720410 -17.360205 0 25 0 6.510077 -17.360205 8.327129 -15.948312 26 0 0 0 -15.948312 31.896625 27 0 0 0 5.980617 -15.948312 28 0 0 0 0 0 29 0 0 0 0 0 Col: 16 17 18 19 20 Row 1 0 0 0 0 0 2 0 0 0 0 0 3 3.232709 0 0 0 0 4 -8.620557 0 0 0 0 5 2.616629 -1.845959 0.692235 0 0 6 -1.845959 3.691917 -1.845959 0 0 7 0.692235 -1.845959 0.461490 0 0 8 0 0 0 0 0 9 -8.620557 0 0 0 0 10 -7.849887 4.614897 -1.845959 0 0 11 -1.845959 4.614897 -1.384469 0 0 12 0 0 0 -13.020154 -17.360205 13 0 0 0 43.400513 43.400513 14 6.142217 0 0 -17.360205 -24.981388 15 -18.426652 0 0 0 39.870781 16 22.084748 -3.658095 1.219365 0 -15.948312 17 -3.658095 19.509842 -3.658095 0 0 18 1.219365 -3.658095 3.658095 0 0 19 0 0 0 69.440821 34.720410 20 -15.948312 0 0 34.720410 133.234070 21 -14.234861 7.578754 -3.031502 0 31.896625 22 -3.031502 7.578754 -2.273626 0 0 23 0 0 0 -13.020154 -17.360205 24 0 0 0 43.400513 43.400513 25 5.980617 0 0 -17.360205 -24.981388 26 -15.948312 0 0 0 39.870781 27 4.744954 -3.031502 1.136813 0 -15.948312 28 -3.031502 6.063004 -3.031502 0 0 29 1.136813 -3.031502 0.757875 0 0 Col: 21 22 23 24 25 Row 1 0 0 0 0 0 2 0 0 0 0 0 3 0 0 0 0 0 4 0 0 0 0 0 5 0 0 0 0 0 6 0 0 0 0 0 7 0 0 0 0 0 8 0 0 0 0 0 9 0 0 0 0 0 10 0 0 0 0 0 11 0 0 0 0 0 12 0 0 4.340051 -17.360205 6.510077 13 0 0 -17.360205 34.720410 -17.360205 14 -15.948312 0 6.510077 -17.360205 8.327129 15 39.870781 0 0 0 -15.948312 16 -14.234861 -3.031502 0 0 5.980617 17 7.578754 7.578754 0 0 0 18 -3.031502 -2.273626 0 0 0 19 0 0 -13.020154 43.400513 -17.360205 20 31.896625 0 -17.360205 43.400513 -24.981388 21 75.919256 6.063004 0 0 -15.948312 22 6.063004 12.126007 0 0 0 23 0 0 13.020154 -13.020154 4.340051 24 0 0 -13.020154 69.440821 -13.020154 25 -15.948312 0 4.340051 -13.020154 24.981388 26 39.870781 0 0 0 -11.961234 27 -14.234861 -3.031502 0 0 3.987078 28 7.578754 7.578754 0 0 0 29 -3.031502 -2.273626 0 0 0 Col: 26 27 28 29 Row 1 0 0 0 0 2 0 0 0 0 3 0 0 0 0 4 0 0 0 0 5 0 0 0 0 6 0 0 0 0 7 0 0 0 0 8 0 0 0 0 9 0 0 0 0 10 0 0 0 0 11 0 0 0 0 12 0 0 0 0 13 0 0 0 0 14 -15.948312 5.980617 0 0 15 31.896625 -15.948312 0 0 16 -15.948312 4.744954 -3.031502 1.136813 17 0 -3.031502 6.063004 -3.031502 18 0 1.136813 -3.031502 0.757875 19 0 0 0 0 20 39.870781 -15.948312 0 0 21 39.870781 -14.234861 7.578754 -3.031502 22 0 -3.031502 7.578754 -2.273626 23 0 0 0 0 24 0 0 0 0 25 -11.961234 3.987078 0 0 26 63.793249 -11.961234 0 0 27 -11.961234 14.234861 -2.273626 0.757875 28 0 -2.273626 12.126007 -2.273626 29 0 0.757875 -2.273626 2.273626 WATHEN_TEST: Normal end of execution. TEMPLATES_TEST Normal end of execution. 27-Mar-2006 23:19:40