3737* > \verbatim
3838* >
3939* > CHETRS_AA solves a system of linear equations A*X = B with a complex
40- * > hermitian matrix A using the factorization A = U*T*U**H or
40+ * > hermitian matrix A using the factorization A = U**H*T*U or
4141* > A = L*T*L**H computed by CHETRF_AA.
4242* > \endverbatim
4343*
4949* > UPLO is CHARACTER*1
5050* > Specifies whether the details of the factorization are stored
5151* > as an upper or lower triangular matrix.
52- * > = 'U': Upper triangular, form is A = U*T*U**H ;
52+ * > = 'U': Upper triangular, form is A = U**H*T*U ;
5353* > = 'L': Lower triangular, form is A = L*T*L**H.
5454* > \endverbatim
5555* >
@@ -200,24 +200,31 @@ SUBROUTINE CHETRS_AA( UPLO, N, NRHS, A, LDA, IPIV, B, LDB,
200200*
201201 IF ( UPPER ) THEN
202202*
203- * Solve A*X = B, where A = U*T*U**T .
203+ * Solve A*X = B, where A = U**H*T*U .
204204*
205- * P**T * B
205+ * 1) Forward substitution with U**H
206206*
207- K = 1
208- DO WHILE ( K.LE. N )
209- KP = IPIV( K )
210- IF ( KP.NE. K )
211- $ CALL CSWAP( NRHS, B( K, 1 ), LDB, B( KP, 1 ), LDB )
212- K = K + 1
213- END DO
207+ IF ( N.GT. 1 ) THEN
208+ *
209+ * Pivot, P**T * B -> B
210+ *
211+ K = 1
212+ DO WHILE ( K.LE. N )
213+ KP = IPIV( K )
214+ IF ( KP.NE. K )
215+ $ CALL CSWAP( NRHS, B( K, 1 ), LDB, B( KP, 1 ), LDB )
216+ K = K + 1
217+ END DO
214218*
215- * Compute (U \P**T * B) -> B [ (U \P**T * B) ]
219+ * Compute U**H \ B -> B [ (U**H \P**T * B) ]
220+ *
221+ CALL CTRSM( ' L' , ' U' , ' C' , ' U' , N-1 , NRHS, ONE, A( 1 , 2 ),
222+ $ LDA, B( 2 , 1 ), LDB)
223+ END IF
216224*
217- CALL CTRSM(' L' , ' U' , ' C' , ' U' , N-1 , NRHS, ONE, A( 1 , 2 ), LDA,
218- $ B( 2 , 1 ), LDB)
225+ * 2) Solve with triangular matrix T
219226*
220- * Compute T \ B -> B [ T \ (U \P**T * B) ]
227+ * Compute T \ B -> B [ T \ (U**H \P**T * B) ]
221228*
222229 CALL CLACPY( ' F' , 1 , N, A(1 , 1 ), LDA+1 , WORK(N), 1 )
223230 IF ( N.GT. 1 ) THEN
@@ -228,65 +235,82 @@ SUBROUTINE CHETRS_AA( UPLO, N, NRHS, A, LDA, IPIV, B, LDB,
228235 CALL CGTSV(N, NRHS, WORK(1 ), WORK(N), WORK(2 * N), B, LDB,
229236 $ INFO)
230237*
231- * Compute (U**T \ B) -> B [ U**T \ (T \ (U \P**T * B) ) ]
238+ * 3) Backward substitution with U
232239*
233- CALL CTRSM( ' L' , ' U' , ' N' , ' U' , N-1 , NRHS, ONE, A( 1 , 2 ), LDA,
234- $ B(2 , 1 ), LDB)
240+ IF ( N.GT. 1 ) THEN
241+ *
242+ * Compute U \ B -> B [ U \ (T \ (U**H \P**T * B) ) ]
235243*
236- * Pivot, P * B [ P * (U**T \ (T \ (U \P**T * B) )) ]
244+ CALL CTRSM( ' L' , ' U' , ' N' , ' U' , N-1 , NRHS, ONE, A( 1 , 2 ),
245+ $ LDA, B(2 , 1 ), LDB)
237246*
238- K = N
239- DO WHILE ( K.GE. 1 )
240- KP = IPIV( K )
241- IF ( KP.NE. K )
242- $ CALL CSWAP( NRHS, B( K, 1 ), LDB, B( KP, 1 ), LDB )
243- K = K - 1
244- END DO
247+ * Pivot, P * B -> B [ P * (U \ (T \ (U**H \P**T * B) )) ]
248+ *
249+ K = N
250+ DO WHILE ( K.GE. 1 )
251+ KP = IPIV( K )
252+ IF ( KP.NE. K )
253+ $ CALL CSWAP( NRHS, B( K, 1 ), LDB, B( KP, 1 ), LDB )
254+ K = K - 1
255+ END DO
256+ END IF
245257*
246258 ELSE
247259*
248- * Solve A*X = B, where A = L*T*L**T .
260+ * Solve A*X = B, where A = L*T*L**H .
249261*
250- * Pivot, P**T * B
262+ * 1) Forward substitution with L
251263*
252- K = 1
253- DO WHILE ( K.LE. N )
254- KP = IPIV( K )
255- IF ( KP.NE. K )
256- $ CALL CSWAP( NRHS, B( K, 1 ), LDB, B( KP, 1 ), LDB )
257- K = K + 1
258- END DO
264+ IF ( N.GT. 1 ) THEN
265+ *
266+ * Pivot, P**T * B -> B
267+ *
268+ K = 1
269+ DO WHILE ( K.LE. N )
270+ KP = IPIV( K )
271+ IF ( KP.NE. K )
272+ $ CALL CSWAP( NRHS, B( K, 1 ), LDB, B( KP, 1 ), LDB )
273+ K = K + 1
274+ END DO
259275*
260- * Compute (L \P**T * B) -> B [ (L \P**T * B) ]
276+ * Compute L \ B -> B [ (L \P**T * B) ]
277+ *
278+ CALL CTRSM( ' L' , ' L' , ' N' , ' U' , N-1 , NRHS, ONE, A( 2 , 1 ),
279+ $ LDA, B(2 , 1 ), LDB )
280+ END IF
261281*
262- CALL CTRSM( ' L' , ' L' , ' N' , ' U' , N-1 , NRHS, ONE, A( 2 , 1 ), LDA,
263- $ B(2 , 1 ), LDB)
282+ * 2) Solve with triangular matrix T
264283*
265284* Compute T \ B -> B [ T \ (L \P**T * B) ]
266285*
267286 CALL CLACPY( ' F' , 1 , N, A(1 , 1 ), LDA+1 , WORK(N), 1 )
268287 IF ( N.GT. 1 ) THEN
269- CALL CLACPY( ' F' , 1 , N-1 , A( 2 , 1 ), LDA+1 , WORK( 1 ), 1 )
288+ CALL CLACPY( ' F' , 1 , N-1 , A( 2 , 1 ), LDA+1 , WORK( 1 ), 1 )
270289 CALL CLACPY( ' F' , 1 , N-1 , A( 2 , 1 ), LDA+1 , WORK( 2 * N ), 1 )
271290 CALL CLACGV( N-1 , WORK( 2 * N ), 1 )
272291 END IF
273292 CALL CGTSV(N, NRHS, WORK(1 ), WORK(N), WORK(2 * N), B, LDB,
274293 $ INFO)
275294*
276- * Compute (L**T \ B) -> B [ L**T \ (T \ (L \P**T * B) ) ]
295+ * 3) Backward substitution with L**H
277296*
278- CALL CTRSM( ' L' , ' L' , ' C' , ' U' , N-1 , NRHS, ONE, A( 2 , 1 ), LDA,
279- $ B( 2 , 1 ), LDB)
297+ IF ( N.GT. 1 ) THEN
298+ *
299+ * Compute (L**H \ B) -> B [ L**H \ (T \ (L \P**T * B) ) ]
280300*
281- * Pivot, P * B [ P * (L**T \ (T \ (L \P**T * B) )) ]
301+ CALL CTRSM( ' L' , ' L' , ' C' , ' U' , N-1 , NRHS, ONE, A( 2 , 1 ),
302+ $ LDA, B( 2 , 1 ), LDB )
282303*
283- K = N
284- DO WHILE ( K.GE. 1 )
285- KP = IPIV( K )
286- IF ( KP.NE. K )
287- $ CALL CSWAP( NRHS, B( K, 1 ), LDB, B( KP, 1 ), LDB )
288- K = K - 1
289- END DO
304+ * Pivot, P * B -> B [ P * (L**H \ (T \ (L \P**T * B) )) ]
305+ *
306+ K = N
307+ DO WHILE ( K.GE. 1 )
308+ KP = IPIV( K )
309+ IF ( KP.NE. K )
310+ $ CALL CSWAP( NRHS, B( K, 1 ), LDB, B( KP, 1 ), LDB )
311+ K = K - 1
312+ END DO
313+ END IF
290314*
291315 END IF
292316*
0 commit comments