root / synthbench / euroben-dm / mod2a / mvcpln.f @ 0:839f52ef7657
History | View | Annotate | Download (4.1 kB)
1 |
Subroutine mvcpln( trans, m, n, alpha, a, lda, x, incx, |
---|---|
2 |
& beta, y, incy, wrk ) |
3 |
! ---------------------------------------------------------------------- |
4 |
! --- MVCPLN performs one of the the following matrix-vector operations |
5 |
! y := alpha*A*x + beta*y, or y := alpha*A'*x + beta*y |
6 |
! where alpha and beta are scalars, x and y are vectors and A is an |
7 |
! m by n matrix. |
8 |
! The implementation is column oriented. |
9 |
! The calling sequence is based on the Level 2 BLAS routine DGEMV. |
10 |
|
11 |
! Parameters |
12 |
! ---------- |
13 |
! TRANS - Input - Specifies the operation to be performed: |
14 |
! TRANS = 'N' implies y := alpha*A*x + beta*y |
15 |
! TRANS = 'T' implies y := alpha*A'*x + beta*y |
16 |
! M, N - Input - Dimension of the problem |
17 |
! ALPHA - Input - Specifies the scalar alpha |
18 |
! A(M,N) - Input - Contains the matrix A |
19 |
! LDA - Input - Leading Dimension of A |
20 |
! X(*) - Input - Contains the vector x |
21 |
! INCX - Input - The increment for the elements of X. In this |
22 |
! version, INCX must be 1 and is only here for |
23 |
! compatibility with Level 2 BLAS routine DGEMV |
24 |
! BETA - Input - Scalar beta; BETA = 0, then Y need not be set. |
25 |
! Y(*) - Output - Contains result vector y |
26 |
! INCY - Input - The increment for the elements of Y. In this |
27 |
! version, INCY must be 1 and is only here for |
28 |
! compatibility with Level 2 BLAS routine DGEMV |
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, 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( 'mvcpln', 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 j = 1, n |
85 |
temp = alpha * x(j) |
86 |
y(1:m) = y(1:m) + a(1:m,j)*temp |
87 |
End Do |
88 |
Else |
89 |
! ---------------------------------------------------------------------- |
90 |
! --- Form y := y + alpha*A'*x; generate partial results. |
91 |
|
92 |
mybase = offset(me) |
93 |
Do j = 1, n |
94 |
temp = zero |
95 |
wrk(j) = zero |
96 |
Do i = 1, m |
97 |
temp = temp + a(i,j)*x(i+mybase) |
98 |
End Do |
99 |
wrk(j) = wrk(j) + alpha*temp |
100 |
End Do |
101 |
! ---------------------------------------------------------------------- |
102 |
! --- Combine partial results. |
103 |
|
104 |
type = MPI_Real8 |
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 mvcpln |