-
Notifications
You must be signed in to change notification settings - Fork 1
/
dtrmv.f
286 lines (286 loc) · 8.65 KB
/
dtrmv.f
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
SUBROUTINE DTRMV ( UPLO, TRANS, DIAG, N, A, LDA, X, INCX )
* .. SCALAR ARGUMENTS ..
INTEGER INCX, LDA, N
CHARACTER*1 DIAG, TRANS, UPLO
* .. ARRAY ARGUMENTS ..
DOUBLE PRECISION A( LDA, * ), X( * )
* ..
*
* PURPOSE
* =======
*
* DTRMV PERFORMS ONE OF THE MATRIX-VECTOR OPERATIONS
*
* X := A*X, OR X := A'*X,
*
* WHERE X IS AN N ELEMENT VECTOR AND A IS AN N BY N UNIT, OR NON-UNIT,
* UPPER OR LOWER TRIANGULAR MATRIX.
*
* PARAMETERS
* ==========
*
* UPLO - CHARACTER*1.
* ON ENTRY, UPLO SPECIFIES WHETHER THE MATRIX IS AN UPPER OR
* LOWER TRIANGULAR MATRIX AS FOLLOWS:
*
* UPLO = 'U' OR 'U' A IS AN UPPER TRIANGULAR MATRIX.
*
* UPLO = 'L' OR 'L' A IS A LOWER TRIANGULAR MATRIX.
*
* UNCHANGED ON EXIT.
*
* TRANS - CHARACTER*1.
* ON ENTRY, TRANS SPECIFIES THE OPERATION TO BE PERFORMED AS
* FOLLOWS:
*
* TRANS = 'N' OR 'N' X := A*X.
*
* TRANS = 'T' OR 'T' X := A'*X.
*
* TRANS = 'C' OR 'C' X := A'*X.
*
* UNCHANGED ON EXIT.
*
* DIAG - CHARACTER*1.
* ON ENTRY, DIAG SPECIFIES WHETHER OR NOT A IS UNIT
* TRIANGULAR AS FOLLOWS:
*
* DIAG = 'U' OR 'U' A IS ASSUMED TO BE UNIT TRIANGULAR.
*
* DIAG = 'N' OR 'N' A IS NOT ASSUMED TO BE UNIT
* TRIANGULAR.
*
* UNCHANGED ON EXIT.
*
* N - INTEGER.
* ON ENTRY, N SPECIFIES THE ORDER OF THE MATRIX A.
* N MUST BE AT LEAST ZERO.
* UNCHANGED ON EXIT.
*
* A - DOUBLE PRECISION ARRAY OF DIMENSION ( LDA, N ).
* BEFORE ENTRY WITH UPLO = 'U' OR 'U', THE LEADING N BY N
* UPPER TRIANGULAR PART OF THE ARRAY A MUST CONTAIN THE UPPER
* TRIANGULAR MATRIX AND THE STRICTLY LOWER TRIANGULAR PART OF
* A IS NOT REFERENCED.
* BEFORE ENTRY WITH UPLO = 'L' OR 'L', THE LEADING N BY N
* LOWER TRIANGULAR PART OF THE ARRAY A MUST CONTAIN THE LOWER
* TRIANGULAR MATRIX AND THE STRICTLY UPPER TRIANGULAR PART OF
* A IS NOT REFERENCED.
* NOTE THAT WHEN DIAG = 'U' OR 'U', THE DIAGONAL ELEMENTS OF
* A ARE NOT REFERENCED EITHER, BUT ARE ASSUMED TO BE UNITY.
* UNCHANGED ON EXIT.
*
* LDA - INTEGER.
* ON ENTRY, LDA SPECIFIES THE FIRST DIMENSION OF A AS DECLARED
* IN THE CALLING (SUB) PROGRAM. LDA MUST BE AT LEAST
* MAX( 1, N ).
* UNCHANGED ON EXIT.
*
* X - DOUBLE PRECISION ARRAY OF DIMENSION AT LEAST
* ( 1 + ( N - 1 )*ABS( INCX ) ).
* BEFORE ENTRY, THE INCREMENTED ARRAY X MUST CONTAIN THE N
* ELEMENT VECTOR X. ON EXIT, X IS OVERWRITTEN WITH THE
* TRANFORMED VECTOR X.
*
* INCX - INTEGER.
* ON ENTRY, INCX SPECIFIES THE INCREMENT FOR THE ELEMENTS OF
* X. INCX MUST NOT BE ZERO.
* UNCHANGED ON EXIT.
*
*
* LEVEL 2 BLAS ROUTINE.
*
* -- WRITTEN ON 22-OCTOBER-1986.
* JACK DONGARRA, ARGONNE NATIONAL LAB.
* JEREMY DU CROZ, NAG CENTRAL OFFICE.
* SVEN HAMMARLING, NAG CENTRAL OFFICE.
* RICHARD HANSON, SANDIA NATIONAL LABS.
*
*
* .. PARAMETERS ..
DOUBLE PRECISION ZERO
PARAMETER ( ZERO = 0.0D+0 )
* .. LOCAL SCALARS ..
DOUBLE PRECISION TEMP
INTEGER I, INFO, IX, J, JX, KX
LOGICAL NOUNIT
* .. EXTERNAL FUNCTIONS ..
LOGICAL LSAME
EXTERNAL LSAME
* .. EXTERNAL SUBROUTINES ..
EXTERNAL XERBLA
* .. INTRINSIC FUNCTIONS ..
INTRINSIC MAX
* ..
* .. EXECUTABLE STATEMENTS ..
*
* TEST THE INPUT PARAMETERS.
*
INFO = 0
IF ( .NOT.LSAME( UPLO , 'U' ).AND.
$ .NOT.LSAME( UPLO , 'L' ) )THEN
INFO = 1
ELSE IF( .NOT.LSAME( TRANS, 'N' ).AND.
$ .NOT.LSAME( TRANS, 'T' ).AND.
$ .NOT.LSAME( TRANS, 'C' ) )THEN
INFO = 2
ELSE IF( .NOT.LSAME( DIAG , 'U' ).AND.
$ .NOT.LSAME( DIAG , 'N' ) )THEN
INFO = 3
ELSE IF( N.LT.0 )THEN
INFO = 4
ELSE IF( LDA.LT.MAX( 1, N ) )THEN
INFO = 6
ELSE IF( INCX.EQ.0 )THEN
INFO = 8
END IF
IF( INFO.NE.0 )THEN
CALL XERBLA( 'DTRMV ', INFO )
RETURN
END IF
*
* QUICK RETURN IF POSSIBLE.
*
IF( N.EQ.0 )
$ RETURN
*
NOUNIT = LSAME( DIAG, 'N' )
*
* SET UP THE START POINT IN X IF THE INCREMENT IS NOT UNITY. THIS
* WILL BE ( N - 1 )*INCX TOO SMALL FOR DESCENDING LOOPS.
*
IF( INCX.LE.0 )THEN
KX = 1 - ( N - 1 )*INCX
ELSE IF( INCX.NE.1 )THEN
KX = 1
END IF
*
* START THE OPERATIONS. IN THIS VERSION THE ELEMENTS OF A ARE
* ACCESSED SEQUENTIALLY WITH ONE PASS THROUGH A.
*
IF( LSAME( TRANS, 'N' ) )THEN
*
* FORM X := A*X.
*
IF( LSAME( UPLO, 'U' ) )THEN
IF( INCX.EQ.1 )THEN
DO 20, J = 1, N
IF( X( J ).NE.ZERO )THEN
TEMP = X( J )
DO 10, I = 1, J - 1
X( I ) = X( I ) + TEMP*A( I, J )
10 CONTINUE
IF( NOUNIT )
$ X( J ) = X( J )*A( J, J )
END IF
20 CONTINUE
ELSE
JX = KX
DO 40, J = 1, N
IF( X( JX ).NE.ZERO )THEN
TEMP = X( JX )
IX = KX
DO 30, I = 1, J - 1
X( IX ) = X( IX ) + TEMP*A( I, J )
IX = IX + INCX
30 CONTINUE
IF( NOUNIT )
$ X( JX ) = X( JX )*A( J, J )
END IF
JX = JX + INCX
40 CONTINUE
END IF
ELSE
IF( INCX.EQ.1 )THEN
DO 60, J = N, 1, -1
IF( X( J ).NE.ZERO )THEN
TEMP = X( J )
DO 50, I = N, J + 1, -1
X( I ) = X( I ) + TEMP*A( I, J )
50 CONTINUE
IF( NOUNIT )
$ X( J ) = X( J )*A( J, J )
END IF
60 CONTINUE
ELSE
KX = KX + ( N - 1 )*INCX
JX = KX
DO 80, J = N, 1, -1
IF( X( JX ).NE.ZERO )THEN
TEMP = X( JX )
IX = KX
DO 70, I = N, J + 1, -1
X( IX ) = X( IX ) + TEMP*A( I, J )
IX = IX - INCX
70 CONTINUE
IF( NOUNIT )
$ X( JX ) = X( JX )*A( J, J )
END IF
JX = JX - INCX
80 CONTINUE
END IF
END IF
ELSE
*
* FORM X := A'*X.
*
IF( LSAME( UPLO, 'U' ) )THEN
IF( INCX.EQ.1 )THEN
DO 100, J = N, 1, -1
TEMP = X( J )
IF( NOUNIT )
$ TEMP = TEMP*A( J, J )
DO 90, I = J - 1, 1, -1
TEMP = TEMP + A( I, J )*X( I )
90 CONTINUE
X( J ) = TEMP
100 CONTINUE
ELSE
JX = KX + ( N - 1 )*INCX
DO 120, J = N, 1, -1
TEMP = X( JX )
IX = JX
IF( NOUNIT )
$ TEMP = TEMP*A( J, J )
DO 110, I = J - 1, 1, -1
IX = IX - INCX
TEMP = TEMP + A( I, J )*X( IX )
110 CONTINUE
X( JX ) = TEMP
JX = JX - INCX
120 CONTINUE
END IF
ELSE
IF( INCX.EQ.1 )THEN
DO 140, J = 1, N
TEMP = X( J )
IF( NOUNIT )
$ TEMP = TEMP*A( J, J )
DO 130, I = J + 1, N
TEMP = TEMP + A( I, J )*X( I )
130 CONTINUE
X( J ) = TEMP
140 CONTINUE
ELSE
JX = KX
DO 160, J = 1, N
TEMP = X( JX )
IX = JX
IF( NOUNIT )
$ TEMP = TEMP*A( J, J )
DO 150, I = J + 1, N
IX = IX + INCX
TEMP = TEMP + A( I, J )*X( IX )
150 CONTINUE
X( JX ) = TEMP
JX = JX + INCX
160 CONTINUE
END IF
END IF
END IF
*
RETURN
*
* END OF DTRMV .
*
END