root / src / blas / dgemv.f @ 2
Historique | Voir | Annoter | Télécharger (7,15 ko)
| 1 | 1 | pfleura2 | SUBROUTINE DGEMV(TRANS,M,N,ALPHA,A,LDA,X,INCX,BETA,Y,INCY) |
|---|---|---|---|
| 2 | 1 | pfleura2 | * .. Scalar Arguments .. |
| 3 | 1 | pfleura2 | DOUBLE PRECISION ALPHA,BETA |
| 4 | 1 | pfleura2 | INTEGER INCX,INCY,LDA,M,N |
| 5 | 1 | pfleura2 | CHARACTER TRANS |
| 6 | 1 | pfleura2 | * .. |
| 7 | 1 | pfleura2 | * .. Array Arguments .. |
| 8 | 1 | pfleura2 | DOUBLE PRECISION A(LDA,*),X(*),Y(*) |
| 9 | 1 | pfleura2 | * .. |
| 10 | 1 | pfleura2 | * |
| 11 | 1 | pfleura2 | * Purpose |
| 12 | 1 | pfleura2 | * ======= |
| 13 | 1 | pfleura2 | * |
| 14 | 1 | pfleura2 | * DGEMV performs one of the matrix-vector operations |
| 15 | 1 | pfleura2 | * |
| 16 | 1 | pfleura2 | * y := alpha*A*x + beta*y, or y := alpha*A'*x + beta*y, |
| 17 | 1 | pfleura2 | * |
| 18 | 1 | pfleura2 | * where alpha and beta are scalars, x and y are vectors and A is an |
| 19 | 1 | pfleura2 | * m by n matrix. |
| 20 | 1 | pfleura2 | * |
| 21 | 1 | pfleura2 | * Arguments |
| 22 | 1 | pfleura2 | * ========== |
| 23 | 1 | pfleura2 | * |
| 24 | 1 | pfleura2 | * TRANS - CHARACTER*1. |
| 25 | 1 | pfleura2 | * On entry, TRANS specifies the operation to be performed as |
| 26 | 1 | pfleura2 | * follows: |
| 27 | 1 | pfleura2 | * |
| 28 | 1 | pfleura2 | * TRANS = 'N' or 'n' y := alpha*A*x + beta*y. |
| 29 | 1 | pfleura2 | * |
| 30 | 1 | pfleura2 | * TRANS = 'T' or 't' y := alpha*A'*x + beta*y. |
| 31 | 1 | pfleura2 | * |
| 32 | 1 | pfleura2 | * TRANS = 'C' or 'c' y := alpha*A'*x + beta*y. |
| 33 | 1 | pfleura2 | * |
| 34 | 1 | pfleura2 | * Unchanged on exit. |
| 35 | 1 | pfleura2 | * |
| 36 | 1 | pfleura2 | * M - INTEGER. |
| 37 | 1 | pfleura2 | * On entry, M specifies the number of rows of the matrix A. |
| 38 | 1 | pfleura2 | * M must be at least zero. |
| 39 | 1 | pfleura2 | * Unchanged on exit. |
| 40 | 1 | pfleura2 | * |
| 41 | 1 | pfleura2 | * N - INTEGER. |
| 42 | 1 | pfleura2 | * On entry, N specifies the number of columns of the matrix A. |
| 43 | 1 | pfleura2 | * N must be at least zero. |
| 44 | 1 | pfleura2 | * Unchanged on exit. |
| 45 | 1 | pfleura2 | * |
| 46 | 1 | pfleura2 | * ALPHA - DOUBLE PRECISION. |
| 47 | 1 | pfleura2 | * On entry, ALPHA specifies the scalar alpha. |
| 48 | 1 | pfleura2 | * Unchanged on exit. |
| 49 | 1 | pfleura2 | * |
| 50 | 1 | pfleura2 | * A - DOUBLE PRECISION array of DIMENSION ( LDA, n ). |
| 51 | 1 | pfleura2 | * Before entry, the leading m by n part of the array A must |
| 52 | 1 | pfleura2 | * contain the matrix of coefficients. |
| 53 | 1 | pfleura2 | * Unchanged on exit. |
| 54 | 1 | pfleura2 | * |
| 55 | 1 | pfleura2 | * LDA - INTEGER. |
| 56 | 1 | pfleura2 | * On entry, LDA specifies the first dimension of A as declared |
| 57 | 1 | pfleura2 | * in the calling (sub) program. LDA must be at least |
| 58 | 1 | pfleura2 | * max( 1, m ). |
| 59 | 1 | pfleura2 | * Unchanged on exit. |
| 60 | 1 | pfleura2 | * |
| 61 | 1 | pfleura2 | * X - DOUBLE PRECISION array of DIMENSION at least |
| 62 | 1 | pfleura2 | * ( 1 + ( n - 1 )*abs( INCX ) ) when TRANS = 'N' or 'n' |
| 63 | 1 | pfleura2 | * and at least |
| 64 | 1 | pfleura2 | * ( 1 + ( m - 1 )*abs( INCX ) ) otherwise. |
| 65 | 1 | pfleura2 | * Before entry, the incremented array X must contain the |
| 66 | 1 | pfleura2 | * vector x. |
| 67 | 1 | pfleura2 | * Unchanged on exit. |
| 68 | 1 | pfleura2 | * |
| 69 | 1 | pfleura2 | * INCX - INTEGER. |
| 70 | 1 | pfleura2 | * On entry, INCX specifies the increment for the elements of |
| 71 | 1 | pfleura2 | * X. INCX must not be zero. |
| 72 | 1 | pfleura2 | * Unchanged on exit. |
| 73 | 1 | pfleura2 | * |
| 74 | 1 | pfleura2 | * BETA - DOUBLE PRECISION. |
| 75 | 1 | pfleura2 | * On entry, BETA specifies the scalar beta. When BETA is |
| 76 | 1 | pfleura2 | * supplied as zero then Y need not be set on input. |
| 77 | 1 | pfleura2 | * Unchanged on exit. |
| 78 | 1 | pfleura2 | * |
| 79 | 1 | pfleura2 | * Y - DOUBLE PRECISION array of DIMENSION at least |
| 80 | 1 | pfleura2 | * ( 1 + ( m - 1 )*abs( INCY ) ) when TRANS = 'N' or 'n' |
| 81 | 1 | pfleura2 | * and at least |
| 82 | 1 | pfleura2 | * ( 1 + ( n - 1 )*abs( INCY ) ) otherwise. |
| 83 | 1 | pfleura2 | * Before entry with BETA non-zero, the incremented array Y |
| 84 | 1 | pfleura2 | * must contain the vector y. On exit, Y is overwritten by the |
| 85 | 1 | pfleura2 | * updated vector y. |
| 86 | 1 | pfleura2 | * |
| 87 | 1 | pfleura2 | * INCY - INTEGER. |
| 88 | 1 | pfleura2 | * On entry, INCY specifies the increment for the elements of |
| 89 | 1 | pfleura2 | * Y. INCY must not be zero. |
| 90 | 1 | pfleura2 | * Unchanged on exit. |
| 91 | 1 | pfleura2 | * |
| 92 | 1 | pfleura2 | * |
| 93 | 1 | pfleura2 | * Level 2 Blas routine. |
| 94 | 1 | pfleura2 | * |
| 95 | 1 | pfleura2 | * -- Written on 22-October-1986. |
| 96 | 1 | pfleura2 | * Jack Dongarra, Argonne National Lab. |
| 97 | 1 | pfleura2 | * Jeremy Du Croz, Nag Central Office. |
| 98 | 1 | pfleura2 | * Sven Hammarling, Nag Central Office. |
| 99 | 1 | pfleura2 | * Richard Hanson, Sandia National Labs. |
| 100 | 1 | pfleura2 | * |
| 101 | 1 | pfleura2 | * |
| 102 | 1 | pfleura2 | * .. Parameters .. |
| 103 | 1 | pfleura2 | DOUBLE PRECISION ONE,ZERO |
| 104 | 1 | pfleura2 | PARAMETER (ONE=1.0D+0,ZERO=0.0D+0) |
| 105 | 1 | pfleura2 | * .. |
| 106 | 1 | pfleura2 | * .. Local Scalars .. |
| 107 | 1 | pfleura2 | DOUBLE PRECISION TEMP |
| 108 | 1 | pfleura2 | INTEGER I,INFO,IX,IY,J,JX,JY,KX,KY,LENX,LENY |
| 109 | 1 | pfleura2 | * .. |
| 110 | 1 | pfleura2 | * .. External Functions .. |
| 111 | 1 | pfleura2 | LOGICAL LSAME |
| 112 | 1 | pfleura2 | EXTERNAL LSAME |
| 113 | 1 | pfleura2 | * .. |
| 114 | 1 | pfleura2 | * .. External Subroutines .. |
| 115 | 1 | pfleura2 | EXTERNAL XERBLA |
| 116 | 1 | pfleura2 | * .. |
| 117 | 1 | pfleura2 | * .. Intrinsic Functions .. |
| 118 | 1 | pfleura2 | INTRINSIC MAX |
| 119 | 1 | pfleura2 | * .. |
| 120 | 1 | pfleura2 | * |
| 121 | 1 | pfleura2 | * Test the input parameters. |
| 122 | 1 | pfleura2 | * |
| 123 | 1 | pfleura2 | INFO = 0 |
| 124 | 1 | pfleura2 | IF (.NOT.LSAME(TRANS,'N') .AND. .NOT.LSAME(TRANS,'T') .AND. |
| 125 | 1 | pfleura2 | + .NOT.LSAME(TRANS,'C')) THEN |
| 126 | 1 | pfleura2 | INFO = 1 |
| 127 | 1 | pfleura2 | ELSE IF (M.LT.0) THEN |
| 128 | 1 | pfleura2 | INFO = 2 |
| 129 | 1 | pfleura2 | ELSE IF (N.LT.0) THEN |
| 130 | 1 | pfleura2 | INFO = 3 |
| 131 | 1 | pfleura2 | ELSE IF (LDA.LT.MAX(1,M)) THEN |
| 132 | 1 | pfleura2 | INFO = 6 |
| 133 | 1 | pfleura2 | ELSE IF (INCX.EQ.0) THEN |
| 134 | 1 | pfleura2 | INFO = 8 |
| 135 | 1 | pfleura2 | ELSE IF (INCY.EQ.0) THEN |
| 136 | 1 | pfleura2 | INFO = 11 |
| 137 | 1 | pfleura2 | END IF |
| 138 | 1 | pfleura2 | IF (INFO.NE.0) THEN |
| 139 | 1 | pfleura2 | CALL XERBLA('DGEMV ',INFO)
|
| 140 | 1 | pfleura2 | RETURN |
| 141 | 1 | pfleura2 | END IF |
| 142 | 1 | pfleura2 | * |
| 143 | 1 | pfleura2 | * Quick return if possible. |
| 144 | 1 | pfleura2 | * |
| 145 | 1 | pfleura2 | IF ((M.EQ.0) .OR. (N.EQ.0) .OR. |
| 146 | 1 | pfleura2 | + ((ALPHA.EQ.ZERO).AND. (BETA.EQ.ONE))) RETURN |
| 147 | 1 | pfleura2 | * |
| 148 | 1 | pfleura2 | * Set LENX and LENY, the lengths of the vectors x and y, and set |
| 149 | 1 | pfleura2 | * up the start points in X and Y. |
| 150 | 1 | pfleura2 | * |
| 151 | 1 | pfleura2 | IF (LSAME(TRANS,'N')) THEN |
| 152 | 1 | pfleura2 | LENX = N |
| 153 | 1 | pfleura2 | LENY = M |
| 154 | 1 | pfleura2 | ELSE |
| 155 | 1 | pfleura2 | LENX = M |
| 156 | 1 | pfleura2 | LENY = N |
| 157 | 1 | pfleura2 | END IF |
| 158 | 1 | pfleura2 | IF (INCX.GT.0) THEN |
| 159 | 1 | pfleura2 | KX = 1 |
| 160 | 1 | pfleura2 | ELSE |
| 161 | 1 | pfleura2 | KX = 1 - (LENX-1)*INCX |
| 162 | 1 | pfleura2 | END IF |
| 163 | 1 | pfleura2 | IF (INCY.GT.0) THEN |
| 164 | 1 | pfleura2 | KY = 1 |
| 165 | 1 | pfleura2 | ELSE |
| 166 | 1 | pfleura2 | KY = 1 - (LENY-1)*INCY |
| 167 | 1 | pfleura2 | END IF |
| 168 | 1 | pfleura2 | * |
| 169 | 1 | pfleura2 | * Start the operations. In this version the elements of A are |
| 170 | 1 | pfleura2 | * accessed sequentially with one pass through A. |
| 171 | 1 | pfleura2 | * |
| 172 | 1 | pfleura2 | * First form y := beta*y. |
| 173 | 1 | pfleura2 | * |
| 174 | 1 | pfleura2 | IF (BETA.NE.ONE) THEN |
| 175 | 1 | pfleura2 | IF (INCY.EQ.1) THEN |
| 176 | 1 | pfleura2 | IF (BETA.EQ.ZERO) THEN |
| 177 | 1 | pfleura2 | DO 10 I = 1,LENY |
| 178 | 1 | pfleura2 | Y(I) = ZERO |
| 179 | 1 | pfleura2 | 10 CONTINUE |
| 180 | 1 | pfleura2 | ELSE |
| 181 | 1 | pfleura2 | DO 20 I = 1,LENY |
| 182 | 1 | pfleura2 | Y(I) = BETA*Y(I) |
| 183 | 1 | pfleura2 | 20 CONTINUE |
| 184 | 1 | pfleura2 | END IF |
| 185 | 1 | pfleura2 | ELSE |
| 186 | 1 | pfleura2 | IY = KY |
| 187 | 1 | pfleura2 | IF (BETA.EQ.ZERO) THEN |
| 188 | 1 | pfleura2 | DO 30 I = 1,LENY |
| 189 | 1 | pfleura2 | Y(IY) = ZERO |
| 190 | 1 | pfleura2 | IY = IY + INCY |
| 191 | 1 | pfleura2 | 30 CONTINUE |
| 192 | 1 | pfleura2 | ELSE |
| 193 | 1 | pfleura2 | DO 40 I = 1,LENY |
| 194 | 1 | pfleura2 | Y(IY) = BETA*Y(IY) |
| 195 | 1 | pfleura2 | IY = IY + INCY |
| 196 | 1 | pfleura2 | 40 CONTINUE |
| 197 | 1 | pfleura2 | END IF |
| 198 | 1 | pfleura2 | END IF |
| 199 | 1 | pfleura2 | END IF |
| 200 | 1 | pfleura2 | IF (ALPHA.EQ.ZERO) RETURN |
| 201 | 1 | pfleura2 | IF (LSAME(TRANS,'N')) THEN |
| 202 | 1 | pfleura2 | * |
| 203 | 1 | pfleura2 | * Form y := alpha*A*x + y. |
| 204 | 1 | pfleura2 | * |
| 205 | 1 | pfleura2 | JX = KX |
| 206 | 1 | pfleura2 | IF (INCY.EQ.1) THEN |
| 207 | 1 | pfleura2 | DO 60 J = 1,N |
| 208 | 1 | pfleura2 | IF (X(JX).NE.ZERO) THEN |
| 209 | 1 | pfleura2 | TEMP = ALPHA*X(JX) |
| 210 | 1 | pfleura2 | DO 50 I = 1,M |
| 211 | 1 | pfleura2 | Y(I) = Y(I) + TEMP*A(I,J) |
| 212 | 1 | pfleura2 | 50 CONTINUE |
| 213 | 1 | pfleura2 | END IF |
| 214 | 1 | pfleura2 | JX = JX + INCX |
| 215 | 1 | pfleura2 | 60 CONTINUE |
| 216 | 1 | pfleura2 | ELSE |
| 217 | 1 | pfleura2 | DO 80 J = 1,N |
| 218 | 1 | pfleura2 | IF (X(JX).NE.ZERO) THEN |
| 219 | 1 | pfleura2 | TEMP = ALPHA*X(JX) |
| 220 | 1 | pfleura2 | IY = KY |
| 221 | 1 | pfleura2 | DO 70 I = 1,M |
| 222 | 1 | pfleura2 | Y(IY) = Y(IY) + TEMP*A(I,J) |
| 223 | 1 | pfleura2 | IY = IY + INCY |
| 224 | 1 | pfleura2 | 70 CONTINUE |
| 225 | 1 | pfleura2 | END IF |
| 226 | 1 | pfleura2 | JX = JX + INCX |
| 227 | 1 | pfleura2 | 80 CONTINUE |
| 228 | 1 | pfleura2 | END IF |
| 229 | 1 | pfleura2 | ELSE |
| 230 | 1 | pfleura2 | * |
| 231 | 1 | pfleura2 | * Form y := alpha*A'*x + y. |
| 232 | 1 | pfleura2 | * |
| 233 | 1 | pfleura2 | JY = KY |
| 234 | 1 | pfleura2 | IF (INCX.EQ.1) THEN |
| 235 | 1 | pfleura2 | DO 100 J = 1,N |
| 236 | 1 | pfleura2 | TEMP = ZERO |
| 237 | 1 | pfleura2 | DO 90 I = 1,M |
| 238 | 1 | pfleura2 | TEMP = TEMP + A(I,J)*X(I) |
| 239 | 1 | pfleura2 | 90 CONTINUE |
| 240 | 1 | pfleura2 | Y(JY) = Y(JY) + ALPHA*TEMP |
| 241 | 1 | pfleura2 | JY = JY + INCY |
| 242 | 1 | pfleura2 | 100 CONTINUE |
| 243 | 1 | pfleura2 | ELSE |
| 244 | 1 | pfleura2 | DO 120 J = 1,N |
| 245 | 1 | pfleura2 | TEMP = ZERO |
| 246 | 1 | pfleura2 | IX = KX |
| 247 | 1 | pfleura2 | DO 110 I = 1,M |
| 248 | 1 | pfleura2 | TEMP = TEMP + A(I,J)*X(IX) |
| 249 | 1 | pfleura2 | IX = IX + INCX |
| 250 | 1 | pfleura2 | 110 CONTINUE |
| 251 | 1 | pfleura2 | Y(JY) = Y(JY) + ALPHA*TEMP |
| 252 | 1 | pfleura2 | JY = JY + INCY |
| 253 | 1 | pfleura2 | 120 CONTINUE |
| 254 | 1 | pfleura2 | END IF |
| 255 | 1 | pfleura2 | END IF |
| 256 | 1 | pfleura2 | * |
| 257 | 1 | pfleura2 | RETURN |
| 258 | 1 | pfleura2 | * |
| 259 | 1 | pfleura2 | * End of DGEMV . |
| 260 | 1 | pfleura2 | * |
| 261 | 1 | pfleura2 | END |