10 February 2020 09:12:30 AM BLAS1_Z_TEST: C++ version Test the BLAS1_Z library, TEST01 DZASUM adds the absolute values of elements of a complex vector. X = 0 (2,-1) 1 (-4,-2) 2 (3,1) 3 (2,2) 4 (-1,-1) 5 (-1,0) 6 (0,-3) 7 (4,0) DZASUM ( NX, X, 1 ) = 27 DZASUM ( NX/2, X, 2 ) = 12 DZASUM ( 2, X, NX/2 ) = 5 Demonstrate with a matrix A: (-3,4) (-1,1) (0,-2) (-1,2) (2,0) (0,5) (1,3) (2,-4) (3,-4) (-4,-2) (-3,3) (0,-1) (2,0) (-4,1) (-3,3) (0,-1) (2,-1) (-4,-3) (-1,-2) (-2,4) DZASUM ( MA, A[1,2], 1 ) = 25 DZASUM ( NA, A[2,1], MA ) = 17 TEST02 DZNRM2 returns the Euclidean norm of a complex vector. The vector X: 0 (2,-1) 1 (-4,-2) 2 (3,1) 3 (2,2) 4 (-1,-1) The L2 norm of X is 6.7082 TEST03 IZAMAX returns the index of the entry of maximum magnitude in a complex vector. The entries and ZABS1 magnitudes: 0 (2,-1) 3 1 (-4,-2) 6 2 (3,1) 4 3 (2,2) 4 4 (-1,-1) 2 The index of maximum magnitude = 2 Note that this is a 1-based index. Note that the L1 norm is used. TEST04 ZABS1 returns the L1 norm of a complex number. Real Imaginary Part Part ZABS1(Z) 2.2493 -0.633337 2.88263 -4.21598 -1.7214 5.93738 2.94814 1.30045 4.24859 1.9557 1.617 3.5727 -0.697329 -0.780678 1.47801 -1.18033 0.387297 1.56763 0.0929965 -3.16607 3.25907 4.46425 0.0515681 4.51582 -2.80233 3.81898 6.6213 1.53178 0.131376 1.66316 TEST05 ZABS2 returns the L2 norm of a complex number. Real Imaginary Part Part ZABS2(Z 2.2493 -0.633337 2.33676 -4.21598 -1.7214 4.55387 2.94814 1.30045 3.22222 1.9557 1.617 2.53761 -0.697329 -0.780678 1.04677 -1.18033 0.387297 1.24225 0.0929965 -3.16607 3.16744 4.46425 0.0515681 4.46455 -2.80233 3.81898 4.73683 1.53178 0.131376 1.53741 TEST06 ZAXPY adds a multiple of one complex vector to another. X = 0 2 -1 1 -4 -2 2 3 1 3 2 2 4 -1 -1 Y = 0 -1 0 1 0 -3 2 4 0 3 -3 4 4 -2 0 The scalar multiplier is: (0.5,-1) A * X + Y = 0 -1 -2.5 1 -4 0 2 6.5 -2.5 3 0 3 4 -3.5 0.5 TEST07 ZCOPY copies one complex vector into another. X = 0 10 1 1 20 2 2 30 3 3 40 4 4 50 5 5 60 6 6 70 7 7 80 8 8 90 9 9 100 10 Y = 0 20 2 1 40 4 2 60 6 3 80 8 4 100 10 5 120 12 6 140 14 7 160 16 8 180 18 9 200 20 A = 10 1 10 2 10 3 10 4 10 5 20 1 20 2 20 3 20 4 20 5 30 1 30 2 30 3 30 4 30 5 40 1 40 2 40 3 40 4 40 5 50 1 50 2 50 3 50 4 50 5 ZCOPY ( 5, X, 1, Y, 1 ) 0 10 1 1 20 2 2 30 3 3 40 4 4 50 5 5 120 12 6 140 14 7 160 16 8 180 18 9 200 20 ZCOPY ( 3, X, 2, Y, 3 ) 0 10 1 1 40 4 2 60 6 3 30 3 4 100 10 5 120 12 6 50 5 7 160 16 8 180 18 9 200 20 ZCOPY ( 5, X, 1, A, 1 ) A = 10 1 10 2 10 3 10 4 10 5 20 2 20 2 20 3 20 4 20 5 30 3 30 2 30 3 30 4 30 5 40 4 40 2 40 3 40 4 40 5 50 5 50 2 50 3 50 4 50 5 ZCOPY ( 5, X, 2, A, 5 ) A = 10 1 30 3 50 5 70 7 90 9 20 1 20 2 20 3 20 4 20 5 30 1 30 2 30 3 30 4 30 5 40 1 40 2 40 3 40 4 40 5 50 1 50 2 50 3 50 4 50 5 TEST08 ZDOTC computes the conjugated dot product of two complex vectors. X = 0 2 -1 1 -4 -2 2 3 1 3 2 2 4 -1 -1 The square of the norm of X, computed as ZDOTC(X,X) = (45,0) Y = 0 -1 0 1 0 -3 2 4 0 3 -3 4 4 -2 0 The dot product X.Y* is (20,19) TEST09 ZDOTU computes the unconjugated dot product of two complex vectors. X = 0 2 -1 1 -4 -2 2 3 1 3 2 2 4 -1 -1 The unconjugated dot product ( X dot X ) (which is NOT the square of the norm of X!): ZDOTU(X,X) = (23,28) Y = 0 -1 0 1 0 -3 2 4 0 3 -3 4 4 -2 0 The dot product ( X dot Y ) is (-8,21) TEST10 ZDROT carries out a Givens rotation on a complex vector. X and Y 0 (10,1) (20,2) 1 (20,2) (40,4) 2 (30,3) (60,6) 3 (40,4) (80,8) 4 (50,5) (100,10) 5 (60,6) (120,12) ZDROT ( N, X, 1, Y, 1, 0.5,0.866025 ) 0 (22.3205,2.23205) (1.33975,0.133975) 1 (44.641,4.4641) (2.67949,0.267949) 2 (66.9615,6.69615) (4.01924,0.401924) 3 (89.282,8.9282) (5.35898,0.535898) 4 (111.603,11.1603) (6.69873,0.669873) 5 (133.923,13.3923) (8.03848,0.803848) TEST11 ZDSCAL multiplies a real scalar times a complex vector. X = 0 10 1 1 20 2 2 30 3 3 40 4 4 50 5 5 60 6 ZDSCAL ( N, 5, X, 1 ) 0 50 5 1 100 10 2 150 15 3 200 20 4 250 25 5 300 30 ZDSCAL ( 3, -2, X, 2 ) 0 -20 -2 1 20 2 2 -60 -6 3 40 4 4 -100 -10 5 60 6 TEST12 ZMACH computes several machine-dependent complex arithmetic parameters. ZMACH(1) = machine epsilon = 2.22045e-16 ZMACH(2) = a tiny value = 2.98334e-153 ZMACH(3) = a huge value = 3.35195e+152 TEST13 ZROTG generates a complex Givens rotation ( C S ) * ( A ) = ( R ) ( -S C ) ( B ) ( 0 ) A = (0.44986,-0.126667) B = (-0.843197,-0.34428) C = 0.45654 S = (-0.701707,0.546973) R = (0.985367,-0.277451) C *A+S*B = (0.985367,-0.277451) -conjg(S)*A+C*B = (0,2.77556e-17) A = (0.589627,0.26009) B = (0.39114,0.3234) C = 0.785623 S = (0.595383,-0.168271) R = (0.750522,0.331062) C *A+S*B = (0.750522,0.331062) -conjg(S)*A+C*B = (5.55112e-17,0) A = (-0.139466,-0.156136) B = (-0.236066,0.0774593) C = 0.644375 S = (0.306229,0.700717) R = (-0.216436,-0.242305) C *A+S*B = (-0.216436,-0.242305) -conjg(S)*A+C*B = (0,0) A = (0.0185993,-0.633214) B = (0.89285,0.0103136) C = 0.578631 S = (0.0145278,-0.81546) R = (0.0321436,-1.09433) C *A+S*B = (0.0321436,-1.09433) -conjg(S)*A+C*B = (-1.11022e-16,-8.67362e-19) A = (-0.560465,0.763795) B = (0.306357,0.0262752) C = 0.951156 S = (-0.160698,0.263588) R = (-0.589246,0.803018) C *A+S*B = (-0.589246,0.803018) -conjg(S)*A+C*B = (-5.55112e-17,-1.73472e-17) TEST14 ZSCAL multiplies a complex scalar times a vector. X = 0 10 1 1 20 2 2 30 3 3 40 4 4 50 5 5 60 6 ZSCAL ( N, ((5,0)), X, 1 ) 0 50 5 1 100 10 2 150 15 3 200 20 4 250 25 5 300 30 ZSCAL ( 3, ((-2,1)), X, 2 ) 0 -21 8 1 20 2 2 -63 24 3 40 4 4 -105 40 5 60 6 TEST15 ZSIGN1 ( C1, C2 ) transfers the sign of complex C2 to the ZABS1 magnitude of C1. C1 C2 C3 -------------------- -------------------- -------------------- (2.2493,-0.633337) (-4.21598,-1.7214) (-2.04688,-0.83575) (2.94814,1.30045) (1.9557,1.617) (2.32568,1.92291) (-0.697329,-0.780678) (-1.18033,0.387297) (-1.11285,0.365155) (0.0929965,-3.16607) (4.46425,0.0515681) (3.22185,0.0372167) (-2.80233,3.81898) (1.53178,0.131376) (6.09827,0.523029) (2.50402,-3.89965) (1.75235,0.0827754) (6.11483,0.288844) (2.17494,-1.33311) (-1.00474,1.35355) (-1.49459,2.01347) (-0.487299,4.5094) (-3.85122,-1.57154) (-3.54864,-1.44806) (-4.44591,1.32828) (-3.89936,-2.7558) (-3.38318,-2.391) (0.156801,-2.16778) (1.24545,2.89371) (0.699452,1.62513) TEST16 ZSIGN2 ( C1, C2 ) transfers the sign of complex C2 to the ZABS2 magnitude of C1. C1 C2 C3 -------------------- -------------------- -------------------- (2.2493,-0.633337) (-4.21598,-1.7214) (-2.16338,-0.883315) (2.94814,1.30045) (1.9557,1.617) (2.48332,2.05324) (-0.697329,-0.780678) (-1.18033,0.387297) (-0.994595,0.326352) (0.0929965,-3.16607) (4.46425,0.0515681) (3.16723,0.0365857) (-2.80233,3.81898) (1.53178,0.131376) (4.71951,0.404777) (2.50402,-3.89965) (1.75235,0.0827754) (4.62921,0.218669) (2.17494,-1.33311) (-1.00474,1.35355) (-1.52048,2.04835) (-0.487299,4.5094) (-3.85122,-1.57154) (-4.19948,-1.71365) (-4.44591,1.32828) (-3.89936,-2.7558) (-3.78928,-2.67801) (0.156801,-2.16778) (1.24545,2.89371) (0.859241,1.99639) TEST17 ZSWAP swaps two complex vectors. X and Y 0 (10,1) (20,2) 1 (20,2) (40,4) 2 (30,3) (60,6) 3 (40,4) (80,8) 4 (50,5) (100,10) ZSWAP ( N, X, 1, Y, 1 ) X and Y 0 (20,2) (10,1) 1 (40,4) (20,2) 2 (60,6) (30,3) 3 (80,8) (40,4) 4 (100,10) (50,5) ZSWAP ( 3, X, 2, Y, 1 ) X and Y 0 (20,2) (10,1) 1 (20,2) (30,3) 2 (40,4) (50,5) 3 (40,4) (80,8) 4 (60,6) (100,10) BLAS1_Z_TEST: Normal end of execution. 10 February 2020 09:12:30 AM