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