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
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
|
*> \brief \b SLAQTR solves a real quasi-triangular system of equations, or a complex quasi-triangular system of special form, in real arithmetic.
*
* =========== DOCUMENTATION ===========
*
* Online html documentation available at
* http://www.netlib.org/lapack/explore-html/
*
*> \htmlonly
*> Download SLAQTR + dependencies
*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/slaqtr.f">
*> [TGZ]</a>
*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/slaqtr.f">
*> [ZIP]</a>
*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/slaqtr.f">
*> [TXT]</a>
*> \endhtmlonly
*
* Definition:
* ===========
*
* SUBROUTINE SLAQTR( LTRAN, LREAL, N, T, LDT, B, W, SCALE, X, WORK,
* INFO )
*
* .. Scalar Arguments ..
* LOGICAL LREAL, LTRAN
* INTEGER INFO, LDT, N
* REAL SCALE, W
* ..
* .. Array Arguments ..
* REAL B( * ), T( LDT, * ), WORK( * ), X( * )
* ..
*
*
*> \par Purpose:
* =============
*>
*> \verbatim
*>
*> SLAQTR solves the real quasi-triangular system
*>
*> op(T)*p = scale*c, if LREAL = .TRUE.
*>
*> or the complex quasi-triangular systems
*>
*> op(T + iB)*(p+iq) = scale*(c+id), if LREAL = .FALSE.
*>
*> in real arithmetic, where T is upper quasi-triangular.
*> If LREAL = .FALSE., then the first diagonal block of T must be
*> 1 by 1, B is the specially structured matrix
*>
*> B = [ b(1) b(2) ... b(n) ]
*> [ w ]
*> [ w ]
*> [ . ]
*> [ w ]
*>
*> op(A) = A or A**T, A**T denotes the transpose of
*> matrix A.
*>
*> On input, X = [ c ]. On output, X = [ p ].
*> [ d ] [ q ]
*>
*> This subroutine is designed for the condition number estimation
*> in routine STRSNA.
*> \endverbatim
*
* Arguments:
* ==========
*
*> \param[in] LTRAN
*> \verbatim
*> LTRAN is LOGICAL
*> On entry, LTRAN specifies the option of conjugate transpose:
*> = .FALSE., op(T+i*B) = T+i*B,
*> = .TRUE., op(T+i*B) = (T+i*B)**T.
*> \endverbatim
*>
*> \param[in] LREAL
*> \verbatim
*> LREAL is LOGICAL
*> On entry, LREAL specifies the input matrix structure:
*> = .FALSE., the input is complex
*> = .TRUE., the input is real
*> \endverbatim
*>
*> \param[in] N
*> \verbatim
*> N is INTEGER
*> On entry, N specifies the order of T+i*B. N >= 0.
*> \endverbatim
*>
*> \param[in] T
*> \verbatim
*> T is REAL array, dimension (LDT,N)
*> On entry, T contains a matrix in Schur canonical form.
*> If LREAL = .FALSE., then the first diagonal block of T must
*> be 1 by 1.
*> \endverbatim
*>
*> \param[in] LDT
*> \verbatim
*> LDT is INTEGER
*> The leading dimension of the matrix T. LDT >= max(1,N).
*> \endverbatim
*>
*> \param[in] B
*> \verbatim
*> B is REAL array, dimension (N)
*> On entry, B contains the elements to form the matrix
*> B as described above.
*> If LREAL = .TRUE., B is not referenced.
*> \endverbatim
*>
*> \param[in] W
*> \verbatim
*> W is REAL
*> On entry, W is the diagonal element of the matrix B.
*> If LREAL = .TRUE., W is not referenced.
*> \endverbatim
*>
*> \param[out] SCALE
*> \verbatim
*> SCALE is REAL
*> On exit, SCALE is the scale factor.
*> \endverbatim
*>
*> \param[in,out] X
*> \verbatim
*> X is REAL array, dimension (2*N)
*> On entry, X contains the right hand side of the system.
*> On exit, X is overwritten by the solution.
*> \endverbatim
*>
*> \param[out] WORK
*> \verbatim
*> WORK is REAL array, dimension (N)
*> \endverbatim
*>
*> \param[out] INFO
*> \verbatim
*> INFO is INTEGER
*> On exit, INFO is set to
*> 0: successful exit.
*> 1: the some diagonal 1 by 1 block has been perturbed by
*> a small number SMIN to keep nonsingularity.
*> 2: the some diagonal 2 by 2 block has been perturbed by
*> a small number in SLALN2 to keep nonsingularity.
*> NOTE: In the interests of speed, this routine does not
*> check the inputs for errors.
*> \endverbatim
*
* Authors:
* ========
*
*> \author Univ. of Tennessee
*> \author Univ. of California Berkeley
*> \author Univ. of Colorado Denver
*> \author NAG Ltd.
*
*> \date September 2012
*
*> \ingroup realOTHERauxiliary
*
* =====================================================================
SUBROUTINE SLAQTR( LTRAN, LREAL, N, T, LDT, B, W, SCALE, X, WORK,
$ INFO )
*
* -- LAPACK auxiliary routine (version 3.4.2) --
* -- LAPACK is a software package provided by Univ. of Tennessee, --
* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
* September 2012
*
* .. Scalar Arguments ..
LOGICAL LREAL, LTRAN
INTEGER INFO, LDT, N
REAL SCALE, W
* ..
* .. Array Arguments ..
REAL B( * ), T( LDT, * ), WORK( * ), X( * )
* ..
*
* =====================================================================
*
* .. Parameters ..
REAL ZERO, ONE
PARAMETER ( ZERO = 0.0E+0, ONE = 1.0E+0 )
* ..
* .. Local Scalars ..
LOGICAL NOTRAN
INTEGER I, IERR, J, J1, J2, JNEXT, K, N1, N2
REAL BIGNUM, EPS, REC, SCALOC, SI, SMIN, SMINW,
$ SMLNUM, SR, TJJ, TMP, XJ, XMAX, XNORM, Z
* ..
* .. Local Arrays ..
REAL D( 2, 2 ), V( 2, 2 )
* ..
* .. External Functions ..
INTEGER ISAMAX
REAL SASUM, SDOT, SLAMCH, SLANGE
EXTERNAL ISAMAX, SASUM, SDOT, SLAMCH, SLANGE
* ..
* .. External Subroutines ..
EXTERNAL SAXPY, SLADIV, SLALN2, SSCAL
* ..
* .. Intrinsic Functions ..
INTRINSIC ABS, MAX
* ..
* .. Executable Statements ..
*
* Do not test the input parameters for errors
*
NOTRAN = .NOT.LTRAN
INFO = 0
*
* Quick return if possible
*
IF( N.EQ.0 )
$ RETURN
*
* Set constants to control overflow
*
EPS = SLAMCH( 'P' )
SMLNUM = SLAMCH( 'S' ) / EPS
BIGNUM = ONE / SMLNUM
*
XNORM = SLANGE( 'M', N, N, T, LDT, D )
IF( .NOT.LREAL )
$ XNORM = MAX( XNORM, ABS( W ), SLANGE( 'M', N, 1, B, N, D ) )
SMIN = MAX( SMLNUM, EPS*XNORM )
*
* Compute 1-norm of each column of strictly upper triangular
* part of T to control overflow in triangular solver.
*
WORK( 1 ) = ZERO
DO 10 J = 2, N
WORK( J ) = SASUM( J-1, T( 1, J ), 1 )
10 CONTINUE
*
IF( .NOT.LREAL ) THEN
DO 20 I = 2, N
WORK( I ) = WORK( I ) + ABS( B( I ) )
20 CONTINUE
END IF
*
N2 = 2*N
N1 = N
IF( .NOT.LREAL )
$ N1 = N2
K = ISAMAX( N1, X, 1 )
XMAX = ABS( X( K ) )
SCALE = ONE
*
IF( XMAX.GT.BIGNUM ) THEN
SCALE = BIGNUM / XMAX
CALL SSCAL( N1, SCALE, X, 1 )
XMAX = BIGNUM
END IF
*
IF( LREAL ) THEN
*
IF( NOTRAN ) THEN
*
* Solve T*p = scale*c
*
JNEXT = N
DO 30 J = N, 1, -1
IF( J.GT.JNEXT )
$ GO TO 30
J1 = J
J2 = J
JNEXT = J - 1
IF( J.GT.1 ) THEN
IF( T( J, J-1 ).NE.ZERO ) THEN
J1 = J - 1
JNEXT = J - 2
END IF
END IF
*
IF( J1.EQ.J2 ) THEN
*
* Meet 1 by 1 diagonal block
*
* Scale to avoid overflow when computing
* x(j) = b(j)/T(j,j)
*
XJ = ABS( X( J1 ) )
TJJ = ABS( T( J1, J1 ) )
TMP = T( J1, J1 )
IF( TJJ.LT.SMIN ) THEN
TMP = SMIN
TJJ = SMIN
INFO = 1
END IF
*
IF( XJ.EQ.ZERO )
$ GO TO 30
*
IF( TJJ.LT.ONE ) THEN
IF( XJ.GT.BIGNUM*TJJ ) THEN
REC = ONE / XJ
CALL SSCAL( N, REC, X, 1 )
SCALE = SCALE*REC
XMAX = XMAX*REC
END IF
END IF
X( J1 ) = X( J1 ) / TMP
XJ = ABS( X( J1 ) )
*
* Scale x if necessary to avoid overflow when adding a
* multiple of column j1 of T.
*
IF( XJ.GT.ONE ) THEN
REC = ONE / XJ
IF( WORK( J1 ).GT.( BIGNUM-XMAX )*REC ) THEN
CALL SSCAL( N, REC, X, 1 )
SCALE = SCALE*REC
END IF
END IF
IF( J1.GT.1 ) THEN
CALL SAXPY( J1-1, -X( J1 ), T( 1, J1 ), 1, X, 1 )
K = ISAMAX( J1-1, X, 1 )
XMAX = ABS( X( K ) )
END IF
*
ELSE
*
* Meet 2 by 2 diagonal block
*
* Call 2 by 2 linear system solve, to take
* care of possible overflow by scaling factor.
*
D( 1, 1 ) = X( J1 )
D( 2, 1 ) = X( J2 )
CALL SLALN2( .FALSE., 2, 1, SMIN, ONE, T( J1, J1 ),
$ LDT, ONE, ONE, D, 2, ZERO, ZERO, V, 2,
$ SCALOC, XNORM, IERR )
IF( IERR.NE.0 )
$ INFO = 2
*
IF( SCALOC.NE.ONE ) THEN
CALL SSCAL( N, SCALOC, X, 1 )
SCALE = SCALE*SCALOC
END IF
X( J1 ) = V( 1, 1 )
X( J2 ) = V( 2, 1 )
*
* Scale V(1,1) (= X(J1)) and/or V(2,1) (=X(J2))
* to avoid overflow in updating right-hand side.
*
XJ = MAX( ABS( V( 1, 1 ) ), ABS( V( 2, 1 ) ) )
IF( XJ.GT.ONE ) THEN
REC = ONE / XJ
IF( MAX( WORK( J1 ), WORK( J2 ) ).GT.
$ ( BIGNUM-XMAX )*REC ) THEN
CALL SSCAL( N, REC, X, 1 )
SCALE = SCALE*REC
END IF
END IF
*
* Update right-hand side
*
IF( J1.GT.1 ) THEN
CALL SAXPY( J1-1, -X( J1 ), T( 1, J1 ), 1, X, 1 )
CALL SAXPY( J1-1, -X( J2 ), T( 1, J2 ), 1, X, 1 )
K = ISAMAX( J1-1, X, 1 )
XMAX = ABS( X( K ) )
END IF
*
END IF
*
30 CONTINUE
*
ELSE
*
* Solve T**T*p = scale*c
*
JNEXT = 1
DO 40 J = 1, N
IF( J.LT.JNEXT )
$ GO TO 40
J1 = J
J2 = J
JNEXT = J + 1
IF( J.LT.N ) THEN
IF( T( J+1, J ).NE.ZERO ) THEN
J2 = J + 1
JNEXT = J + 2
END IF
END IF
*
IF( J1.EQ.J2 ) THEN
*
* 1 by 1 diagonal block
*
* Scale if necessary to avoid overflow in forming the
* right-hand side element by inner product.
*
XJ = ABS( X( J1 ) )
IF( XMAX.GT.ONE ) THEN
REC = ONE / XMAX
IF( WORK( J1 ).GT.( BIGNUM-XJ )*REC ) THEN
CALL SSCAL( N, REC, X, 1 )
SCALE = SCALE*REC
XMAX = XMAX*REC
END IF
END IF
*
X( J1 ) = X( J1 ) - SDOT( J1-1, T( 1, J1 ), 1, X, 1 )
*
XJ = ABS( X( J1 ) )
TJJ = ABS( T( J1, J1 ) )
TMP = T( J1, J1 )
IF( TJJ.LT.SMIN ) THEN
TMP = SMIN
TJJ = SMIN
INFO = 1
END IF
*
IF( TJJ.LT.ONE ) THEN
IF( XJ.GT.BIGNUM*TJJ ) THEN
REC = ONE / XJ
CALL SSCAL( N, REC, X, 1 )
SCALE = SCALE*REC
XMAX = XMAX*REC
END IF
END IF
X( J1 ) = X( J1 ) / TMP
XMAX = MAX( XMAX, ABS( X( J1 ) ) )
*
ELSE
*
* 2 by 2 diagonal block
*
* Scale if necessary to avoid overflow in forming the
* right-hand side elements by inner product.
*
XJ = MAX( ABS( X( J1 ) ), ABS( X( J2 ) ) )
IF( XMAX.GT.ONE ) THEN
REC = ONE / XMAX
IF( MAX( WORK( J2 ), WORK( J1 ) ).GT.( BIGNUM-XJ )*
$ REC ) THEN
CALL SSCAL( N, REC, X, 1 )
SCALE = SCALE*REC
XMAX = XMAX*REC
END IF
END IF
*
D( 1, 1 ) = X( J1 ) - SDOT( J1-1, T( 1, J1 ), 1, X,
$ 1 )
D( 2, 1 ) = X( J2 ) - SDOT( J1-1, T( 1, J2 ), 1, X,
$ 1 )
*
CALL SLALN2( .TRUE., 2, 1, SMIN, ONE, T( J1, J1 ),
$ LDT, ONE, ONE, D, 2, ZERO, ZERO, V, 2,
$ SCALOC, XNORM, IERR )
IF( IERR.NE.0 )
$ INFO = 2
*
IF( SCALOC.NE.ONE ) THEN
CALL SSCAL( N, SCALOC, X, 1 )
SCALE = SCALE*SCALOC
END IF
X( J1 ) = V( 1, 1 )
X( J2 ) = V( 2, 1 )
XMAX = MAX( ABS( X( J1 ) ), ABS( X( J2 ) ), XMAX )
*
END IF
40 CONTINUE
END IF
*
ELSE
*
SMINW = MAX( EPS*ABS( W ), SMIN )
IF( NOTRAN ) THEN
*
* Solve (T + iB)*(p+iq) = c+id
*
JNEXT = N
DO 70 J = N, 1, -1
IF( J.GT.JNEXT )
$ GO TO 70
J1 = J
J2 = J
JNEXT = J - 1
IF( J.GT.1 ) THEN
IF( T( J, J-1 ).NE.ZERO ) THEN
J1 = J - 1
JNEXT = J - 2
END IF
END IF
*
IF( J1.EQ.J2 ) THEN
*
* 1 by 1 diagonal block
*
* Scale if necessary to avoid overflow in division
*
Z = W
IF( J1.EQ.1 )
$ Z = B( 1 )
XJ = ABS( X( J1 ) ) + ABS( X( N+J1 ) )
TJJ = ABS( T( J1, J1 ) ) + ABS( Z )
TMP = T( J1, J1 )
IF( TJJ.LT.SMINW ) THEN
TMP = SMINW
TJJ = SMINW
INFO = 1
END IF
*
IF( XJ.EQ.ZERO )
$ GO TO 70
*
IF( TJJ.LT.ONE ) THEN
IF( XJ.GT.BIGNUM*TJJ ) THEN
REC = ONE / XJ
CALL SSCAL( N2, REC, X, 1 )
SCALE = SCALE*REC
XMAX = XMAX*REC
END IF
END IF
CALL SLADIV( X( J1 ), X( N+J1 ), TMP, Z, SR, SI )
X( J1 ) = SR
X( N+J1 ) = SI
XJ = ABS( X( J1 ) ) + ABS( X( N+J1 ) )
*
* Scale x if necessary to avoid overflow when adding a
* multiple of column j1 of T.
*
IF( XJ.GT.ONE ) THEN
REC = ONE / XJ
IF( WORK( J1 ).GT.( BIGNUM-XMAX )*REC ) THEN
CALL SSCAL( N2, REC, X, 1 )
SCALE = SCALE*REC
END IF
END IF
*
IF( J1.GT.1 ) THEN
CALL SAXPY( J1-1, -X( J1 ), T( 1, J1 ), 1, X, 1 )
CALL SAXPY( J1-1, -X( N+J1 ), T( 1, J1 ), 1,
$ X( N+1 ), 1 )
*
X( 1 ) = X( 1 ) + B( J1 )*X( N+J1 )
X( N+1 ) = X( N+1 ) - B( J1 )*X( J1 )
*
XMAX = ZERO
DO 50 K = 1, J1 - 1
XMAX = MAX( XMAX, ABS( X( K ) )+
$ ABS( X( K+N ) ) )
50 CONTINUE
END IF
*
ELSE
*
* Meet 2 by 2 diagonal block
*
D( 1, 1 ) = X( J1 )
D( 2, 1 ) = X( J2 )
D( 1, 2 ) = X( N+J1 )
D( 2, 2 ) = X( N+J2 )
CALL SLALN2( .FALSE., 2, 2, SMINW, ONE, T( J1, J1 ),
$ LDT, ONE, ONE, D, 2, ZERO, -W, V, 2,
$ SCALOC, XNORM, IERR )
IF( IERR.NE.0 )
$ INFO = 2
*
IF( SCALOC.NE.ONE ) THEN
CALL SSCAL( 2*N, SCALOC, X, 1 )
SCALE = SCALOC*SCALE
END IF
X( J1 ) = V( 1, 1 )
X( J2 ) = V( 2, 1 )
X( N+J1 ) = V( 1, 2 )
X( N+J2 ) = V( 2, 2 )
*
* Scale X(J1), .... to avoid overflow in
* updating right hand side.
*
XJ = MAX( ABS( V( 1, 1 ) )+ABS( V( 1, 2 ) ),
$ ABS( V( 2, 1 ) )+ABS( V( 2, 2 ) ) )
IF( XJ.GT.ONE ) THEN
REC = ONE / XJ
IF( MAX( WORK( J1 ), WORK( J2 ) ).GT.
$ ( BIGNUM-XMAX )*REC ) THEN
CALL SSCAL( N2, REC, X, 1 )
SCALE = SCALE*REC
END IF
END IF
*
* Update the right-hand side.
*
IF( J1.GT.1 ) THEN
CALL SAXPY( J1-1, -X( J1 ), T( 1, J1 ), 1, X, 1 )
CALL SAXPY( J1-1, -X( J2 ), T( 1, J2 ), 1, X, 1 )
*
CALL SAXPY( J1-1, -X( N+J1 ), T( 1, J1 ), 1,
$ X( N+1 ), 1 )
CALL SAXPY( J1-1, -X( N+J2 ), T( 1, J2 ), 1,
$ X( N+1 ), 1 )
*
X( 1 ) = X( 1 ) + B( J1 )*X( N+J1 ) +
$ B( J2 )*X( N+J2 )
X( N+1 ) = X( N+1 ) - B( J1 )*X( J1 ) -
$ B( J2 )*X( J2 )
*
XMAX = ZERO
DO 60 K = 1, J1 - 1
XMAX = MAX( ABS( X( K ) )+ABS( X( K+N ) ),
$ XMAX )
60 CONTINUE
END IF
*
END IF
70 CONTINUE
*
ELSE
*
* Solve (T + iB)**T*(p+iq) = c+id
*
JNEXT = 1
DO 80 J = 1, N
IF( J.LT.JNEXT )
$ GO TO 80
J1 = J
J2 = J
JNEXT = J + 1
IF( J.LT.N ) THEN
IF( T( J+1, J ).NE.ZERO ) THEN
J2 = J + 1
JNEXT = J + 2
END IF
END IF
*
IF( J1.EQ.J2 ) THEN
*
* 1 by 1 diagonal block
*
* Scale if necessary to avoid overflow in forming the
* right-hand side element by inner product.
*
XJ = ABS( X( J1 ) ) + ABS( X( J1+N ) )
IF( XMAX.GT.ONE ) THEN
REC = ONE / XMAX
IF( WORK( J1 ).GT.( BIGNUM-XJ )*REC ) THEN
CALL SSCAL( N2, REC, X, 1 )
SCALE = SCALE*REC
XMAX = XMAX*REC
END IF
END IF
*
X( J1 ) = X( J1 ) - SDOT( J1-1, T( 1, J1 ), 1, X, 1 )
X( N+J1 ) = X( N+J1 ) - SDOT( J1-1, T( 1, J1 ), 1,
$ X( N+1 ), 1 )
IF( J1.GT.1 ) THEN
X( J1 ) = X( J1 ) - B( J1 )*X( N+1 )
X( N+J1 ) = X( N+J1 ) + B( J1 )*X( 1 )
END IF
XJ = ABS( X( J1 ) ) + ABS( X( J1+N ) )
*
Z = W
IF( J1.EQ.1 )
$ Z = B( 1 )
*
* Scale if necessary to avoid overflow in
* complex division
*
TJJ = ABS( T( J1, J1 ) ) + ABS( Z )
TMP = T( J1, J1 )
IF( TJJ.LT.SMINW ) THEN
TMP = SMINW
TJJ = SMINW
INFO = 1
END IF
*
IF( TJJ.LT.ONE ) THEN
IF( XJ.GT.BIGNUM*TJJ ) THEN
REC = ONE / XJ
CALL SSCAL( N2, REC, X, 1 )
SCALE = SCALE*REC
XMAX = XMAX*REC
END IF
END IF
CALL SLADIV( X( J1 ), X( N+J1 ), TMP, -Z, SR, SI )
X( J1 ) = SR
X( J1+N ) = SI
XMAX = MAX( ABS( X( J1 ) )+ABS( X( J1+N ) ), XMAX )
*
ELSE
*
* 2 by 2 diagonal block
*
* Scale if necessary to avoid overflow in forming the
* right-hand side element by inner product.
*
XJ = MAX( ABS( X( J1 ) )+ABS( X( N+J1 ) ),
$ ABS( X( J2 ) )+ABS( X( N+J2 ) ) )
IF( XMAX.GT.ONE ) THEN
REC = ONE / XMAX
IF( MAX( WORK( J1 ), WORK( J2 ) ).GT.
$ ( BIGNUM-XJ ) / XMAX ) THEN
CALL SSCAL( N2, REC, X, 1 )
SCALE = SCALE*REC
XMAX = XMAX*REC
END IF
END IF
*
D( 1, 1 ) = X( J1 ) - SDOT( J1-1, T( 1, J1 ), 1, X,
$ 1 )
D( 2, 1 ) = X( J2 ) - SDOT( J1-1, T( 1, J2 ), 1, X,
$ 1 )
D( 1, 2 ) = X( N+J1 ) - SDOT( J1-1, T( 1, J1 ), 1,
$ X( N+1 ), 1 )
D( 2, 2 ) = X( N+J2 ) - SDOT( J1-1, T( 1, J2 ), 1,
$ X( N+1 ), 1 )
D( 1, 1 ) = D( 1, 1 ) - B( J1 )*X( N+1 )
D( 2, 1 ) = D( 2, 1 ) - B( J2 )*X( N+1 )
D( 1, 2 ) = D( 1, 2 ) + B( J1 )*X( 1 )
D( 2, 2 ) = D( 2, 2 ) + B( J2 )*X( 1 )
*
CALL SLALN2( .TRUE., 2, 2, SMINW, ONE, T( J1, J1 ),
$ LDT, ONE, ONE, D, 2, ZERO, W, V, 2,
$ SCALOC, XNORM, IERR )
IF( IERR.NE.0 )
$ INFO = 2
*
IF( SCALOC.NE.ONE ) THEN
CALL SSCAL( N2, SCALOC, X, 1 )
SCALE = SCALOC*SCALE
END IF
X( J1 ) = V( 1, 1 )
X( J2 ) = V( 2, 1 )
X( N+J1 ) = V( 1, 2 )
X( N+J2 ) = V( 2, 2 )
XMAX = MAX( ABS( X( J1 ) )+ABS( X( N+J1 ) ),
$ ABS( X( J2 ) )+ABS( X( N+J2 ) ), XMAX )
*
END IF
*
80 CONTINUE
*
END IF
*
END IF
*
RETURN
*
* End of SLAQTR
*
END
|