root / synthbench / euroben-dm / mod2a / mvrpln.f @ 0:839f52ef7657
History | View | Annotate | Download (4.1 kB)
1 |
Subroutine mvrpln( trans, m, n, alpha, a, lda, x, incx, |
---|---|
2 |
& beta, y, incy, wrk ) |
3 |
! ---------------------------------------------------------------------- |
4 |
! --- Row oriented implementation of matrix-vector multiplication |
5 |
! y = alpha*A*x + beta*y or y = alpha*A'*x + beta*y |
6 |
! The calling sequence is based on the Level 2 BLAS routine DGEMV |
7 |
|
8 |
! Parameters |
9 |
! ---------- |
10 |
! TRANS - Input - Specifies the operation to be performed: |
11 |
! TRANS = 'N' implies y = alpha*A*x + beta*y. |
12 |
! TRANS = 'T' implies y = alpha*A'*x + beta*y. |
13 |
! M, N - Input - Dimension of the problem. |
14 |
! ALPHA - Input - Specifies the scalar alpha. |
15 |
! A(M,N) - Input - Contains the matrix A. |
16 |
! LDA - Input - Leading Dimension of A. |
17 |
! X(*) - Input - Contains the vector x. |
18 |
! INCX - Input - Specifies the increment for the elements of X. |
19 |
! In this implementation, only INCX = 0 is allowed. |
20 |
! This parameter is here only for compatibility |
21 |
! with Level 2 BLAS routine DGEMV only. |
22 |
! BETA - Input - Scalar beta; BETA = 0, then Y need not be set. |
23 |
! Y(*) - Output - Contains result vector y |
24 |
! |
25 |
! INCY - Input - Specifies the increment for the elements of Y. |
26 |
! In this implementation, only INCY = 0 is allowed. |
27 |
! This parameter is here only for compatibility |
28 |
! with Level 2 BLAS routine DGEMV only. |
29 |
! WRK(*) - Workspace. NOT compatible with DGEMV! |
30 |
! ---------------------------------------------------------------------- |
31 |
Use dist_module |
32 |
Use numerics |
33 |
Character*1 :: trans |
34 |
Integer :: m, n, lda, incx, incy |
35 |
Real(l_) :: alpha, beta |
36 |
Real(l_) :: a(lda,*), x(*), y(*), wrk(*) |
37 |
! ---------------------------------------------------------------------- |
38 |
! --- Communication types: |
39 |
Include 'mpif.h' |
40 |
Integer :: com, type |
41 |
|
42 |
! --- Local constants |
43 |
Real(l_), Parameter :: zero = 0.0_l_, one = 1.0_l_ |
44 |
|
45 |
! --- Local variables |
46 |
Integer :: i, info, j, jt, k, kbase, mybase |
47 |
Real(l_) :: temp |
48 |
! ---------------------------------------------------------------------- |
49 |
! --- Test the input parameters |
50 |
|
51 |
info = 0 |
52 |
If ( trans /= 'N' .AND. trans /= 'T' ) Then |
53 |
info = 1 |
54 |
Else If ( m < 0 ) Then |
55 |
info = 2 |
56 |
Else If ( n < 0 ) Then |
57 |
info = 3 |
58 |
Else If( lda < MAX ( 1, m ) ) Then |
59 |
info = 6 |
60 |
Else If ( incx /= 1 ) Then |
61 |
info = 8 |
62 |
Else If ( incy /= 1 ) Then |
63 |
info = 11 |
64 |
End If |
65 |
If ( info /= 0 ) Then |
66 |
Call eberr ( 'mvrpln', info ) |
67 |
Return |
68 |
End If |
69 |
! ---------------------------------------------------------------------- |
70 |
! --- Start the operations; First form y := beta*y |
71 |
|
72 |
If ( beta /= one ) Then |
73 |
If ( beta == zero ) Then |
74 |
y(1:m) = zero |
75 |
Else |
76 |
y(1:m) = beta*y(1:m) |
77 |
End If |
78 |
End If |
79 |
If ( alpha == zero ) Return |
80 |
If ( trans == 'N' ) Then |
81 |
! ---------------------------------------------------------------------- |
82 |
! --- Form y := y + alpha*A*x |
83 |
|
84 |
Do i = 1, m |
85 |
temp = zero |
86 |
Do j = 1, n |
87 |
temp = temp + a(i,j) * x(j) |
88 |
End Do |
89 |
y(i) = y(i) + alpha*temp |
90 |
End Do |
91 |
Else |
92 |
! ---------------------------------------------------------------------- |
93 |
! --- Form y := y + alpha*A'*x; generate partial results. |
94 |
|
95 |
mybase = offset(me) |
96 |
wrk(1:n) = zero |
97 |
Do i = 1, m |
98 |
temp = alpha*x(mybase+i) |
99 |
wrk(1:n) = wrk(1:n) + a(i,1:n)*temp |
100 |
End Do |
101 |
! ---------------------------------------------------------------------- |
102 |
! --- Combine partial results. |
103 |
|
104 |
type = MPI_Double_Precision |
105 |
com = MPI_Comm_World |
106 |
Do k = 0, nodes - 1 |
107 |
kbase = offset(k) + 1 |
108 |
Call MPI_Reduce( wrk(kbase), y, sizes(k), type, MPI_Sum, k, |
109 |
& com, info ) |
110 |
End Do |
111 |
Endif |
112 |
! ---------------------------------------------------------------------- |
113 |
End Subroutine mvrpln |