blas1_c_test 16-Apr-2006 10:18:28 BLAS1_C_PRB: Tests for the MATLAB version using single precision complex arithmetic of the BLAS1, the Level 1 Basic Linear Algebra Subprograms. TEST01 CABS1 returns the L1 norm of a complex number. Real Imaginary Part Part CABS1(Z) 2.249298 -0.633337 2.882635 -4.215983 -1.721400 5.937383 2.948136 1.300451 4.248587 1.955698 1.617000 3.572698 -0.697329 -0.780678 1.478006 -1.180331 0.387297 1.567628 0.092996 -3.166071 3.259068 4.464248 0.051568 4.515817 -2.802325 3.818976 6.621301 1.531783 0.131376 1.663159 TEST02 CABS2 returns the L2 norm of a complex number. Real Imaginary Part Part CABS2(Z) 2.249298 -0.633337 2.336762 -4.215983 -1.721400 4.553870 2.948136 1.300451 3.222216 1.955698 1.617000 2.537606 -0.697329 -0.780678 1.046769 -1.180331 0.387297 1.242248 0.092996 -3.166071 3.167437 4.464248 0.051568 4.464546 -2.802325 3.818976 4.736835 1.531783 0.131376 1.537407 x = Columns 1 through 4 2.0000 0 - 1.0000i -4.0000 0 - 2.0000i Columns 5 through 8 3.0000 0 + 1.0000i 2.0000 0 + 2.0000i Columns 9 through 10 -1.0000 0 - 1.0000i TEST03 CAXPY adds a multiple of one complex vector to another. X = 1 2.000000 0.000000 2 0.000000 -1.000000 3 -4.000000 0.000000 4 0.000000 -2.000000 5 3.000000 0.000000 Y = 1 -1.000000 0.000000 2 0.000000 0.000000 3 0.000000 0.000000 4 0.000000 -3.000000 5 4.000000 0.000000 The scalar multiplier is: ( 0.500000 -1.000000 ) A * X + Y = 1 0.000000 -2.000000 2 -1.000000 -0.500000 3 -2.000000 4.000000 4 -2.000000 -4.000000 5 5.500000 -3.000000 TEST04 CCOPY copies one complex vector into another. X = 1 10.000000 1.000000 2 20.000000 2.000000 3 30.000000 3.000000 4 40.000000 4.000000 5 50.000000 5.000000 6 60.000000 6.000000 7 70.000000 7.000000 8 80.000000 8.000000 9 90.000000 9.000000 10 100.000000 10.000000 Y = 1 20.000000 2.000000 2 40.000000 4.000000 3 60.000000 6.000000 4 80.000000 8.000000 5 100.000000 10.000000 6 120.000000 12.000000 7 140.000000 14.000000 8 160.000000 16.000000 9 180.000000 18.000000 10 200.000000 20.000000 A = 10.000000 1.000000 10.000000 2.000000 10.000000 3.000000 10.000000 4.000000 10.000000 5.000000 20.000000 1.000000 20.000000 2.000000 20.000000 3.000000 20.000000 4.000000 20.000000 5.000000 30.000000 1.000000 30.000000 2.000000 30.000000 3.000000 30.000000 4.000000 30.000000 5.000000 40.000000 1.000000 40.000000 2.000000 40.000000 3.000000 40.000000 4.000000 40.000000 5.000000 50.000000 1.000000 50.000000 2.000000 50.000000 3.000000 50.000000 4.000000 50.000000 5.000000 Y = CCOPY ( 5, X, 1, Y, 1 ) 1 10.000000 1.000000 2 20.000000 2.000000 3 30.000000 3.000000 4 40.000000 4.000000 5 50.000000 5.000000 6 120.000000 12.000000 7 140.000000 14.000000 8 160.000000 16.000000 9 180.000000 18.000000 10 200.000000 20.000000 Y = CCOPY ( 3, X, 2, Y, 3 ) 1 10.000000 1.000000 2 40.000000 4.000000 3 60.000000 6.000000 4 30.000000 3.000000 5 100.000000 10.000000 6 120.000000 12.000000 7 50.000000 5.000000 8 160.000000 16.000000 9 180.000000 18.000000 10 200.000000 20.000000 A(1:5,1) = CCOPY ( 5, X, 1, A(1:5,1), 1 ) A = 10.000000 1.000000 10.000000 2.000000 10.000000 3.000000 10.000000 4.000000 10.000000 5.000000 20.000000 2.000000 20.000000 2.000000 20.000000 3.000000 20.000000 4.000000 20.000000 5.000000 30.000000 3.000000 30.000000 2.000000 30.000000 3.000000 30.000000 4.000000 30.000000 5.000000 40.000000 4.000000 40.000000 2.000000 40.000000 3.000000 40.000000 4.000000 40.000000 5.000000 50.000000 5.000000 50.000000 2.000000 50.000000 3.000000 50.000000 4.000000 50.000000 5.000000 A(1,1:5) = CCOPY ( 5, X, 2, A(1,1:5), 1 ) A = 10.000000 1.000000 30.000000 3.000000 50.000000 5.000000 70.000000 7.000000 90.000000 9.000000 20.000000 1.000000 20.000000 2.000000 20.000000 3.000000 20.000000 4.000000 20.000000 5.000000 30.000000 1.000000 30.000000 2.000000 30.000000 3.000000 30.000000 4.000000 30.000000 5.000000 40.000000 1.000000 40.000000 2.000000 40.000000 3.000000 40.000000 4.000000 40.000000 5.000000 50.000000 1.000000 50.000000 2.000000 50.000000 3.000000 50.000000 4.000000 50.000000 5.000000 TEST05 CDOTC computes the conjugated dot product of two complex vectors. X = 1 2.000000 -1.000000 2 -4.000000 -2.000000 3 3.000000 1.000000 4 2.000000 2.000000 5 -1.000000 -1.000000 The square of the norm of X, computed as CDOTC(X,X) = 45.000000 0.000000 Y = 1 -1.000000 0.000000 2 0.000000 -3.000000 3 4.000000 0.000000 4 -3.000000 4.000000 5 -2.000000 0.000000 The dot product X.Y* is 20.000000 -19.000000 TEST06 CDOTU computes the unconjugated dot product of two complex vectors. X = 1 2.000000 -1.000000 2 -4.000000 -2.000000 3 3.000000 1.000000 4 2.000000 2.000000 5 -1.000000 -1.000000 The unconjugated dot product ( X dot X ) (which is NOT the square of the norm of X!): CDOTU(X,X) = 23.000000 X = 1 -1.000000 0.000000 2 0.000000 -3.000000 3 4.000000 0.000000 4 -3.000000 4.000000 5 -2.000000 0.000000 The dot product ( X dot Y ) is -8.000000 TEST07 CMACH computes several machine-dependent complex arithmetic parameters. Warning: Divide by zero. > In cmach at 86 In blas1_c_test07 at 19 In blas1_c_test at 28 Warning: Divide by zero. > In cmach at 88 In blas1_c_test07 at 19 In blas1_c_test at 28 Warning: Divide by zero. > In cmach at 92 In blas1_c_test07 at 19 In blas1_c_test at 28 CMACH(1) = machine epsilon = 0.000000 Warning: Divide by zero. > In cmach at 86 In blas1_c_test07 at 20 In blas1_c_test at 28 Warning: Divide by zero. > In cmach at 88 In blas1_c_test07 at 20 In blas1_c_test at 28 Warning: Divide by zero. > In cmach at 92 In blas1_c_test07 at 20 In blas1_c_test at 28 CMACH(2) = a tiny value = 0.000000 Warning: Divide by zero. > In cmach at 86 In blas1_c_test07 at 21 In blas1_c_test at 28 Warning: Divide by zero. > In cmach at 88 In blas1_c_test07 at 21 In blas1_c_test at 28 Warning: Divide by zero. > In cmach at 92 In blas1_c_test07 at 21 In blas1_c_test at 28 CMACH(3) = a huge value = Inf TEST08 CSCAL multiplies a complex scalar times a vector. X = 1 10.000000 1.000000 2 20.000000 2.000000 3 30.000000 3.000000 4 40.000000 4.000000 5 50.000000 5.000000 6 60.000000 6.000000 CSCAL ( N, ( 5.000000 0.000000), X, 1 ) 1 50.000000 5.000000 2 100.000000 10.000000 3 150.000000 15.000000 4 200.000000 20.000000 5 250.000000 25.000000 6 300.000000 30.000000 CSCAL ( 3, ( -2.000000 1.000000), X, 2 ) 1 -21.000000 8.000000 2 20.000000 2.000000 3 -63.000000 24.000000 4 40.000000 4.000000 5 -105.000000 40.000000 6 60.000000 6.000000 TEST09 CSIGN1 ( C1, C2 ) transfers the sign of complex C2 to the CABS1 magnitude of C1. C1 C2 C3 -------------------- -------------------- -------------------- 2.249298 -0.633337 -4.215983 -1.721400 -2.046885 -0.835750 2.948136 1.300451 1.955698 1.617000 2.325680 1.922907 -0.697329 -0.780678 -1.180331 0.387297 -1.112852 0.365155 0.092996 -3.166071 4.464248 0.051568 3.221851 0.037217 -2.802325 3.818976 1.531783 0.131376 6.098271 0.523029 2.504022 -3.899654 1.752354 0.082775 6.114831 0.288844 2.174944 -1.333114 -1.004736 1.353553 -1.494589 2.013470 -0.487299 4.509404 -3.851225 -1.571537 -3.548639 -1.448064 -4.445906 1.328276 -3.899357 -2.755801 -3.383180 -2.391002 0.156801 -2.167782 1.245447 2.893713 0.699452 1.625131 TEST10 CSIGN2 ( C1, C2 ) transfers the sign of complex C2 to the CABS2 magnitude of C1. C1 C2 C3 -------------------- -------------------- -------------------- 2.249298 -0.633337 -4.215983 -1.721400 -2.163380 -0.883315 2.948136 1.300451 1.955698 1.617000 2.483318 2.053244 -0.697329 -0.780678 -1.180331 0.387297 -0.994595 0.326352 0.092996 -3.166071 4.464248 0.051568 3.167226 0.036586 -2.802325 3.818976 1.531783 0.131376 4.719508 0.404777 2.504022 -3.899654 1.752354 0.082775 4.629212 0.218669 2.174944 -1.333114 -1.004736 1.353553 -1.520478 2.048346 -0.487299 4.509404 -3.851225 -1.571537 -4.199476 -1.713646 -4.445906 1.328276 -3.899357 -2.755801 -3.789283 -2.678008 0.156801 -2.167782 1.245447 2.893713 0.859241 1.996390 TEST11 CSROT carries out a Givens rotation on a complex vector. X and Y 1 10.000000 1.000000 20.000000 2.000000 2 20.000000 2.000000 40.000000 4.000000 3 30.000000 3.000000 60.000000 6.000000 4 40.000000 4.000000 80.000000 8.000000 5 50.000000 5.000000 100.000000 10.000000 6 60.000000 6.000000 120.000000 12.000000 temp = Columns 1 through 4 5.0000 + 0.5000i 10.0000 + 1.0000i 15.0000 + 1.5000i 20.0000 + 2.0000i Columns 5 through 6 25.0000 + 2.5000i 30.0000 + 3.0000i cy = Columns 1 through 4 -8.6603 - 0.8660i -17.3205 - 1.7321i -25.9808 - 2.5981i -34.6410 - 3.4641i Columns 5 through 6 -43.3013 - 4.3301i -51.9615 - 5.1962i CSROT ( N, X, 1, Y, 1, 0.500000, 0.866025 ) 1 5.000000 0.500000 -8.660254 -0.866025 2 10.000000 1.000000 -17.320508 -1.732051 3 15.000000 1.500000 -25.980762 -2.598076 4 20.000000 2.000000 -34.641016 -3.464102 5 25.000000 2.500000 -43.301270 -4.330127 6 30.000000 3.000000 -51.961524 -5.196152 TEST12 CSSCAL multiplies a real scalar times a complex vector. X = 1 10.000000 1.000000 2 20.000000 2.000000 3 30.000000 3.000000 4 40.000000 4.000000 5 50.000000 5.000000 6 60.000000 6.000000 X = CSSCAL ( N, 5.000000, X, 1 ) 1 50.000000 5.000000 2 100.000000 10.000000 3 150.000000 15.000000 4 200.000000 20.000000 5 250.000000 25.000000 6 300.000000 30.000000 X = CSSCAL ( 3, -2.000000, X, 2 ) 1 -20.000000 -2.000000 2 20.000000 2.000000 3 -60.000000 -6.000000 4 40.000000 4.000000 5 -100.000000 -10.000000 6 60.000000 6.000000 TEST13 CSWAP swaps two complex vectors. X and Y 1 10.000000 1.000000 20.000000 2.000000 2 20.000000 2.000000 40.000000 4.000000 3 30.000000 3.000000 60.000000 6.000000 4 40.000000 4.000000 80.000000 8.000000 5 50.000000 5.000000 100.000000 10.000000 [ X, Y ] = CSWAP ( N, X, 1, Y, 1 ) X and Y 1 20.000000 2.000000 10.000000 1.000000 2 40.000000 4.000000 20.000000 2.000000 3 60.000000 6.000000 30.000000 3.000000 4 80.000000 8.000000 40.000000 4.000000 5 100.000000 10.000000 50.000000 5.000000 [ X, Y ] = CSWAP ( 3, X, 2, Y, 1 ) X and Y 1 20.000000 2.000000 10.000000 1.000000 2 20.000000 2.000000 30.000000 3.000000 3 40.000000 4.000000 50.000000 5.000000 4 40.000000 4.000000 80.000000 8.000000 5 60.000000 6.000000 100.000000 10.000000 TEST14 ICAMAX returns the index of the entry of maximum magnitude in a complex vector. The entries and CABS1 magnitudes: 1 2.000000 -1.000000 3.000000 2 -4.000000 -2.000000 6.000000 3 3.000000 1.000000 4.000000 4 2.000000 2.000000 4.000000 5 -1.000000 -1.000000 2.000000 The index of maximum magnitude = 2 x = Columns 1 through 4 2.0000 - 1.0000i -4.0000 - 2.0000i 3.0000 + 1.0000i 2.0000 + 2.0000i Columns 5 through 8 -1.0000 - 1.0000i -1.0000 0 - 3.0000i 4.0000 TEST15 SCASUM adds the absolute values of elements of a complex vector. X = 1 2.000000 -1.000000 2 -4.000000 -2.000000 3 3.000000 1.000000 4 2.000000 2.000000 5 -1.000000 -1.000000 6 -1.000000 0.000000 7 0.000000 -3.000000 8 4.000000 0.000000 SCASUM ( NX, X, 1 ) = 27.000000 SCASUM ( NX/2, X, 2 ) = 12.000000 SCASUM ( 2, X, NX/2 ) = 5.000000 Demonstrate with a matrix A: -3.000000 4.000000 2.000000 0.000000 3.000000 -4.000000 2.000000 0.000000 2.000000 -1.000000 -1.000000 1.000000 0.000000 5.000000 -4.000000 -2.000000 -4.000000 1.000000 -4.000000 -3.000000 0.000000 -2.000000 1.000000 3.000000 -3.000000 3.000000 -3.000000 3.000000 -1.000000 -2.000000 -1.000000 2.000000 2.000000 -4.000000 0.000000 -1.000000 0.000000 -1.000000 -2.000000 4.000000 SCASUM ( MA, A(1:MA,2), 1 ) = 18.000000 SCASUM ( NA, A(2,1:NA), 1 ) = 16.000000 TEST16 SCNRM2 returns the Euclidean norm of a complex vector. The vector X: 1 2.000000 -1.000000 2 -4.000000 -2.000000 3 3.000000 1.000000 4 2.000000 2.000000 5 -1.000000 -1.000000 The L2 norm of X is 6.708204 BLAS1_C_PRB: Normal end of execution. 16-Apr-2006 10:18:32 >>