30 March 2007 06:14:30 AM BLAS1_D_PRB: C version Double precision real arithmetic Test the routines in the BLAS1 library, the Level 1 Basic Linear Algebra Subprograms. TEST01 DASUM adds the absolute values of elements of a vector. X = 1 -2.000000 2 4.000000 3 -6.000000 4 8.000000 5 -10.000000 6 12.000000 7 -14.000000 8 16.000000 9 -18.000000 10 20.000000 DASUM ( NX, X, 1 ) = 110.000000 DASUM ( NX/2, X, 2 ) = 50.000000 DASUM ( 2, X, NX/2 ) = 14.000000 Demonstrate with a matrix A: 11.000000 -12.000000 13.000000 -14.000000 -21.000000 22.000000 -23.000000 24.000000 31.000000 -32.000000 33.000000 -34.000000 -41.000000 42.000000 -43.000000 44.000000 51.000000 -52.000000 53.000000 -54.000000 DASUM(MA,A(1,2),1) = 160.000000 DASUM(NA,A(2,1),LDA) = 90.000000 TEST02 DAXPY adds a multiple of vector X to vector Y. X = 1 1.000000 2 2.000000 3 3.000000 4 4.000000 5 5.000000 6 6.000000 Y = 1 100.000000 2 200.000000 3 300.000000 4 400.000000 5 500.000000 6 600.000000 DAXPY ( N, 1.000000, X, 1, Y, 1 ) Y = 1 101.000000 2 202.000000 3 303.000000 4 404.000000 5 505.000000 6 606.000000 DAXPY ( N, -2.000000, X, 1, Y, 1 ) Y = 1 98.000000 2 196.000000 3 294.000000 4 392.000000 5 490.000000 6 588.000000 DAXPY ( 3, 3.000000, X, 2, Y, 1 ) Y = 1 103.000000 2 209.000000 3 315.000000 4 400.000000 5 500.000000 6 600.000000 DAXPY ( 3, -4.000000, X, 1, Y, 2 ) Y = 1 96.000000 2 200.000000 3 292.000000 4 400.000000 5 488.000000 6 600.000000 TEST03 DCOPY copies one vector into another. 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 Y = 1 10.000000 2 20.000000 3 30.000000 4 40.000000 5 50.000000 6 60.000000 7 70.000000 8 80.000000 9 90.000000 10 100.000000 A = 11.000000 12.000000 13.000000 14.000000 15.000000 21.000000 22.000000 23.000000 24.000000 25.000000 31.000000 32.000000 33.000000 34.000000 35.000000 41.000000 42.000000 43.000000 44.000000 45.000000 51.000000 52.000000 53.000000 54.000000 55.000000 DCOPY ( 5, X, 1, Y, 1 ) 1 1.000000 2 2.000000 3 3.000000 4 4.000000 5 5.000000 6 60.000000 7 70.000000 8 80.000000 9 90.000000 10 100.000000 DCOPY ( 3, X, 2, Y, 3 ) 1 1.000000 2 20.000000 3 30.000000 4 3.000000 5 50.000000 6 60.000000 7 5.000000 8 80.000000 9 90.000000 10 100.000000 DCOPY ( 5, X, 1, A, 1 ) A = 1.000000 12.000000 13.000000 14.000000 15.000000 2.000000 22.000000 23.000000 24.000000 25.000000 3.000000 32.000000 33.000000 34.000000 35.000000 4.000000 42.000000 43.000000 44.000000 45.000000 5.000000 52.000000 53.000000 54.000000 55.000000 DCOPY ( 5, X, 2, A, 5 ) A = 1.000000 3.000000 5.000000 7.000000 9.000000 21.000000 22.000000 23.000000 24.000000 25.000000 31.000000 32.000000 33.000000 34.000000 35.000000 41.000000 42.000000 43.000000 44.000000 45.000000 51.000000 52.000000 53.000000 54.000000 55.000000 TEST04 DDOT computes the dot product of vectors. Dot product of X and Y is -55.000000 Product of row 2 of A and X is 85.000000 Product of column 2 of A and X is 85.000000 Matrix product computed with DDOT: 50.000000 30.000000 10.000000 -10.000000 -30.000000 60.000000 35.000000 10.000000 -15.000000 -40.000000 70.000000 40.000000 10.000000 -20.000000 -50.000000 80.000000 45.000000 10.000000 -25.000000 -60.000000 90.000000 50.000000 10.000000 -30.000000 -70.000000 TEST05 DMACH returns some approximate machine numbers. DMACH(1) = EPS = 2.220446e-16 DMACH(2) = TINY = 4.008337e-290 DMACH(3) = HUGE = 2.494800e+289 TEST06 DNRM2 computes the Euclidean norm of a vector. X = 1 1.000000 2 2.000000 3 3.000000 4 4.000000 5 5.000000 The 2-norm of X is 7.416198 The 2-norm of row 2 of A is 11.618950 The 2-norm of column 2 of A is 11.618950 TEST07 DROT carries out a Givens rotation. X and Y 1 1.000000 -11.000000 2 2.000000 -8.000000 3 3.000000 -3.000000 4 4.000000 4.000000 5 5.000000 13.000000 6 6.000000 24.000000 DROT ( N, X, 1, Y, 1, 0.500000, 0.866025 ) 1 -9.026279 -6.366025 2 -5.928203 -5.732051 3 -1.098076 -4.098076 4 5.464102 -1.464102 5 13.758330 2.169873 6 23.784610 6.803848 DROT ( N, X, 1, Y, 1, 0.090536, -0.995893 ) 1 11.045361 0.000000 2 8.148217 1.267500 3 3.259287 2.716072 4 -3.621430 4.345716 5 -12.493933 6.156431 6 -23.358222 8.148217 TEST08 DROTG generates a real Givens rotation ( C S ) * ( A ) = ( R ) ( -S C ) ( B ) ( 0 ) A = 0.218418, B = 0.956318 C = 0.218418, S = 0.956318 R = 0.218418, Z = 0.956318 C*A+S*B = 0.980943 -S*A+C*B = 0.000000 A = 0.829509, B = 0.561695 C = 0.829509, S = 0.561695 R = 0.829509, Z = 0.561695 C*A+S*B = 1.001792 -S*A+C*B = 0.000000 A = 0.415307, B = 0.066119 C = 0.415307, S = 0.066119 R = 0.415307, Z = 0.066119 C*A+S*B = 0.420537 -S*A+C*B = 0.000000 A = 0.257578, B = 0.109957 C = 0.257578, S = 0.109957 R = 0.257578, Z = 0.109957 C*A+S*B = 0.280066 -S*A+C*B = 0.000000 A = 0.043829, B = 0.633966 C = 0.043829, S = 0.633966 R = 0.043829, Z = 0.633966 C*A+S*B = 0.635479 -S*A+C*B = 0.000000 TEST09 DSCAL multiplies a vector by a scalar. X = 1 1.000000 2 2.000000 3 3.000000 4 4.000000 5 5.000000 6 6.000000 DSCAL ( N, 5.000000, X, 1 ) 1 5.000000 2 10.000000 3 15.000000 4 20.000000 5 25.000000 6 30.000000 DSCAL ( 3, -2.000000, X, 2 ) 1 -2.000000 2 2.000000 3 -6.000000 4 4.000000 5 -10.000000 6 6.000000 TEST10 DSWAP swaps two vectors. X and Y: 1 1.000000 100.000000 2 2.000000 200.000000 3 3.000000 300.000000 4 4.000000 400.000000 5 5.000000 500.000000 6 6.000000 600.000000 DSWAP ( N, X, 1, Y, 1 ) X and Y: 1 100.000000 1.000000 2 200.000000 2.000000 3 300.000000 3.000000 4 400.000000 4.000000 5 500.000000 5.000000 6 600.000000 6.000000 DSWAP ( 3, X, 2, Y, 1 ) X and Y: 1 100.000000 1.000000 2 2.000000 3.000000 3 200.000000 5.000000 4 4.000000 400.000000 5 300.000000 500.000000 6 6.000000 600.000000 TEST11 IDAMAX returns the index of maximum magnitude; The vector X: 1 2.000000 2 -2.000000 3 5.000000 4 1.000000 5 -3.000000 6 4.000000 7 0.000000 8 -4.000000 9 3.000000 10 -1.000000 11 -5.000000 The index of maximum magnitude = 3 TEST12 Use IDAMAX, DAXPY and DSCAL in a Gauss elimination routine. First five entries of solution: 1.000000 2.000000 3.000000 4.000000 5.000000 BLAS1_D_PRB: Normal end of execution. 30 March 2007 06:14:30 AM