You are on page 1of 9

# >> blas1_c_test

03-Jan-2011 17:53:55
BLAS1_C_PRB:
Test the BLAS1_C library.
TEST01
CABS1 returns the L1 norm of a complex number.
Real
Part

Imaginary
Part

2.249298
-4.215983
2.948136
1.955698
-0.697329
-1.180331
0.092996
4.464248
-2.802325
1.531783

-0.633337
-1.721400
1.300451
1.617000
-0.780678
0.387297
-3.166071
0.051568
3.818976
0.131376

CABS1(Z)
2.882635
5.937383
4.248587
3.572698
1.478006
1.567628
3.259068
4.515817
6.621301
1.663159

TEST02
CABS2 returns the L2 norm of a complex number.
Real
Part

Imaginary
Part

2.249298
-4.215983
2.948136
1.955698
-0.697329
-1.180331
0.092996
4.464248
-2.802325
1.531783

-0.633337
-1.721400
1.300451
1.617000
-0.780678
0.387297
-3.166071
0.051568
3.818976
0.131376

CABS2(Z)
2.336762
4.553870
3.222216
2.537606
1.046769
1.242248
3.167437
4.464546
4.736835
1.537407

TEST03
CAXPY adds a multiple of one complex vector to another.
X =
1
2
3
4
5

2.000000
0.000000
-4.000000
0.000000
3.000000

0.000000
-1.000000
0.000000
-2.000000
0.000000

1
2
3
4
5

-1.000000
0.000000
0.000000
0.000000
4.000000

0.000000
0.000000
0.000000
-3.000000
0.000000

Y =

## The scalar multiplier is: ( 0.500000 -1.000000 )

A * X + Y =
1
2
3
4
5

0.000000
-1.000000
-2.000000
-2.000000
5.500000

-2.000000
-0.500000
4.000000
-4.000000
-3.000000

TEST04
CCOPY copies one complex vector into another.
X =
1
2
3
4
5
6
7
8
9
10

10.000000
20.000000
30.000000
40.000000
50.000000
60.000000
70.000000
80.000000
90.000000
100.000000

1.000000
2.000000
3.000000
4.000000
5.000000
6.000000
7.000000
8.000000
9.000000
10.000000

1
2
3
4
5
6
7
8
9
10

20.000000
40.000000
60.000000
80.000000
100.000000
120.000000
140.000000
160.000000
180.000000
200.000000

2.000000
4.000000
6.000000
8.000000
10.000000
12.000000
14.000000
16.000000
18.000000
20.000000

Y =

A =
10.000000 1.000000 10.000000
4.000000 10.000000 5.000000
20.000000 1.000000 20.000000
4.000000 20.000000 5.000000
30.000000 1.000000 30.000000
4.000000 30.000000 5.000000
40.000000 1.000000 40.000000
4.000000 40.000000 5.000000
50.000000 1.000000 50.000000
4.000000 50.000000 5.000000

10.000000 3.000000

10.000000

2.000000

20.000000 3.000000

20.000000

2.000000

30.000000 3.000000

30.000000

2.000000

40.000000 3.000000

40.000000

2.000000

50.000000 3.000000

50.000000

Y = CCOPY ( 5, X, 1, Y, 1 )

2.000000

1
2
3
4
5
6
7

10.000000
20.000000
30.000000
40.000000
50.000000
120.000000
140.000000

1.000000
2.000000
3.000000
4.000000
5.000000
12.000000
14.000000

8
9
10

160.000000
180.000000
200.000000

16.000000
18.000000
20.000000

Y = CCOPY ( 3, X, 2, Y, 3 )
1
2
3
4
5
6
7
8
9
10

10.000000
40.000000
60.000000
30.000000
100.000000
120.000000
50.000000
160.000000
180.000000
200.000000

1.000000
4.000000
6.000000
3.000000
10.000000
12.000000
5.000000
16.000000
18.000000
20.000000

## A(1:5,1) = CCOPY ( 5, X, 1, A(1:5,1), 1 )

A =
10.000000 1.000000 10.000000
4.000000 10.000000 5.000000
20.000000 2.000000 20.000000
4.000000 20.000000 5.000000
30.000000 3.000000 30.000000
4.000000 30.000000 5.000000
40.000000 4.000000 40.000000
4.000000 40.000000 5.000000
50.000000 5.000000 50.000000
4.000000 50.000000 5.000000

2.000000

10.000000 3.000000

10.000000

2.000000

20.000000 3.000000

20.000000

2.000000

30.000000 3.000000

30.000000

2.000000

40.000000 3.000000

40.000000

2.000000

50.000000 3.000000

50.000000

3.000000

50.000000 5.000000

70.000000

2.000000

20.000000 3.000000

20.000000

2.000000

30.000000 3.000000

30.000000

2.000000

40.000000 3.000000

40.000000

2.000000

50.000000 3.000000

50.000000

## A(1,1:5) = CCOPY ( 5, X, 2, A(1,1:5), 1 )

A =
10.000000 1.000000 30.000000
7.000000 90.000000 9.000000
20.000000 1.000000 20.000000
4.000000 20.000000 5.000000
30.000000 1.000000 30.000000
4.000000 30.000000 5.000000
40.000000 1.000000 40.000000
4.000000 40.000000 5.000000
50.000000 1.000000 50.000000
4.000000 50.000000 5.000000

TEST05
CDOTC computes the conjugated dot product of
two complex vectors.
X =
1
2
3
4
5

2.000000
-4.000000
3.000000
2.000000
-1.000000

-1.000000
-2.000000
1.000000
2.000000
-1.000000

## The square of the norm of X, computed as

CDOTC(X,X) = 45.000000 0.000000
Y =
1
2
3
4
5

-1.000000
0.000000
4.000000
-3.000000
-2.000000

0.000000
-3.000000
0.000000
4.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
3
4
5

2.000000
-4.000000
3.000000
2.000000
-1.000000

-1.000000
-2.000000
1.000000
2.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
2
3
4
5

-1.000000
0.000000
4.000000
-3.000000
-2.000000

0.000000
-3.000000
0.000000
4.000000
0.000000

## The dot product ( X dot Y ) is -8.000000

TEST07
CMACH computes several machine-dependent
complex arithmetic parameters.
CMACH(1) = machine epsilon = 2.220446e-16
CMACH(2) = a tiny value
= 8.900295e-306
CMACH(3) = a huge value
= 1.123558e+305
TEST08
CROTG generates a complex Givens rotation
( C S ) * ( A ) = ( R )
( -S C ) ( B ) ( 0 )
A
B
C
S
R

=
=
=
=
=

0.449860
-0.843197
0.456540
-0.701707
0.985367
C *A+S*B =
-conj(S)*A+C*B =
A =

0.589627

-0.126667
-0.344280
0.546973
-0.277451
0.985367
0.000000
0.260090

-0.277451
0.000000

B
C
S
R

0.391140
0.785623
0.595383
0.750522
C *A+S*B =
-conj(S)*A+C*B =
A
B
C
S
R

=
=
=
=

0.323400

=
=
=
=
=

-0.168271
0.331062
0.750522
0.000000

-0.139466
-0.236066
0.644375
0.306229
-0.216436
C *A+S*B =
-conj(S)*A+C*B =

-0.156136
0.077459

A
B
C
S
R

-0.633214
0.010314

0.018599
0.892850
0.578631
0.014528
0.032144
C *A+S*B =
-conj(S)*A+C*B =
A
B
C
S
R

=
=
=
=
=

0.700717
-0.242305
-0.216436
-0.000000

0.331062
0.000000

=
=
=
=
=

-0.560465
0.306357
0.951156
-0.160698
-0.589246
C *A+S*B =
-conj(S)*A+C*B =

-0.815460
-1.094331
0.032144
0.000000

-0.242305
0.000000

-1.094331
0.000000

0.763795
0.026275
0.263588
0.803018
-0.589246
0.000000

0.803018
0.000000

TEST09
CSCAL multiplies a complex scalar times a vector.
X =
1
2
3
4
5
6

10.000000
20.000000
30.000000
40.000000
50.000000
60.000000

1.000000
2.000000
3.000000
4.000000
5.000000
6.000000

1
2
3
4
5
6

50.000000
100.000000
150.000000
200.000000
250.000000
300.000000

5.000000
10.000000
15.000000
20.000000
25.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

TEST10
CSIGN1 ( C1, C2 ) transfers the sign of complex C2
to the CABS1 magnitude of C1.
C1
C2
C3
-------------------- -------------------- -------------------2.249298
2.948136
-0.697329
0.092996
-2.802325
2.504022
2.174944
-0.487299
-4.445906
0.156801

-0.633337
1.300451
-0.780678
-3.166071
3.818976
-3.899654
-1.333114
4.509404
1.328276
-2.167782

-4.215983
1.955698
-1.180331
4.464248
1.531783
1.752354
-1.004736
-3.851225
-3.899357
1.245447

-1.721400
1.617000
0.387297
0.051568
0.131376
0.082775
1.353553
-1.571537
-2.755801
2.893713

-2.046885
2.325680
-1.112852
3.221851
6.098271
6.114831
-1.494589
-3.548639
-3.383180
0.699452

-0.835750
1.922907
0.365155
0.037217
0.523029
0.288844
2.013470
-1.448064
-2.391002
1.625131

TEST11
CSIGN2 ( C1, C2 ) transfers the sign of complex C2
to the CABS2 magnitude of C1.
C1
C2
C3
-------------------- -------------------- -------------------2.249298
2.948136
-0.697329
0.092996
-2.802325
2.504022
2.174944
-0.487299
-4.445906
0.156801

-0.633337
1.300451
-0.780678
-3.166071
3.818976
-3.899654
-1.333114
4.509404
1.328276
-2.167782

-4.215983
1.955698
-1.180331
4.464248
1.531783
1.752354
-1.004736
-3.851225
-3.899357
1.245447

-1.721400
1.617000
0.387297
0.051568
0.131376
0.082775
1.353553
-1.571537
-2.755801
2.893713

-2.163380
2.483318
-0.994595
3.167226
4.719508
4.629212
-1.520478
-4.199476
-3.789283
0.859241

TEST12
CSROT carries out a Givens rotation
on a complex vector.
X and Y
1
2
3
4
5
6

10.000000
20.000000
30.000000
40.000000
50.000000
60.000000

1.000000 20.000000
2.000000 40.000000
3.000000 60.000000
4.000000 80.000000
5.000000 100.000000
6.000000 120.000000

2.000000
4.000000
6.000000
8.000000
10.000000
12.000000

1 22.320508
2 44.641016
3 66.961524
4 89.282032
5 111.602540
6 133.923048
TEST13

2.232051
4.464102
6.696152
8.928203
11.160254
13.392305

1.339746
2.679492
4.019238
5.358984
6.698730
8.038476

0.133975
0.267949
0.401924
0.535898
0.669873
0.803848

-0.883315
2.053244
0.326352
0.036586
0.404777
0.218669
2.048346
-1.713646
-2.678008
1.996390

## CSSCAL multiplies a real scalar times a complex vector.

X =
1
2
3
4
5
6

10.000000
20.000000
30.000000
40.000000
50.000000
60.000000

1.000000
2.000000
3.000000
4.000000
5.000000
6.000000

X = CSSCAL ( N, 5.000000, X, 1 )
1
2
3
4
5
6

50.000000
100.000000
150.000000
200.000000
250.000000
300.000000

5.000000
10.000000
15.000000
20.000000
25.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
TEST14
CSWAP swaps two complex vectors.
X and Y
1
2
3
4
5

10.000000
20.000000
30.000000
40.000000
50.000000

1.000000 20.000000
2.000000 40.000000
3.000000 60.000000
4.000000 80.000000
5.000000 100.000000

2.000000
4.000000
6.000000
8.000000
10.000000

[ X, Y ] = CSWAP ( N, X, 1, Y, 1 )
X and Y
1 20.000000
2 40.000000
3 60.000000
4 80.000000
5 100.000000

2.000000
4.000000
6.000000
8.000000
10.000000

10.000000
20.000000
30.000000
40.000000
50.000000

1.000000
2.000000
3.000000
4.000000
5.000000

[ X, Y ] = CSWAP ( 3, X, 2, Y, 1 )
X and Y
1
2
3
4
5

20.000000
20.000000
40.000000
40.000000
60.000000

2.000000 10.000000
2.000000 30.000000
4.000000 50.000000
4.000000 80.000000
6.000000 100.000000

1.000000
3.000000
5.000000
8.000000
10.000000

TEST15
ICAMAX returns the index of the entry of
maximum magnitude in a complex vector.
The entries and CABS1 magnitudes:
1
2
3
4
5

2.000000
-4.000000
3.000000
2.000000
-1.000000

-1.000000
-2.000000
1.000000
2.000000
-1.000000

3.000000
6.000000
4.000000
4.000000
2.000000

## The index of maximum magnitude = 2

TEST16
SCASUM adds the absolute values of elements
of a complex vector.
X =
1
2
3
4
5
6
7
8

2.000000
-4.000000
3.000000
2.000000
-1.000000
-1.000000
0.000000
4.000000

-1.000000
-2.000000
1.000000
2.000000
-1.000000
0.000000
-3.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
2.000000
3.000000
2.000000

4.000000
0.000000
-4.000000
0.000000

2.000000
-1.000000
0.000000
-4.000000

-1.000000
1.000000
5.000000
-2.000000

-4.000000
-4.000000
0.000000
1.000000

1.000000
-3.000000
-2.000000
3.000000

-3.000000
-3.000000
-1.000000
-1.000000

3.000000
3.000000
-2.000000
2.000000

2.000000
0.000000
0.000000
-2.000000

-4.000000
-1.000000
-1.000000
4.000000

## SCASUM ( MA, A(1:MA,2), 1 ) = 18.000000

SCASUM ( NA, A(2,1:NA), 1 ) = 16.000000
TEST17
SCNRM2 returns the Euclidean norm of a complex vector.
The vector X:
1
2
3
4
5

2.000000
-4.000000
3.000000
2.000000
-1.000000

-1.000000
-2.000000
1.000000
2.000000
-1.000000

## The L2 norm of X is 6.708204

BLAS1_C_PRB:
Normal end of execution.
03-Jan-2011 17:53:55
>>