>> blas1_d_test

03-Jan-2011 17:57:33
BLAS1_D_TEST
Test the BLAS1_D library.
TEST01
DASUM adds the absolute values of elements of a vector.
X =
1
2
3
4
5
6
7
8
9
10

-2.000000
4.000000
-6.000000
8.000000
-10.000000
12.000000
-14.000000
16.000000
-18.000000
20.000000

DASUM ( NX, X, 1 ) = 110.000000
DASUM ( NX/2, X, 2 ) = 50.000000
DASUM ( 2, X, NX/2 ) = 14.000000
Demonstrate with a matrix A:
11.000000
-21.000000
31.000000
-41.000000
51.000000

-12.000000
22.000000
-32.000000
42.000000
-52.000000

13.000000
-23.000000
33.000000
-43.000000
53.000000

-14.000000
24.000000
-34.000000
44.000000
-54.000000

DASUM(MA,A(1:MA,2),1) = 160.000000
DASUM(NA,A(2,1:NA),1) = 90.000000
TEST02
DAXPY adds a multiple of vector X to vector Y.
X =
1
2
3
4
5
6

1.000000
2.000000
3.000000
4.000000
5.000000
6.000000

1
2
3
4
5
6

100.000000
200.000000
300.000000
400.000000
500.000000
600.000000

Y =

DAXPY ( N, 1.000000, X, 1, Y, 1 )

1
2
3
4
5
6

101.000000
202.000000
303.000000
404.000000
505.000000
606.000000

DAXPY ( N, -2.000000, X, 1, Y, 1 )
1
2
3
4
5
6

98.000000
196.000000
294.000000
392.000000
490.000000
588.000000

DAXPY ( 3, 3.000000, X, 2, Y, 1 )
1
2
3
4
5
6

103.000000
209.000000
315.000000
400.000000
500.000000
600.000000

DAXPY ( 3, -4.000000, X, 1, Y, 2 )
1
2
3
4
5
6

96.000000
200.000000
292.000000
400.000000
488.000000
600.000000

TEST03
DCOPY copies one vector into another.
X =
1
2
3
4
5
6
7
8
9
10

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

10.000000
20.000000
30.000000
40.000000
50.000000
60.000000
70.000000

Y =

8
9
10

80.000000
90.000000
100.000000

11.000000
21.000000
31.000000
41.000000
51.000000

12.000000
22.000000
32.000000
42.000000
52.000000

A =
13.000000
23.000000
33.000000
43.000000
53.000000

14.000000
24.000000
34.000000
44.000000
54.000000

15.000000
25.000000
35.000000
45.000000
55.000000

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

1.000000
2.000000
3.000000
4.000000
5.000000
60.000000
70.000000
80.000000
90.000000
100.000000

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

1.000000
20.000000
30.000000
3.000000
50.000000
60.000000
5.000000
80.000000
90.000000
100.000000

DCOPY ( 5, X, 1, A, 1 )
A =
1.000000
2.000000
3.000000
4.000000
5.000000

12.000000
22.000000
32.000000
42.000000
52.000000

13.000000
23.000000
33.000000
43.000000
53.000000

14.000000
24.000000
34.000000
44.000000
54.000000

15.000000
25.000000
35.000000
45.000000
55.000000

DCOPY ( 5, X, 2, A, 5 )
A =
1.000000
21.000000
31.000000
41.000000
51.000000
TEST04

3.000000 5.000000 7.000000 9.000000
22.000000 23.000000 24.000000 25.000000
32.000000 33.000000 34.000000 35.000000
42.000000 43.000000 44.000000 45.000000
52.000000 53.000000 54.000000 55.000000

DDOT computes the dot product of vectors.
Dot product of X and Y is -55.000000
Product of row 2 of A and X is 85.000000
Product of column 2 of A and X is 85.000000
Matrix product computed with DDOT:
50.000000
60.000000
70.000000
80.000000
90.000000

30.000000
35.000000
40.000000
45.000000
50.000000

10.000000
10.000000
10.000000
10.000000
10.000000

-10.000000
-15.000000
-20.000000
-25.000000
-30.000000

TEST05
DMACH returns some approximate machine numbers.
DMACH(1) = EPS = 2.220446e-16
DMACH(2) = TINY = 2.225074e-306
DMACH(3) = HUGE = 4.494233e+305
TEST06
DNRM2 computes the Euclidean norm of a vector.
The vector X:
1
2
3
4
5

1.000000
2.000000
3.000000
4.000000
5.000000

The 2-norm of X is 7.416198
The 2-norm of row 2 of A is 11.618950
The 2-norm of column 2 of A is 11.618950
TEST07
DROT carries out a Givens rotation.
X and Y
1
2
3
4
5
6

1.000000
2.000000
3.000000
4.000000
5.000000
6.000000

-11.000000
-8.000000
-3.000000
4.000000
13.000000
24.000000

DROT ( N, X, 1, Y, 1, 0.500000, 0.866025 )
1
2
3
4

-9.026279
-5.928203
-1.098076
5.464102

-6.366025
-5.732051
-4.098076
-1.464102

-30.000000
-40.000000
-50.000000
-60.000000
-70.000000

5
6

13.758330
23.784610

2.169873
6.803848

DROT ( N, X, 1, Y, 1, 0.090536, -0.995893 )
1
2
3
4
5
6

11.045361
8.148217
3.259287
-3.621430
-12.493933
-23.358222

0.000000
1.267500
2.716072
4.345716
6.156431
8.148217

TEST08
DROTG 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.491123
C*A+S*B = 0.980943
-S*A+C*B = 0.000000
A = 0.829509 B = 0.561695
C = 0.828025 S = 0.560691
R = 1.001792 Z = 0.560691
C*A+S*B = 1.001792
-S*A+C*B = 0.000000
A = 0.415307 B = 0.066119
C = 0.987563 S = 0.157224
R = 0.420537 Z = 0.157224
C*A+S*B = 0.420537
-S*A+C*B = 0.000000
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.000000
A = 0.043829 B = 0.633966
C = 0.068970 S = 0.997619
R = 0.635479 Z = 14.499053
C*A+S*B = 0.635479
-S*A+C*B = 0.000000
TEST09
DSCAL multiplies a vector by a scalar.
X =
1
2
3
4
5
6

1.000000
2.000000
3.000000
4.000000
5.000000
6.000000

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

5.000000
10.000000
15.000000
20.000000
25.000000
30.000000

DSCAL ( 3, -2.000000, X, 2 )
1
2
3
4
5
6

-2.000000
2.000000
-6.000000
4.000000
-10.000000
6.000000

TEST10
DSWAP swaps two vectors.
X and Y
1
2
3
4
5
6

1.000000
2.000000
3.000000
4.000000
5.000000
6.000000

100.000000
200.000000
300.000000
400.000000
500.000000
600.000000

DSWAP ( N, X, 1, Y, 1 )
X and Y
1
2
3
4
5
6

100.000000
200.000000
300.000000
400.000000
500.000000
600.000000

1.000000
2.000000
3.000000
4.000000
5.000000
6.000000

DSWAP ( 3, X, 2, Y, 1 )
X and Y
1
2
3
4
5
6

100.000000
2.000000
200.000000
4.000000
300.000000
6.000000

1.000000
3.000000
5.000000
400.000000
500.000000
600.000000

TEST11
IDAMAX returns the index of maximum magnitude;
The vector X:
1 1.000000
2 -3.000000

3
4
5
6
7
8
9
10
11

4.000000
0.000000
-4.000000
3.000000
-1.000000
-5.000000
2.000000
-2.000000
-6.000000

The index of maximum magnitude = 11
TEST12
Use IDAMAX, DAXPY, DDOT and DSCAL
in a Gauss elimination routine.
Solution (should be (1,2,3,...,n)):
1.000000
2.000000
3.000000
4.000000
5.000000
6.000000
7.000000
8.000000
9.000000
10.000000
BLAS1_D_TEST
Normal end of execution.
03-Jan-2011 17:57:33
>>