25 March 2014 11:33:03 AM BLAS1_C_PRB: C++ version Test the BLAS1_C library. TEST01 CABS1 returns the L1 norm of a complex number. Real Imaginary Part Part CABS1(Z) 2.2493 -0.633337 2.88264 -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.0929956 -3.16607 3.25907 4.46425 0.051568 4.51582 -2.80232 3.81898 6.6213 1.53178 0.131376 1.66316 TEST02 CABS2 returns the L2 norm of a complex number. Real Imaginary Part Part CABS2(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.0929956 -3.16607 3.16744 4.46425 0.051568 4.46455 -2.80232 3.81898 4.73683 1.53178 0.131376 1.53741 TEST03 CAXPY 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 TEST04 CCOPY 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 CCOPY ( 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 CCOPY ( 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 CCOPY ( 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 CCOPY ( 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 TEST05 CDOTC 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 CDOTC(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) TEST06 CDOTU 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!): CDOTU(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) TEST07 CMACH computes several machine-dependent complex arithmetic parameters. CMACH(1) = machine epsilon = 1.19209e-07 CMACH(2) = a tiny value = 1.53329e-18 CMACH(3) = a huge value = 6.52191e+17 TEST08 CROTG 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.701706,0.546973) R = (0.985367,-0.277451) C *A+S*B = (0.985367,-0.277451) -conjg(S)*A+C*B = (0,0) 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.750521,0.331062) -conjg(S)*A+C*B = (0,0) A = (-0.139466,-0.156136) B = (-0.236066,0.0774594) C = 0.644375 S = (0.306228,0.700717) R = (-0.216436,-0.242305) C *A+S*B = (-0.216436,-0.242305) -conjg(S)*A+C*B = (-2.98023e-08,7.45058e-09) A = (0.0185991,-0.633214) B = (0.89285,0.0103136) C = 0.578632 S = (0.0145276,-0.81546) R = (0.0321433,-1.09433) C *A+S*B = (0.0321433,-1.09433) -conjg(S)*A+C*B = (0,-4.65661e-10) 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 = (2.98023e-08,-5.58794e-09) TEST09 CSCAL 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 CSCAL ( N, ((5,0)), X, 1 ) 0 50 5 1 100 10 2 150 15 3 200 20 4 250 25 5 300 30 CSCAL ( 3, ((-2,1)), X, 2 ) 0 -21 8 1 20 2 2 -63 24 3 40 4 4 -105 40 5 60 6 TEST10 CSIGN1 ( C1, C2 ) transfers the sign of complex C2 to the CABS1 magnitude of C1. C1 C2 C3 -------------------- -------------------- -------------------- (2.2493,-0.633337) (-4.21598,-1.7214) (-2.04689,-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.0929956,-3.16607) (4.46425,0.051568) (3.22185,0.0372167) (-2.80232,3.81898) (1.53178,0.131376) (6.09827,0.523029) (2.50402,-3.89966) (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.85123,-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) TEST11 CSIGN2 ( C1, C2 ) transfers the sign of complex C2 to the CABS2 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.0929956,-3.16607) (4.46425,0.051568) (3.16723,0.0365857) (-2.80232,3.81898) (1.53178,0.131376) (4.71951,0.404777) (2.50402,-3.89966) (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.85123,-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) TEST12 CSROT 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) CSROT ( 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.35899,0.535898) 4 (111.603,11.1603) (6.69873,0.669873) 5 (133.923,13.3923) (8.03848,0.803848) TEST13 CSSCAL 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 CSSCAL ( N, 5, X, 1 ) 0 50 5 1 100 10 2 150 15 3 200 20 4 250 25 5 300 30 CSSCAL ( 3, -2, X, 2 ) 0 -20 -2 1 20 2 2 -60 -6 3 40 4 4 -100 -10 5 60 6 TEST14 CSWAP 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) CSWAP ( 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) CSWAP ( 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) TEST15 ICAMAX returns the index of the entry of maximum magnitude in a complex vector. The entries and CABS1 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. TEST16 SCASUM 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) SCASUM ( NX, X, 1 ) = 27 SCASUM ( NX/2, X, 2 ) = 12 SCASUM ( 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) SCASUM ( MA, A[1,2], 1 ) = 25 SCASUM ( NA, A[2,1], MA ) = 17 TEST17 SCNRM2 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 BLAS1_C_PRB: Normal end of execution. 25 March 2014 11:33:03 AM