25 March 2014 11:48:35 AM BLAS1_S_PRB: C++ version Test the BLAS1_S library. TEST01 ISAMAX returns the index of maximum magnitude; The vector X: 1 2 2 -2 3 5 4 1 5 -3 6 4 7 0 8 -4 9 3 10 -1 11 -5 The index of maximum magnitude = 3 TEST02 Use ISAMAX, SAXPY and SSCAL in a Gauss elimination routine. First five entries of solution: 1 2 3 4 5 TEST03 SASUM adds the absolute values of elements of a vector. X = 1 -2 2 4 3 -6 4 8 5 -10 6 12 7 -14 8 16 9 -18 10 20 SASUM ( NX, X, 1 ) = 110 SASUM ( NX/2, X, 2 ) = 50 SASUM ( 2, X, NX/2 ) = 14 Demonstrate with a matrix A: 11 -12 13 -14 -21 22 -23 24 31 -32 33 -34 -41 42 -43 44 51 -52 53 -54 SASUM(MA,A(1,2),1) = 160 SASUM(NA,A(2,1),LDA) = 90 TEST04 SAXPY adds a multiple of vector X to vector Y. X = 1 1 2 2 3 3 4 4 5 5 6 6 Y = 1 100 2 200 3 300 4 400 5 500 6 600 SAXPY ( N, 1, X, 1, Y, 1 ) Y = 1 101 2 202 3 303 4 404 5 505 6 606 SAXPY ( N, -2, X, 1, Y, 1 ) Y = 1 98 2 196 3 294 4 392 5 490 6 588 SAXPY ( 3, 3, X, 2, Y, 1 ) Y = 1 103 2 209 3 315 4 400 5 500 6 600 SAXPY ( 3, -4, X, 1, Y, 2 ) Y = 1 96 2 200 3 292 4 400 5 488 6 600 TEST05 SCOPY copies one vector into another. X = 1 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9 10 10 Y = 1 10 2 20 3 30 4 40 5 50 6 60 7 70 8 80 9 90 10 100 A = 11 12 13 14 15 21 22 23 24 25 31 32 33 34 35 41 42 43 44 45 51 52 53 54 55 SCOPY ( 5, X, 1, Y, 1 ) 1 1 2 2 3 3 4 4 5 5 6 60 7 70 8 80 9 90 10 100 SCOPY ( 3, X, 2, Y, 3 ) 1 1 2 20 3 30 4 3 5 50 6 60 7 5 8 80 9 90 10 100 SCOPY ( 5, X, 1, A, 1 ) A = 1 12 13 14 15 2 22 23 24 25 3 32 33 34 35 4 42 43 44 45 5 52 53 54 55 SCOPY ( 5, X, 2, A, 5 ) A = 1 3 5 7 9 21 22 23 24 25 31 32 33 34 35 41 42 43 44 45 51 52 53 54 55 TEST06 SDOT computes the dot product of vectors. Dot product of X and Y is -55 Product of row 2 of A and X is 85 Product of column 2 of A and X is 85 Matrix product computed with SDOT: 50 30 10 -10 -30 60 35 10 -15 -40 70 40 10 -20 -50 80 45 10 -25 -60 90 50 10 -30 -70 TEST07 SMACH returns some approximate machine numbers. SMACH(1) = EPS = 1.19209e-07 SMACH(2) = TINY = 2.35099e-36 SMACH(3) = HUGE = 4.25353e+35 TEST08 SNRM2 computes the Euclidean norm of a vector. X = 1 1 2 2 3 3 4 4 5 5 The 2-norm of X is 7.4162 The 2-norm of row 2 of A is 11.6189 The 2-norm of column 2 of A is 11.6189 TEST09 SROT carries out a Givens rotation. X and Y 1 1 -11 2 2 -8 3 3 -3 4 4 4 5 5 13 6 6 24 SROT ( N, X, 1, Y, 1, 0.5,0.866025 ) 1 -9.02628 -6.36603 2 -5.9282 -5.73205 3 -1.09808 -4.09808 4 5.4641 -1.4641 5 13.7583 2.16987 6 23.7846 6.80385 SROT ( N, X, 1, Y, 1, 0.0905358,-0.995893 ) 1 11.0454 -5.96046e-08 2 8.14822 1.2675 3 3.25929 2.71607 4 -3.62143 4.34572 5 -12.4939 6.15643 6 -23.3582 8.14822 TEST10 SROTG generates a real Givens rotation ( C S ) * ( A ) = ( R ) ( -S C ) ( B ) ( 0 ) A = 0.218418 B = 0.956318 C = 0.222661 S = 0.974896 R = 0.980943 Z = 4.49112 C*A+S*B = 0.980943 -S*A+C*B = 0 A = 0.829509 B = 0.561695 C = 0.828025 S = 0.560691 R = 1.00179 Z = 0.560691 C*A+S*B = 1.00179 -S*A+C*B = 2.98023e-08 A = 0.415307 B = 0.0661187 C = 0.987563 S = 0.157224 R = 0.420537 Z = 0.157224 C*A+S*B = 0.420537 -S*A+C*B = 0 A = 0.257578 B = 0.109957 C = 0.919705 S = 0.392611 R = 0.280066 Z = 0.392611 C*A+S*B = 0.280066 -S*A+C*B = 0 A = 0.043829 B = 0.633966 C = 0.06897 S = 0.997619 R = 0.635479 Z = 14.4991 C*A+S*B = 0.635479 -S*A+C*B = -3.72529e-09 TEST11 SSCAL multiplies a vector by a scalar. X = 1 1 2 2 3 3 4 4 5 5 6 6 SSCAL ( N, 5, X, 1 ) 1 5 2 10 3 15 4 20 5 25 6 30 SSCAL ( 3, -2, X, 2 ) 1 -2 2 2 3 -6 4 4 5 -10 6 6 TEST12 SSWAP swaps two vectors. X and Y: 1 1 100 2 2 200 3 3 300 4 4 400 5 5 500 6 6 600 SSWAP ( N, X, 1, Y, 1 ) X and Y: 1 100 1 2 200 2 3 300 3 4 400 4 5 500 5 6 600 6 SSWAP ( 3, X, 2, Y, 1 ) X and Y: 1 100 1 2 2 3 3 200 5 4 4 400 5 300 500 6 6 600 BLAS1_S_PRB: Normal end of execution. 25 March 2014 11:48:35 AM