LAPACK 3.12.1
LAPACK: Linear Algebra PACKage
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
clatrs3.f
Go to the documentation of this file.
1*> \brief \b CLATRS3 solves a triangular system of equations with the scale factors set to prevent overflow.
2*
3* Definition:
4* ===========
5*
6* SUBROUTINE CLATRS3( UPLO, TRANS, DIAG, NORMIN, N, NRHS, A, LDA,
7* X, LDX, SCALE, CNORM, WORK, LWORK, INFO )
8*
9* .. Scalar Arguments ..
10* CHARACTER DIAG, NORMIN, TRANS, UPLO
11* INTEGER INFO, LDA, LWORK, LDX, N, NRHS
12* ..
13* .. Array Arguments ..
14* REAL CNORM( * ), SCALE( * ), WORK( * )
15* COMPLEX A( LDA, * ), X( LDX, * )
16* ..
17*
18*
19*> \par Purpose:
20* =============
21*>
22*> \verbatim
23*>
24*> CLATRS3 solves one of the triangular systems
25*>
26*> A * X = B * diag(scale), A**T * X = B * diag(scale), or
27*> A**H * X = B * diag(scale)
28*>
29*> with scaling to prevent overflow. Here A is an upper or lower
30*> triangular matrix, A**T denotes the transpose of A, A**H denotes the
31*> conjugate transpose of A. X and B are n-by-nrhs matrices and scale
32*> is an nrhs-element vector of scaling factors. A scaling factor scale(j)
33*> is usually less than or equal to 1, chosen such that X(:,j) is less
34*> than the overflow threshold. If the matrix A is singular (A(j,j) = 0
35*> for some j), then a non-trivial solution to A*X = 0 is returned. If
36*> the system is so badly scaled that the solution cannot be represented
37*> as (1/scale(k))*X(:,k), then x(:,k) = 0 and scale(k) is returned.
38*>
39*> This is a BLAS-3 version of LATRS for solving several right
40*> hand sides simultaneously.
41*>
42*> \endverbatim
43*
44* Arguments:
45* ==========
46*
47*> \param[in] UPLO
48*> \verbatim
49*> UPLO is CHARACTER*1
50*> Specifies whether the matrix A is upper or lower triangular.
51*> = 'U': Upper triangular
52*> = 'L': Lower triangular
53*> \endverbatim
54*>
55*> \param[in] TRANS
56*> \verbatim
57*> TRANS is CHARACTER*1
58*> Specifies the operation applied to A.
59*> = 'N': Solve A * x = s*b (No transpose)
60*> = 'T': Solve A**T* x = s*b (Transpose)
61*> = 'C': Solve A**T* x = s*b (Conjugate transpose)
62*> \endverbatim
63*>
64*> \param[in] DIAG
65*> \verbatim
66*> DIAG is CHARACTER*1
67*> Specifies whether or not the matrix A is unit triangular.
68*> = 'N': Non-unit triangular
69*> = 'U': Unit triangular
70*> \endverbatim
71*>
72*> \param[in] NORMIN
73*> \verbatim
74*> NORMIN is CHARACTER*1
75*> Specifies whether CNORM has been set or not.
76*> = 'Y': CNORM contains the column norms on entry
77*> = 'N': CNORM is not set on entry. On exit, the norms will
78*> be computed and stored in CNORM.
79*> \endverbatim
80*>
81*> \param[in] N
82*> \verbatim
83*> N is INTEGER
84*> The order of the matrix A. N >= 0.
85*> \endverbatim
86*>
87*> \param[in] NRHS
88*> \verbatim
89*> NRHS is INTEGER
90*> The number of columns of X. NRHS >= 0.
91*> \endverbatim
92*>
93*> \param[in] A
94*> \verbatim
95*> A is COMPLEX array, dimension (LDA,N)
96*> The triangular matrix A. If UPLO = 'U', the leading n by n
97*> upper triangular part of the array A contains the upper
98*> triangular matrix, and the strictly lower triangular part of
99*> A is not referenced. If UPLO = 'L', the leading n by n lower
100*> triangular part of the array A contains the lower triangular
101*> matrix, and the strictly upper triangular part of A is not
102*> referenced. If DIAG = 'U', the diagonal elements of A are
103*> also not referenced and are assumed to be 1.
104*> \endverbatim
105*>
106*> \param[in] LDA
107*> \verbatim
108*> LDA is INTEGER
109*> The leading dimension of the array A. LDA >= max (1,N).
110*> \endverbatim
111*>
112*> \param[in,out] X
113*> \verbatim
114*> X is COMPLEX array, dimension (LDX,NRHS)
115*> On entry, the right hand side B of the triangular system.
116*> On exit, X is overwritten by the solution matrix X.
117*> \endverbatim
118*>
119*> \param[in] LDX
120*> \verbatim
121*> LDX is INTEGER
122*> The leading dimension of the array X. LDX >= max (1,N).
123*> \endverbatim
124*>
125*> \param[out] SCALE
126*> \verbatim
127*> SCALE is REAL array, dimension (NRHS)
128*> The scaling factor s(k) is for the triangular system
129*> A * x(:,k) = s(k)*b(:,k) or A**T* x(:,k) = s(k)*b(:,k).
130*> If SCALE = 0, the matrix A is singular or badly scaled.
131*> If A(j,j) = 0 is encountered, a non-trivial vector x(:,k)
132*> that is an exact or approximate solution to A*x(:,k) = 0
133*> is returned. If the system so badly scaled that solution
134*> cannot be presented as x(:,k) * 1/s(k), then x(:,k) = 0
135*> is returned.
136*> \endverbatim
137*>
138*> \param[in,out] CNORM
139*> \verbatim
140*> CNORM is REAL array, dimension (N)
141*>
142*> If NORMIN = 'Y', CNORM is an input argument and CNORM(j)
143*> contains the norm of the off-diagonal part of the j-th column
144*> of A. If TRANS = 'N', CNORM(j) must be greater than or equal
145*> to the infinity-norm, and if TRANS = 'T' or 'C', CNORM(j)
146*> must be greater than or equal to the 1-norm.
147*>
148*> If NORMIN = 'N', CNORM is an output argument and CNORM(j)
149*> returns the 1-norm of the offdiagonal part of the j-th column
150*> of A.
151*> \endverbatim
152*>
153*> \param[out] WORK
154*> \verbatim
155*> WORK is REAL array, dimension (MAX(1,LWORK)).
156*> On exit, if INFO = 0, WORK(1) returns the optimal size of
157*> WORK.
158*> \endverbatim
159*>
160*> \param[in] LWORK
161*> \verbatim
162*> LWORK is INTEGER
163*> The dimension of the array WORK.
164*>
165*> If MIN(N,NRHS) = 0, LWORK >= 1, else
166*> LWORK >= MAX(1, 2*NBA * MAX(NBA, MIN(NRHS, 32)), where
167*> NBA = (N + NB - 1)/NB and NB is the optimal block size.
168*>
169*> If LWORK = -1, then a workspace query is assumed; the routine
170*> only calculates the optimal dimensions of the WORK array, returns
171*> this value as the first entry of the WORK array, and no error
172*> message related to LWORK is issued by XERBLA.
173*> \endverbatim
174*>
175*> \param[out] INFO
176*> \verbatim
177*> INFO is INTEGER
178*> = 0: successful exit
179*> < 0: if INFO = -k, the k-th argument had an illegal value
180*> \endverbatim
181*
182* Authors:
183* ========
184*
185*> \author Univ. of Tennessee
186*> \author Univ. of California Berkeley
187*> \author Univ. of Colorado Denver
188*> \author NAG Ltd.
189*
190*> \ingroup latrs3
191*> \par Further Details:
192* =====================
193* \verbatim
194* The algorithm follows the structure of a block triangular solve.
195* The diagonal block is solved with a call to the robust the triangular
196* solver LATRS for every right-hand side RHS = 1, ..., NRHS
197* op(A( J, J )) * x( J, RHS ) = SCALOC * b( J, RHS ),
198* where op( A ) = A or op( A ) = A**T or op( A ) = A**H.
199* The linear block updates operate on block columns of X,
200* B( I, K ) - op(A( I, J )) * X( J, K )
201* and use GEMM. To avoid overflow in the linear block update, the worst case
202* growth is estimated. For every RHS, a scale factor s <= 1.0 is computed
203* such that
204* || s * B( I, RHS )||_oo
205* + || op(A( I, J )) ||_oo * || s * X( J, RHS ) ||_oo <= Overflow threshold
206*
207* Once all columns of a block column have been rescaled (BLAS-1), the linear
208* update is executed with GEMM without overflow.
209*
210* To limit rescaling, local scale factors track the scaling of column segments.
211* There is one local scale factor s( I, RHS ) per block row I = 1, ..., NBA
212* per right-hand side column RHS = 1, ..., NRHS. The global scale factor
213* SCALE( RHS ) is chosen as the smallest local scale factor s( I, RHS )
214* I = 1, ..., NBA.
215* A triangular solve op(A( J, J )) * x( J, RHS ) = SCALOC * b( J, RHS )
216* updates the local scale factor s( J, RHS ) := s( J, RHS ) * SCALOC. The
217* linear update of potentially inconsistently scaled vector segments
218* s( I, RHS ) * b( I, RHS ) - op(A( I, J )) * ( s( J, RHS )* x( J, RHS ) )
219* computes a consistent scaling SCAMIN = MIN( s(I, RHS ), s(J, RHS) ) and,
220* if necessary, rescales the blocks prior to calling GEMM.
221*
222* \endverbatim
223* =====================================================================
224* References:
225* C. C. Kjelgaard Mikkelsen, A. B. Schwarz and L. Karlsson (2019).
226* Parallel robust solution of triangular linear systems. Concurrency
227* and Computation: Practice and Experience, 31(19), e5064.
228*
229* Contributor:
230* Angelika Schwarz, Umea University, Sweden.
231*
232* =====================================================================
233 SUBROUTINE clatrs3( UPLO, TRANS, DIAG, NORMIN, N, NRHS, A, LDA,
234 $ X, LDX, SCALE, CNORM, WORK, LWORK, INFO )
235 IMPLICIT NONE
236*
237* .. Scalar Arguments ..
238 CHARACTER DIAG, TRANS, NORMIN, UPLO
239 INTEGER INFO, LDA, LWORK, LDX, N, NRHS
240* ..
241* .. Array Arguments ..
242 COMPLEX A( LDA, * ), X( LDX, * )
243 REAL CNORM( * ), SCALE( * ), WORK( * )
244* ..
245*
246* =====================================================================
247*
248* .. Parameters ..
249 REAL ZERO, ONE
250 parameter( zero = 0.0e+0, one = 1.0e+0 )
251 COMPLEX CZERO, CONE
252 parameter( czero = ( 0.0e+0, 0.0e+0 ) )
253 parameter( cone = ( 1.0e+0, 0.0e+0 ) )
254 INTEGER NBMAX, NBMIN, NBRHS, NRHSMIN
255 parameter( nrhsmin = 2, nbrhs = 32 )
256 parameter( nbmin = 8, nbmax = 64 )
257* ..
258* .. Local Arrays ..
259 REAL W( NBMAX ), XNRM( NBRHS )
260* ..
261* .. Local Scalars ..
262 LOGICAL LQUERY, NOTRAN, NOUNIT, UPPER
263 INTEGER AWRK, I, IFIRST, IINC, ILAST, II, I1, I2, J,
264 $ jfirst, jinc, jlast, j1, j2, k, kk, k1, k2,
265 $ lanrm, lds, lscale, nb, nba, nbx, rhs, lwmin
266 REAL ANRM, BIGNUM, BNRM, RSCAL, SCAL, SCALOC,
267 $ scamin, smlnum, tmax
268* ..
269* .. External Functions ..
270 LOGICAL LSAME
271 INTEGER ILAENV
272 REAL SLAMCH, CLANGE, SLARMM,
274 EXTERNAL ilaenv, lsame, slamch,
275 $ clange, slarmm, sroundup_lwork
276* ..
277* .. External Subroutines ..
278 EXTERNAL clatrs, csscal, xerbla
279* ..
280* .. Intrinsic Functions ..
281 INTRINSIC abs, max, min
282* ..
283* .. Executable Statements ..
284*
285 info = 0
286 upper = lsame( uplo, 'U' )
287 notran = lsame( trans, 'N' )
288 nounit = lsame( diag, 'N' )
289 lquery = ( lwork.EQ.-1 )
290*
291* Partition A and X into blocks.
292*
293 nb = max( nbmin, ilaenv( 1, 'CLATRS', '', n, n, -1, -1 ) )
294 nb = min( nbmax, nb )
295 nba = max( 1, (n + nb - 1) / nb )
296 nbx = max( 1, (nrhs + nbrhs - 1) / nbrhs )
297*
298* Compute the workspace
299*
300* The workspace comprises two parts.
301* The first part stores the local scale factors. Each simultaneously
302* computed right-hand side requires one local scale factor per block
303* row. WORK( I + KK * LDS ) is the scale factor of the vector
304* segment associated with the I-th block row and the KK-th vector
305* in the block column.
306*
307 lscale = nba * max( nba, min( nrhs, nbrhs ) )
308 lds = nba
309*
310* The second part stores upper bounds of the triangular A. There are
311* a total of NBA x NBA blocks, of which only the upper triangular
312* part or the lower triangular part is referenced. The upper bound of
313* the block A( I, J ) is stored as WORK( AWRK + I + J * NBA ).
314*
315 lanrm = nba * nba
316 awrk = lscale
317*
318 IF( min( n, nrhs ).EQ.0 ) THEN
319 lwmin = 1
320 ELSE
321 lwmin = lscale + lanrm
322 END IF
323 work( 1 ) = sroundup_lwork( lwmin )
324*
325* Test the input parameters.
326*
327 IF( .NOT.upper .AND. .NOT.lsame( uplo, 'L' ) ) THEN
328 info = -1
329 ELSE IF( .NOT.notran .AND. .NOT.lsame( trans, 'T' ) .AND. .NOT.
330 $ lsame( trans, 'C' ) ) THEN
331 info = -2
332 ELSE IF( .NOT.nounit .AND. .NOT.lsame( diag, 'U' ) ) THEN
333 info = -3
334 ELSE IF( .NOT.lsame( normin, 'Y' ) .AND. .NOT.
335 $ lsame( normin, 'N' ) ) THEN
336 info = -4
337 ELSE IF( n.LT.0 ) THEN
338 info = -5
339 ELSE IF( nrhs.LT.0 ) THEN
340 info = -6
341 ELSE IF( lda.LT.max( 1, n ) ) THEN
342 info = -8
343 ELSE IF( ldx.LT.max( 1, n ) ) THEN
344 info = -10
345 ELSE IF( .NOT.lquery .AND. lwork.LT.lwmin ) THEN
346 info = -14
347 END IF
348 IF( info.NE.0 ) THEN
349 CALL xerbla( 'CLATRS3', -info )
350 RETURN
351 ELSE IF( lquery ) THEN
352 RETURN
353 END IF
354*
355* Initialize scaling factors
356*
357 DO kk = 1, nrhs
358 scale( kk ) = one
359 END DO
360*
361* Quick return if possible
362*
363 IF( min( n, nrhs ).EQ.0 )
364 $ RETURN
365*
366* Determine machine dependent constant to control overflow.
367*
368 bignum = slamch( 'Overflow' )
369 smlnum = slamch( 'Safe Minimum' )
370*
371* Use unblocked code for small problems
372*
373 IF( nrhs.LT.nrhsmin ) THEN
374 CALL clatrs( uplo, trans, diag, normin, n, a, lda, x( 1,
375 $ 1 ),
376 $ scale( 1 ), cnorm, info )
377 DO k = 2, nrhs
378 CALL clatrs( uplo, trans, diag, 'Y', n, a, lda, x( 1,
379 $ k ),
380 $ scale( k ), cnorm, info )
381 END DO
382 RETURN
383 END IF
384*
385* Compute norms of blocks of A excluding diagonal blocks and find
386* the block with the largest norm TMAX.
387*
388 tmax = zero
389 DO j = 1, nba
390 j1 = (j-1)*nb + 1
391 j2 = min( j*nb, n ) + 1
392 IF ( upper ) THEN
393 ifirst = 1
394 ilast = j - 1
395 ELSE
396 ifirst = j + 1
397 ilast = nba
398 END IF
399 DO i = ifirst, ilast
400 i1 = (i-1)*nb + 1
401 i2 = min( i*nb, n ) + 1
402*
403* Compute upper bound of A( I1:I2-1, J1:J2-1 ).
404*
405 IF( notran ) THEN
406 anrm = clange( 'I', i2-i1, j2-j1, a( i1, j1 ), lda,
407 $ w )
408 work( awrk + i+(j-1)*nba ) = anrm
409 ELSE
410 anrm = clange( '1', i2-i1, j2-j1, a( i1, j1 ), lda,
411 $ w )
412 work( awrk + j+(i-1)*nba ) = anrm
413 END IF
414 tmax = max( tmax, anrm )
415 END DO
416 END DO
417*
418 IF( .NOT. tmax.LE.slamch('Overflow') ) THEN
419*
420* Some matrix entries have huge absolute value. At least one upper
421* bound norm( A(I1:I2-1, J1:J2-1), 'I') is not a valid floating-point
422* number, either due to overflow in LANGE or due to Inf in A.
423* Fall back to LATRS. Set normin = 'N' for every right-hand side to
424* force computation of TSCAL in LATRS to avoid the likely overflow
425* in the computation of the column norms CNORM.
426*
427 DO k = 1, nrhs
428 CALL clatrs( uplo, trans, diag, 'N', n, a, lda, x( 1,
429 $ k ),
430 $ scale( k ), cnorm, info )
431 END DO
432 RETURN
433 END IF
434*
435* Every right-hand side requires workspace to store NBA local scale
436* factors. To save workspace, X is computed successively in block columns
437* of width NBRHS, requiring a total of NBA x NBRHS space. If sufficient
438* workspace is available, larger values of NBRHS or NBRHS = NRHS are viable.
439 DO k = 1, nbx
440* Loop over block columns (index = K) of X and, for column-wise scalings,
441* over individual columns (index = KK).
442* K1: column index of the first column in X( J, K )
443* K2: column index of the first column in X( J, K+1 )
444* so the K2 - K1 is the column count of the block X( J, K )
445 k1 = (k-1)*nbrhs + 1
446 k2 = min( k*nbrhs, nrhs ) + 1
447*
448* Initialize local scaling factors of current block column X( J, K )
449*
450 DO kk = 1, k2-k1
451 DO i = 1, nba
452 work( i+kk*lds ) = one
453 END DO
454 END DO
455*
456 IF( notran ) THEN
457*
458* Solve A * X(:, K1:K2-1) = B * diag(scale(K1:K2-1))
459*
460 IF( upper ) THEN
461 jfirst = nba
462 jlast = 1
463 jinc = -1
464 ELSE
465 jfirst = 1
466 jlast = nba
467 jinc = 1
468 END IF
469 ELSE
470*
471* Solve op(A) * X(:, K1:K2-1) = B * diag(scale(K1:K2-1))
472* where op(A) = A**T or op(A) = A**H
473*
474 IF( upper ) THEN
475 jfirst = 1
476 jlast = nba
477 jinc = 1
478 ELSE
479 jfirst = nba
480 jlast = 1
481 jinc = -1
482 END IF
483 END IF
484
485 DO j = jfirst, jlast, jinc
486* J1: row index of the first row in A( J, J )
487* J2: row index of the first row in A( J+1, J+1 )
488* so that J2 - J1 is the row count of the block A( J, J )
489 j1 = (j-1)*nb + 1
490 j2 = min( j*nb, n ) + 1
491*
492* Solve op(A( J, J )) * X( J, RHS ) = SCALOC * B( J, RHS )
493*
494 DO kk = 1, k2-k1
495 rhs = k1 + kk - 1
496 IF( kk.EQ.1 ) THEN
497 CALL clatrs( uplo, trans, diag, 'N', j2-j1,
498 $ a( j1, j1 ), lda, x( j1, rhs ),
499 $ scaloc, cnorm, info )
500 ELSE
501 CALL clatrs( uplo, trans, diag, 'Y', j2-j1,
502 $ a( j1, j1 ), lda, x( j1, rhs ),
503 $ scaloc, cnorm, info )
504 END IF
505* Find largest absolute value entry in the vector segment
506* X( J1:J2-1, RHS ) as an upper bound for the worst case
507* growth in the linear updates.
508 xnrm( kk ) = clange( 'I', j2-j1, 1, x( j1, rhs ),
509 $ ldx, w )
510*
511 IF( scaloc .EQ. zero ) THEN
512* LATRS found that A is singular through A(j,j) = 0.
513* Reset the computation x(1:n) = 0, x(j) = 1, SCALE = 0
514* and compute op(A)*x = 0. Note that X(J1:J2-1, KK) is
515* set by LATRS.
516 scale( rhs ) = zero
517 DO ii = 1, j1-1
518 x( ii, kk ) = czero
519 END DO
520 DO ii = j2, n
521 x( ii, kk ) = czero
522 END DO
523* Discard the local scale factors.
524 DO ii = 1, nba
525 work( ii+kk*lds ) = one
526 END DO
527 scaloc = one
528 ELSE IF( scaloc*work( j+kk*lds ) .EQ. zero ) THEN
529* LATRS computed a valid scale factor, but combined with
530* the current scaling the solution does not have a
531* scale factor > 0.
532*
533* Set WORK( J+KK*LDS ) to smallest valid scale
534* factor and increase SCALOC accordingly.
535 scal = work( j+kk*lds ) / smlnum
536 scaloc = scaloc * scal
537 work( j+kk*lds ) = smlnum
538* If LATRS overestimated the growth, x may be
539* rescaled to preserve a valid combined scale
540* factor WORK( J, KK ) > 0.
541 rscal = one / scaloc
542 IF( xnrm( kk )*rscal .LE. bignum ) THEN
543 xnrm( kk ) = xnrm( kk ) * rscal
544 CALL csscal( j2-j1, rscal, x( j1, rhs ), 1 )
545 scaloc = one
546 ELSE
547* The system op(A) * x = b is badly scaled and its
548* solution cannot be represented as (1/scale) * x.
549* Set x to zero. This approach deviates from LATRS
550* where a completely meaningless non-zero vector
551* is returned that is not a solution to op(A) * x = b.
552 scale( rhs ) = zero
553 DO ii = 1, n
554 x( ii, kk ) = czero
555 END DO
556* Discard the local scale factors.
557 DO ii = 1, nba
558 work( ii+kk*lds ) = one
559 END DO
560 scaloc = one
561 END IF
562 END IF
563 scaloc = scaloc * work( j+kk*lds )
564 work( j+kk*lds ) = scaloc
565 END DO
566*
567* Linear block updates
568*
569 IF( notran ) THEN
570 IF( upper ) THEN
571 ifirst = j - 1
572 ilast = 1
573 iinc = -1
574 ELSE
575 ifirst = j + 1
576 ilast = nba
577 iinc = 1
578 END IF
579 ELSE
580 IF( upper ) THEN
581 ifirst = j + 1
582 ilast = nba
583 iinc = 1
584 ELSE
585 ifirst = j - 1
586 ilast = 1
587 iinc = -1
588 END IF
589 END IF
590*
591 DO i = ifirst, ilast, iinc
592* I1: row index of the first column in X( I, K )
593* I2: row index of the first column in X( I+1, K )
594* so the I2 - I1 is the row count of the block X( I, K )
595 i1 = (i-1)*nb + 1
596 i2 = min( i*nb, n ) + 1
597*
598* Prepare the linear update to be executed with GEMM.
599* For each column, compute a consistent scaling, a
600* scaling factor to survive the linear update, and
601* rescale the column segments, if necessary. Then
602* the linear update is safely executed.
603*
604 DO kk = 1, k2-k1
605 rhs = k1 + kk - 1
606* Compute consistent scaling
607 scamin = min( work( i+kk*lds), work( j+kk*lds ) )
608*
609* Compute scaling factor to survive the linear update
610* simulating consistent scaling.
611*
612 bnrm = clange( 'I', i2-i1, 1, x( i1, rhs ), ldx,
613 $ w )
614 bnrm = bnrm*( scamin / work( i+kk*lds ) )
615 xnrm( kk ) = xnrm( kk )*( scamin / work( j+kk*lds) )
616 anrm = work( awrk + i+(j-1)*nba )
617 scaloc = slarmm( anrm, xnrm( kk ), bnrm )
618*
619* Simultaneously apply the robust update factor and the
620* consistency scaling factor to X( I, KK ) and X( J, KK ).
621*
622 scal = ( scamin / work( i+kk*lds) )*scaloc
623 IF( scal.NE.one ) THEN
624 CALL csscal( i2-i1, scal, x( i1, rhs ), 1 )
625 work( i+kk*lds ) = scamin*scaloc
626 END IF
627*
628 scal = ( scamin / work( j+kk*lds ) )*scaloc
629 IF( scal.NE.one ) THEN
630 CALL csscal( j2-j1, scal, x( j1, rhs ), 1 )
631 work( j+kk*lds ) = scamin*scaloc
632 END IF
633 END DO
634*
635 IF( notran ) THEN
636*
637* B( I, K ) := B( I, K ) - A( I, J ) * X( J, K )
638*
639 CALL cgemm( 'N', 'N', i2-i1, k2-k1, j2-j1, -cone,
640 $ a( i1, j1 ), lda, x( j1, k1 ), ldx,
641 $ cone, x( i1, k1 ), ldx )
642 ELSE IF( lsame( trans, 'T' ) ) THEN
643*
644* B( I, K ) := B( I, K ) - A( I, J )**T * X( J, K )
645*
646 CALL cgemm( 'T', 'N', i2-i1, k2-k1, j2-j1, -cone,
647 $ a( j1, i1 ), lda, x( j1, k1 ), ldx,
648 $ cone, x( i1, k1 ), ldx )
649 ELSE
650*
651* B( I, K ) := B( I, K ) - A( I, J )**H * X( J, K )
652*
653 CALL cgemm( 'C', 'N', i2-i1, k2-k1, j2-j1, -cone,
654 $ a( j1, i1 ), lda, x( j1, k1 ), ldx,
655 $ cone, x( i1, k1 ), ldx )
656 END IF
657 END DO
658 END DO
659*
660* Reduce local scaling factors
661*
662 DO kk = 1, k2-k1
663 rhs = k1 + kk - 1
664 DO i = 1, nba
665 scale( rhs ) = min( scale( rhs ), work( i+kk*lds ) )
666 END DO
667 END DO
668*
669* Realize consistent scaling
670*
671 DO kk = 1, k2-k1
672 rhs = k1 + kk - 1
673 IF( scale( rhs ).NE.one .AND. scale( rhs ).NE. zero ) THEN
674 DO i = 1, nba
675 i1 = (i-1)*nb + 1
676 i2 = min( i*nb, n ) + 1
677 scal = scale( rhs ) / work( i+kk*lds )
678 IF( scal.NE.one )
679 $ CALL csscal( i2-i1, scal, x( i1, rhs ), 1 )
680 END DO
681 END IF
682 END DO
683 END DO
684*
685 work( 1 ) = sroundup_lwork( lwmin )
686*
687 RETURN
688*
689* End of CLATRS3
690*
691 END
subroutine xerbla(srname, info)
Definition cblat2.f:3285
subroutine cgemm(transa, transb, m, n, k, alpha, a, lda, b, ldb, beta, c, ldc)
CGEMM
Definition cgemm.f:188
subroutine clatrs3(uplo, trans, diag, normin, n, nrhs, a, lda, x, ldx, scale, cnorm, work, lwork, info)
CLATRS3 solves a triangular system of equations with the scale factors set to prevent overflow.
Definition clatrs3.f:235
subroutine clatrs(uplo, trans, diag, normin, n, a, lda, x, scale, cnorm, info)
CLATRS solves a triangular system of equations with the scale factor set to prevent overflow.
Definition clatrs.f:238
real function sroundup_lwork(lwork)
SROUNDUP_LWORK
subroutine csscal(n, sa, cx, incx)
CSSCAL
Definition csscal.f:78