Repository navigation
Expand file tree
/
Copy pathAB13HD.f
More file actions
3436 lines (3436 loc) · 126 KB
/
Copy pathAB13HD.f
File metadata and controls
3436 lines (3436 loc) · 126 KB
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
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
SUBROUTINE AB13HD( DICO, JOBE, EQUIL, JOBD, CKPROP, REDUCE, POLES,
$ N, M, P, RANKE, FPEAK, A, LDA, E, LDE, B, LDB,
$ C, LDC, D, LDD, NR, GPEAK, TOL, IWORK, DWORK,
$ LDWORK, ZWORK, LZWORK, BWORK, IWARN, INFO )
C
C PURPOSE
C
C To compute the L-infinity norm of a proper continuous-time or
C causal discrete-time system, either standard or in the descriptor
C form,
C
C -1
C G(lambda) = C*( lambda*E - A ) *B + D .
C
C The norm is finite if and only if the matrix pair (A,E) has no
C finite eigenvalue on the boundary of the stability domain, i.e.,
C the imaginary axis, or the unit circle, respectively.
C
C ARGUMENTS
C
C Mode Parameters
C
C DICO CHARACTER*1
C Specifies the type of the system, as follows:
C = 'C': continuous-time system;
C = 'D': discrete-time system.
C
C JOBE CHARACTER*1
C Specifies whether E is an identity matrix, a general
C square matrix, or a matrix in compressed form, as follows:
C = 'I': E is the identity matrix;
C = 'G': E is a general matrix;
C = 'C': E is in compressed form, i.e., E = [ T 0 ],
C [ 0 0 ]
C with a square full-rank matrix T.
C
C EQUIL CHARACTER*1
C Specifies whether the user wishes to preliminarily
C equilibrate the system (A,E,B,C) or (A,B,C), as follows:
C = 'S': perform equilibration (scaling);
C = 'N': do not perform equilibration.
C
C JOBD CHARACTER*1
C Specifies whether or not a non-zero matrix D appears in
C the given state space model:
C = 'D': D is present;
C = 'Z': D is assumed a zero matrix;
C = 'F': D is known to be well-conditioned (hence, to have
C full rank), for DICO = 'C' and JOBE = 'I'.
C The options JOBD = 'D' and JOBD = 'F' produce the same
C results, but much less memory is needed for JOBD = 'F'.
C
C CKPROP CHARACTER*1
C If DICO = 'C' and JOBE <> 'I', specifies whether the user
C wishes to check the properness of the transfer function of
C the descriptor system, as follows:
C = 'C': check the properness;
C = 'N': do not check the properness.
C If the test is requested and the system is found improper
C then GPEAK and FPEAK are both set to infinity, i.e., their
C second component is zero; in addition, IWARN is set to 2.
C If the test is not requested, but the system is improper,
C the resulted GPEAK and FPEAK may be wrong.
C If DICO = 'D' or JOBE = 'I', this option is ineffective.
C
C REDUCE CHARACTER*1
C If CKPROP = 'C', specifies whether the user wishes to
C reduce the system order, by removing all uncontrollable
C and unobservable poles before computing the norm, as
C follows:
C = 'R': reduce the system order;
C = 'N': compute the norm without reducing the order.
C If CKPROP = 'N', this option is ineffective.
C
C POLES CHARACTER*1
C Specifies whether the user wishes to use all or part of
C the poles to compute the test frequencies (in the non-
C iterative part of the algorithm), or all or part of the
C midpoints (in the iterative part of the algorithm), as
C follows:
C = 'A': use all poles with non-negative imaginary parts
C and all midpoints;
C = 'P': use part of the poles and midpoints.
C
C Input/Output Parameters
C
C N (input) INTEGER
C The order of the system. N >= 0.
C
C M (input) INTEGER
C The column size of the matrix B. M >= 0.
C
C P (input) INTEGER
C The row size of the matrix C. P >= 0.
C
C RANKE (input) INTEGER
C If JOBE = 'C', RANKE denotes the rank of the descriptor
C matrix E or the size of the full-rank block T.
C 0 <= RANKE <= N.
C
C FPEAK (input/output) DOUBLE PRECISION array, dimension (2)
C On entry, this parameter must contain an estimate of the
C frequency where the gain of the frequency response would
C achieve its peak value. Setting FPEAK(2) = 0 indicates an
C infinite frequency. An accurate estimate could reduce the
C number of iterations of the iterative algorithm. If no
C estimate is available, set FPEAK(1) = 0, and FPEAK(2) = 1.
C FPEAK(1) >= 0, FPEAK(2) >= 0.
C On exit, if INFO = 0, this array contains the frequency
C OMEGA, where the gain of the frequency response achieves
C its peak value GPEAK, i.e.,
C
C || G ( j*OMEGA ) || = GPEAK , if DICO = 'C', or
C
C j*OMEGA
C || G ( e ) || = GPEAK , if DICO = 'D',
C
C where OMEGA = FPEAK(1), if FPEAK(2) > 0, and OMEGA is
C infinite, if FPEAK(2) = 0. (If nonzero, FPEAK(2) = 1.)
C For discrete-time systems, it is assumed that the sampling
C period is Ts = 1. If Ts <> 1, the frequency corresponding
C to the peak gain is OMEGA/Ts.
C
C A (input/output) DOUBLE PRECISION array, dimension (LDA,N)
C On entry, the leading N-by-N part of this array must
C contain the state dynamics matrix A.
C On exit, if EQUIL = 'S' and CKPROP = 'N', the leading
C N-by-N part of this array contains the state dynamics
C matrix of an equivalent, scaled system.
C On exit, if CKPROP = 'C', DICO = 'C', and JOBE <> 'I', the
C leading NR-by-NR part of this array contains the state
C dynamics matrix of an equivalent reduced, possibly scaled
C (if EQUIL = 'S') system, used to check the properness.
C Otherwise, the array A is unchanged.
C
C LDA INTEGER
C The leading dimension of the array A. LDA >= max(1,N).
C
C E (input/output) DOUBLE PRECISION array, dimension (LDE,K),
C where K is N, RANKE, or 0, if JOBE = 'G', 'C', or 'I',
C respectively.
C On entry, if JOBE = 'G', the leading N-by-N part of this
C array must contain the descriptor matrix E of the system.
C If JOBE = 'C', the leading RANKE-by-RANKE part of this
C array must contain the full-rank block T of the descriptor
C matrix E.
C If JOBE = 'I', then E is assumed to be the identity matrix
C and is not referenced.
C On exit, if EQUIL = 'S' and CKPROP = 'N', the leading
C K-by-K part of this array contains the descriptor matrix
C of an equivalent, scaled system.
C On exit, if CKPROP = 'C', DICO = 'C', and JOBE <> 'I', the
C leading MIN(K,NR)-by-MIN(K,NR) part of this array contains
C the descriptor matrix of an equivalent reduced, possibly
C scaled (if EQUIL = 'S') system, used to check the
C properness.
C Otherwise, the array E is unchanged.
C
C LDE INTEGER
C The leading dimension of the array E.
C LDE >= MAX(1,N), if JOBE = 'G';
C LDE >= MAX(1,RANKE), if JOBE = 'C';
C LDE >= 1, if JOBE = 'I'.
C
C B (input/output) DOUBLE PRECISION array, dimension (LDB,M)
C On entry, the leading N-by-M part of this array must
C contain the system input matrix B.
C On exit, if EQUIL = 'S' and CKPROP = 'N', the leading
C NR-by-M part of this array contains the system input
C matrix of an equivalent, scaled system.
C On exit, if CKPROP = 'C', DICO = 'C', and JOBE <> 'I', the
C leading NR-by-M part of this array contains the system
C input matrix of an equivalent reduced, possibly scaled (if
C EQUIL = 'S') system, used to check the properness.
C Otherwise, the array B is unchanged.
C
C LDB INTEGER
C The leading dimension of the array B. LDB >= max(1,N).
C
C C (input/output) DOUBLE PRECISION array, dimension (LDC,N)
C On entry, the leading P-by-N part of this array must
C contain the system output matrix C.
C On exit, if EQUIL = 'S' and CKPROP = 'N', the leading
C P-by-NR part of this array contains the system output
C matrix of an equivalent, scaled system.
C On exit, if CKPROP = 'C', DICO = 'C', and JOBE <> 'I', the
C leading P-by-NR part of this array contains the system
C output matrix of an equivalent reduced, possibly scaled
C (if EQUIL = 'S') system, used to check the properness.
C Otherwise, the array C is unchanged.
C
C LDC INTEGER
C The leading dimension of the array C. LDC >= max(1,P).
C
C D (input) DOUBLE PRECISION array, dimension (LDD,M)
C If JOBD = 'D' or JOBD = 'F', the leading P-by-M part of
C this array must contain the direct transmission matrix D.
C The array D is not referenced if JOBD = 'Z'.
C
C LDD INTEGER
C The leading dimension of array D.
C LDD >= MAX(1,P), if JOBD = 'D' or JOBD = 'F';
C LDD >= 1, if JOBD = 'Z'.
C
C NR (output) INTEGER
C If CKPROP = 'C', DICO = 'C', and JOBE <> 'I', the order of
C the reduced system. Otherwise, NR = N.
C
C GPEAK (output) DOUBLE PRECISION array, dimension (2)
C The L-infinity norm of the system, i.e., the peak gain
C of the frequency response (as measured by the largest
C singular value in the MIMO case), coded in the same way
C as FPEAK.
C
C Tolerances
C
C TOL DOUBLE PRECISION array, dimension K, where K = 2, if
C CKPROP = 'N' or DICO = 'D' or JOBE = 'I', and K = 4,
C otherwise.
C TOL(1) is the tolerance used to set the accuracy in
C determining the norm. 0 <= TOL(1) < 1.
C TOL(2) is the threshold value for magnitude of the matrix
C elements, if EQUIL = 'S': elements with magnitude less
C than or equal to TOL(2) are ignored for scaling. If the
C user sets TOL(2) >= 0, then the given value of TOL(2) is
C used. If the user sets TOL(2) < 0, then an implicitly
C computed, default threshold, THRESH, is used instead,
C defined by THRESH = 0.1, if MN/MX < EPS, and otherwise,
C THRESH = MIN( 100*(MN/(EPS**0.25*MX))**0.5, 0.1 ), where
C MX and MN are the maximum and the minimum nonzero absolute
C value, respectively, of the elements of A and E, and EPS
C is the machine precision (see LAPACK Library routine
C DLAMCH). TOL(2) = 0 is not always a good choice.
C TOL(2) < 1. TOL(2) is not used if EQUIL = 'N'.
C TOL(3) is the tolerance to be used in rank determinations
C when transforming (lambda*E-A,B,C), if CKPROP = 'C'. If
C the user sets TOL(3) > 0, then the given value of TOL(3)
C is used as a lower bound for reciprocal condition numbers
C in rank determinations; a (sub)matrix whose estimated
C condition number is less than 1/TOL(3) is considered to be
C of full rank. If the user sets TOL(3) <= 0, then an
C implicitly computed, default tolerance, defined by
C TOLDEF1 = N*N*EPS, is used instead. TOL(3) < 1.
C TOL(4) is the tolerance to be used for checking the
C singularity of the matrices A and E when CKPROP = 'C'.
C If the user sets TOL(4) > 0, then the given value of
C TOL(4) is used. If the user sets TOL(4) <= 0, then an
C implicitly computed, default tolerance, defined by
C TOLDEF2 = N*EPS, is used instead. The 1-norms of A and E
C are also taken into account. TOL(4) < 1.
C
C Workspace
C
C IWORK INTEGER array, dimension (LIWORK)
C LIWORK >= 1, if MIN(N,P,M) = 0, or B = 0, or C = 0; else
C LIWORK >= MAX(1,N), if DICO = 'C', JOBE = 'I', and
C JOBD <> 'D';
C LIWORK >= 2*N + M + P + R + 12, otherwise, where
C R = 0, if M + P is even,
C R = 1, if M + P is odd.
C On exit, if INFO = 0, IWORK(1) returns the number of
C iterations performed by the iterative algorithm
C (possibly 0).
C
C DWORK DOUBLE PRECISION array, dimension (LDWORK)
C On exit, if INFO = 0, DWORK(1) contains the optimal value
C of LDWORK.
C On exit, if INFO = -28, DWORK(1) returns the minimum
C value of LDWORK. These values are also set when LDWORK = 0
C on entry, but no error message related to LDWORK is issued
C by XERBLA.
C
C LDWORK INTEGER
C The dimension of the array DWORK.
C LDWORK >= 1, if MIN(M,P) = 0 or ( JOBD = 'Z' and
C ( N = 0 or B = 0 or C = 0 ) );
C LDWORK >= P*M + x, if ( ( N = 0 and MIN(M,P) > 0 )
C or ( B = 0 or C = 0 ) ) and JOBD <> 'Z',
C where
C x = MAX( 4*MIN(M,P) + MAX(M,P), 6*MIN(M,P) ),
C if DICO = 'C',
C x = 6*MIN(M,P), if DICO = 'D';
C LDWORK >= MAX( 1, N*(N+M+P+2) + MAX( N*(N+M+2) + P*M + x,
C 4*N*N + 9*N ) ),
C if DICO = 'C', JOBE = 'I' and JOBD = 'Z'.
C LDWORK >= MAX( 1, (N+M)*(M+P) + P*P + x,
C 2*N*(N+M+P+1) + N + MIN(P,M) +
C MAX( M*(N+P) + N + x, N*N +
C MAX( N*(P+M) + MAX(M,P),
C 2*N*N + 8*N ) ) ),
C if DICO = 'C', JOBE = 'I' and JOBD = 'F'.
C The formulas for other cases, e.g., for JOBE <> 'I' or
C CKPROP = 'C', contain additional and/or other terms.
C The minimum value of LDWORK for all cases can be obtained
C in DWORK(1) when LDWORK is set to 0 on entry.
C For good performance, LDWORK must generally be larger.
C
C If LDWORK = -1, then a workspace query is assumed;
C the routine only calculates the optimal size of the
C DWORK array, returns this value as the first entry of
C the DWORK array, and no error message related to LDWORK
C is issued by XERBLA.
C
C ZWORK COMPLEX*16 array, dimension (LZWORK)
C On exit, if INFO = 0, ZWORK(1) contains the optimal
C LZWORK.
C On exit, if INFO = -30, ZWORK(1) returns the minimum
C value of LZWORK. These values are also set when LZWORK = 0
C on entry, but no error message related to LZWORK is issued
C by XERBLA.
C If LDWORK = 0 and LZWORK = 0 are both set on entry, then
C on exit, INFO = -30, but both DWORK(1) and ZWORK(1) are
C set the minimum values of LDWORK and LZWORK, respectively.
C
C LZWORK INTEGER
C The dimension of the array ZWORK.
C LZWORK >= 1, if MIN(N,M,P) = 0, or B = 0, or C = 0;
C LZWORK >= MAX(1, (N+M)*(N+P) + 2*MIN(M,P) + MAX(M,P)),
C otherwise.
C For good performance, LZWORK must generally be larger.
C
C If LZWORK = -1, then a workspace query is assumed;
C the routine only calculates the optimal size of the
C ZWORK array, returns this value as the first entry of
C the ZWORK array, and no error message related to LZWORK
C is issued by XERBLA.
C
C BWORK LOGICAL array, dimension (N)
C
C Warning Indicator
C
C IWARN INTEGER
C = 0: no warning;
C = 1: the descriptor system is singular. GPEAK(1) and
C GPEAK(2) are set to 0. FPEAK(1) and FPEAK(2) are
C set to 0 and 1, respectively;
C = 2: the descriptor system is improper. GPEAK(1) and
C GPEAK(2) are set to 1 and 0, respectively,
C corresponding to infinity. FPEAK(1) and FPEAK(2) are
C set similarly. This warning can only appear if
C CKPROP = 'C'.
C
C Error Indicator
C
C INFO INTEGER
C = 0: successful exit;
C < 0: if INFO = -i, the i-th argument had an illegal
C value;
C = 1: a matrix is (numerically) singular or the Sylvester
C equation is very ill-conditioned, when computing the
C largest singular value of G(infinity) (for
C DICO = 'C'); the descriptor system is nearly
C singular; the L-infinity norm could be infinite;
C = 2: the (periodic) QR (or QZ) algorithm for computing
C eigenvalues did not converge;
C = 3: the SVD algorithm for computing singular values did
C not converge;
C = 4: the tolerance is too small and the algorithm did
C not converge; this is a warning;
C = 5: other computations than QZ iteration, or reordering
C of eigenvalues, failed in the LAPACK Library
C routines DHGEQZ or DTGSEN, respectively;
C = 6: the numbers of "finite" eigenvalues before and after
C reordering differ; the threshold used might be
C unsuitable.
C
C METHOD
C
C The routine implements the method presented in [2], which is an
C extension of the method in [1] for descriptor systems. There are
C several improvements and refinements [3-5] to increase numerical
C robustness, accuracy and efficiency, such as the usage of
C structure-preserving eigenvalue computations for skew-Hamiltonian/
C Hamiltonian eigenvalue problems in the iterative method in [2].
C
C REFERENCES
C
C [1] Bruinsma, N.A. and Steinbuch, M.
C A fast algorithm to compute the H-infinity-norm of a transfer
C function matrix.
C Systems & Control Letters, vol. 14, pp. 287-293, 1990.
C
C [2] Voigt, M.
C L-infinity-Norm Computation for Descriptor Systems.
C Diploma Thesis, Fakultaet fuer Mathematik, TU Chemnitz,
C http://nbn-resolving.de/urn:nbn:de:bsz:ch1-201001050.
C
C [3] Benner, P., Sima, V. and Voigt, M.
C L-infinity-norm computation for continuous-time descriptor
C systems using structured matrix pencils.
C IEEE Trans. Auto. Contr., AC-57, pp.233-238, 2012.
C
C [4] Benner, P., Sima, V. and Voigt, M.
C Robust and efficient algorithms for L-infinity-norm
C computations for descriptor systems.
C 7th IFAC Symposium on Robust Control Design (ROCOND'12),
C pp. 189-194, 2012.
C
C [5] Benner, P., Sima, V. and Voigt, M.
C Algorithm 961: Fortran 77 subroutines for the solution of
C skew-Hamiltonian/Hamiltonian eigenproblems.
C ACM Trans. Math. Softw, 42, pp. 1-26, 2016.
C
C NUMERICAL ASPECTS
C
C If the algorithm does not converge in MAXIT = 30 iterations
C (INFO = 4), the tolerance must be increased, or the system is
C improper.
C
C FURTHER COMMENTS
C
C Setting POLES = 'P' usually saves some computational effort. The
C number of poles used is defined by the parameters BM, BNEICD,
C BNEICM, BNEICX, BNEIR and SWNEIC.
C Both real and complex optimal workspace sizes are computed if
C either LDWORK = -1 or LZWORK = -1.
C
C CONTRIBUTORS
C
C M. Voigt, Max Planck Institute for Dynamics of Complex Technical
C Systems, March 2011.
C V. Sima, Research Institute for Informatics, Bucharest, Dec. 2011.
C Partly based on the SLICOT Library routine AB13DD by D. Sima and
C V. Sima.
C
C REVISIONS
C
C V. Sima, Mar. 2012, Apr. 2012, May 2012, June 2012, June-Nov.
C 2022, Jan. 2023, Mar.-Aug. 2023, Oct. 2023 - Jan. 2024.
C M. Voigt, Apr. 2017, Sep. 2017.
C
C KEYWORDS
C
C H-infinity optimal control, robust control, system norm.
C
C ******************************************************************
C
C .. Parameters ..
C BM specifies the maximum number of midpoints to be used in the
C iterative part of the algorithm if POLES = 'P'; similarly,
C BNEICD, BNEICM, and BNEICX specify the number of complex poles
C (with positive imaginary part) to be used as test frequencies,
C and BNEIR has the same purpose for real poles;
C MAXIT is the maximum number of iterations;
C SWNEIC is the system order when the number of complex poles to be
C used is increased.
C
INTEGER BM, BNEICD, BNEICM, BNEICX, BNEIR, MAXIT,
$ SWNEIC
PARAMETER ( BM = 2, BNEICD = 10, BNEICM = 45,
$ BNEICX = 60, BNEIR = 3, MAXIT = 30,
$ SWNEIC = 300 )
DOUBLE PRECISION ZERO, P1, P25, ONE, TWO, FOUR, TEN, HUNDRD,
$ THOUSD
PARAMETER ( ZERO = 0.0D+0, P1 = 0.1D+0, P25 = 0.25D+0,
$ ONE = 1.0D+0, TWO = 2.0D+0, FOUR = 4.0D+0,
$ TEN = 1.0D+1, HUNDRD = 1.0D+2,
$ THOUSD = 1.0D+3 )
COMPLEX*16 CONE
PARAMETER ( CONE = ( 1.0D+0, 0.0D+0 ) )
C ..
C .. Scalar Arguments ..
CHARACTER CKPROP, DICO, EQUIL, JOBD, JOBE, POLES, REDUCE
INTEGER INFO, IWARN, LDA, LDB, LDC, LDD, LDE, LDWORK,
$ LZWORK, M, N, NR, P, RANKE
C ..
C .. Array Arguments ..
COMPLEX*16 ZWORK( * )
DOUBLE PRECISION A( LDA, * ), B( LDB, * ), C( LDC, * ),
$ D( LDD, * ), DWORK( * ), E( LDE, * ),
$ FPEAK( 2 ), GPEAK( 2 ), TOL( * )
INTEGER IWORK( * )
LOGICAL BWORK( * )
C ..
C .. Local Scalars ..
CHARACTER EIGENV, JBDX, JOB, JOBEIG, JOBSYS, NCSING,
$ NEQUIL, NOVECT, NTRAN, QZVECT, RESTOR, SVEC,
$ TRANS, UPDATE, VECT
LOGICAL ALLPOL, CASE0, CASE1, CASE2, CASE3, CMPRE,
$ DISCR, FULLRD, GENE, ILASCL, ILESCL, IND1,
$ ISPROP, LEQUIL, LINF, LQUERY, NCMPRE, NODYN,
$ NSRT, REALW, UNITE, USEPEN, WCKPRP, WITHD,
$ WITHE, WNRMD, WREDUC, ZEROD
INTEGER I, I0, I1, I2, IA, IAS, IB, IBS, IBT, IBV, IC,
$ ICI, ICU, ICW, ID, IE, IERR, IES, IH, IH12,
$ IH22, IHC, IHI, II, IJ, IJ12, ILFT, ILO, IM,
$ IMIN, IQ, IR, IRHT, IRLW, IS, ISB, ISC, ISL,
$ IT, IT12, ITAU, ITER, IU, IV, IWRK, IZ, J, K,
$ L, LIW, LW, M0, MAXCWK, MAXPM, MAXWRK, MINCWK,
$ MINPM, MINWRK, MNW13X, MNWSVD, N1, N2, NBLK,
$ NBLK2, NC, NE, NEI, NEIC, NEIR, NINF, NK, NN,
$ NR2, NWS, ODW13X, ODWSVD, P0, PM, PMQ, Q, QP,
$ R, RNKE, SDIM, SDIM1, TN, TNR, WR13ID
DOUBLE PRECISION ANRM, ANRMTO, BIGNUM, BNORM, BOUND, CND, CNORM,
$ DIF, ENRM, ENRMTO, EPS, FPEAKI, FPEAKS, GAMMA,
$ GAMMAL, GAMMAS, MAXRED, OMEGA, OZ, PI, RAT,
$ RCOND, SAFMAX, SAFMIN, SCL, SMLNUM, STOL, SV1,
$ SVP, TD, TEPS, THRESH, TM, TMP, TMR, TOL1,
$ TOL2, TOLDEF, TOLER, TOLN, TOLP, TZER, WMAX,
$ WRMIN
C ..
C .. Local Arrays ..
INTEGER IDUM( 1 )
DOUBLE PRECISION DUM( 3 ), GAM( 1 ), MGAM( 1 ), ONES( 1 ),
$ TOLI( 3 )
C ..
C .. External Functions ..
LOGICAL AB13ID, LSAME
DOUBLE PRECISION AB13DX, DLAMCH, DLANGE, DLANHS, DLANTR, DLAPY2,
$ MA02SD
EXTERNAL AB13DX, AB13ID, DLAMCH, DLANGE, DLANHS, DLANTR,
$ DLAPY2, LSAME, MA02SD
C ..
C .. External Subroutines ..
EXTERNAL DAXPY, DCOPY, DGEBAL, DGECON, DGEHRD, DGEMM,
$ DGEQRF, DGESVD, DGETRF, DGETRS, DGGBAK, DGGBAL,
$ DHGEQZ, DHSEQR, DLABAD, DLACPY, DLADIV, DLASCL,
$ DLASET, DLASRT, DORMHR, DORMQR, DSCAL, DSWAP,
$ DSYRK, DTGSEN, DTRCON, DTRSM, MA02AD, MB01SD,
$ MB02RD, MB02SD, MB02TD, MB03XD, MB04BP, SB04OD,
$ TB01ID, TG01AD, TG01BD, XERBLA, ZGESVD
C ..
C .. Intrinsic Functions ..
INTRINSIC ABS, ATAN, ATAN2, COS, DBLE, INT, LOG, MAX,
$ MIN, MOD, SIN, SQRT
C ..
C .. Executable Statements ..
C
C Test the input scalar parameters.
C
NN = N*N
MINPM = MIN( P, M )
MAXPM = MAX( P, M )
IWARN = 0
INFO = 0
DISCR = LSAME( DICO, 'D' )
UNITE = LSAME( JOBE, 'I' )
GENE = LSAME( JOBE, 'G' )
CMPRE = LSAME( JOBE, 'C' )
LEQUIL = LSAME( EQUIL, 'S' )
WITHD = LSAME( JOBD, 'D' )
FULLRD = LSAME( JOBD, 'F' )
ZEROD = LSAME( JOBD, 'Z' )
WCKPRP = LSAME( CKPROP, 'C' )
WREDUC = LSAME( REDUCE, 'R' )
ALLPOL = LSAME( POLES, 'A' )
WITHE = GENE .OR. CMPRE
LQUERY = LDWORK.EQ.-1 .OR. LZWORK.EQ.-1
C
IF( .NOT. ( DISCR .OR. LSAME( DICO, 'C' ) ) ) THEN
INFO = -1
ELSE IF( .NOT. ( WITHE .OR. UNITE ) ) THEN
INFO = -2
ELSE IF( .NOT. ( LEQUIL .OR. LSAME( EQUIL, 'N' ) ) ) THEN
INFO = -3
ELSE IF( .NOT. ( WITHD .OR. FULLRD .OR. ZEROD ) ) THEN
INFO = -4
ELSE IF( .NOT. ( WCKPRP .OR. LSAME( CKPROP, 'N' ) ) ) THEN
IF( .NOT.( DISCR .OR. UNITE ) )
$ INFO = -5
ELSE IF( .NOT. ( WREDUC .OR. LSAME( REDUCE, 'N' ) ) ) THEN
IF( WCKPRP )
$ INFO = -6
ELSE IF( .NOT. ( ALLPOL .OR. LSAME( POLES, 'P' ) ) ) THEN
INFO = -7
ELSE IF( N.LT.0 ) THEN
INFO = -8
ELSE IF( M.LT.0 ) THEN
INFO = -9
ELSE IF( P.LT.0 ) THEN
INFO = -10
ELSE IF( CMPRE .AND. ( RANKE.LT.0 .OR. RANKE.GT.N ) ) THEN
INFO = -11
ELSE IF( MIN( FPEAK( 1 ), FPEAK( 2 ) ).LT.ZERO ) THEN
INFO = -12
ELSE IF( LDA.LT.MAX( 1, N ) ) THEN
INFO = -14
ELSE IF( LDE.LT.1 .OR. ( GENE .AND. LDE.LT.N ) .OR.
$ ( CMPRE .AND. LDE.LT.RANKE ) ) THEN
INFO = -16
ELSE IF( LDB.LT.MAX( 1, N ) ) THEN
INFO = -18
ELSE IF( LDC.LT.MAX( 1, P ) ) THEN
INFO = -20
ELSE IF( LDD.LT.1 .OR. ( .NOT.ZEROD .AND. LDD.LT.P ) ) THEN
INFO = -22
ELSE IF( TOL( 1 ).LT.ZERO .OR. TOL( 1 ).GE.ONE ) THEN
INFO = -25
ELSE IF( .NOT.LEQUIL .AND. TOL( 2 ).GE.ONE ) THEN
INFO = -25
ELSE IF( .NOT.DISCR .AND. WITHE .AND. WCKPRP .AND.
$ ( TOL( 3 ).GE.ONE .OR. TOL( 4 ).GE.ONE ) ) THEN
INFO = -25
ELSE
NODYN = N.EQ.0
IF( .NOT.NODYN ) THEN
BNORM = DLANGE( '1-norm', N, M, B, LDB, DWORK )
CNORM = DLANGE( '1-norm', P, N, C, LDC, DWORK )
NODYN = MIN( BNORM, CNORM ).EQ.ZERO
END IF
C
C Option FULLRD is useless for discrete-time systems.
C
IF( DISCR .AND. FULLRD )
$ FULLRD = .FALSE.
WITHD = WITHD .OR. FULLRD
C
C Compute workspace.
C
C Note: The workspace requirement is dominated by the solution of
C the generalized skew-Hamiltonian/Hamiltonian eigenvalue
C problem, when needed.
C
MINCWK = 1
MAXCWK = 1
IF( MINPM.EQ.0 .OR. ( NODYN .AND. ZEROD ) ) THEN
MINWRK = 1
MAXWRK = 1
ELSE
USEPEN = WITHE .OR. DISCR
EIGENV = 'E'
NTRAN = 'N'
NOVECT = 'N'
SVEC = NOVECT
TRANS = 'T'
C
IF( CMPRE ) THEN
CMPRE = RANKE.LT.N
NCMPRE = .NOT.CMPRE
ELSE
NCMPRE = .FALSE.
RANKE = N
END IF
C
IF( DISCR .OR. UNITE ) THEN
WCKPRP = .FALSE.
WREDUC = .FALSE.
END IF
C
C Optimal and minimum local workspace for DGESVD/ZGESVD and
C AB13DX.
C
IF( LQUERY ) THEN
CALL DGESVD( NOVECT, NOVECT, P, M, DWORK, P, DWORK,
$ DWORK, P, DWORK, M, DWORK, -1, IERR )
ODWSVD = INT( DWORK( 1 ) )
ODW13X = MINPM + ODWSVD
END IF
C
IU = 0
IF( NODYN ) THEN
IF( WITHD ) THEN
MNWSVD = MAX( 3*MINPM + MAXPM, 5*MINPM )
MINWRK = P*M + MINPM + MNWSVD
IF( LQUERY )
$ MAXWRK = MAX( MINWRK, P*M + MINPM + ODWSVD )
ELSE
MAXWRK = 1
END IF
ELSE
I0 = ( N + M )*( N + P )
IE = 0
PM = P + M
IF( LQUERY ) THEN
CALL ZGESVD( NOVECT, NOVECT, P, M, ZWORK, P, DWORK,
$ ZWORK, P, ZWORK, M, ZWORK, -1, DWORK,
$ IERR )
MAXCWK = I0 + INT( ZWORK( 1 ) )
END IF
C
MINCWK = I0 + 2*MINPM + MAXPM
MNWSVD = 5*MINPM
IF( DISCR ) THEN
MINWRK = 0
MAXWRK = 0
ELSE
MNWSVD = MAX( MNWSVD, 3*MINPM + MAXPM )
IF( WITHD ) THEN
C
C Workspace for finding maximum singular value of D.
C
IF( UNITE ) THEN
IU = N*PM + MINPM
IE = IU
IWRK = IU + P*P + PM*M
SVEC = 'AllVec'
IF( LQUERY ) THEN
CALL DGESVD( SVEC, SVEC, P, M, DWORK, P,
$ DWORK, DWORK, P, DWORK, M,
$ DWORK, -1, IERR )
MAXWRK = IWRK + INT( DWORK( 1 ) )
END IF
ELSE
IWRK = MINPM + P*M
MAXWRK = 0
END IF
MINWRK = IWRK + MNWSVD
ELSE
MINWRK = 0
MAXWRK = 0
END IF
END IF
MNW13X = MINPM + MNWSVD
C
TN = 2*N
IB = IE + NN
IR = IB + N*PM
IBT = IR + TN
C
IF( WITHE ) THEN
NSRT = CMPRE .OR. DISCR
IB = IB + NN
IR = IR + NN
IBT = IBT + NN
IF( WCKPRP ) THEN
NEQUIL = 'NoEquil'
NCSING = 'NCkSing'
RESTOR = 'No'
IF( CMPRE ) THEN
JOBSYS = 'NotRed'
ELSE
JOBSYS = 'Reduce'
END IF
C
C Workspace for checking properness.
C
I0 = NN + 4*N
I1 = N + MAXPM
IF( P.EQ.M ) THEN
I2 = IR
ELSE
I2 = IB + TN*MAXPM
END IF
C
IF( WREDUC ) THEN
C
C A reduced-order system is used for finding norm.
C
JOBEIG = 'Allnmn'
UPDATE = 'Upd'
I0 = I0 + 4
IF( CMPRE ) THEN
WR13ID = MAX( I0, I1 )
ELSE
WR13ID = MAX( I0, 2*( I1 - 1 ) )
END IF
ELSE
C
C Original system is used for finding norm.
C
JOBEIG = 'Infnmn'
UPDATE = 'NoUpd'
IF( CMPRE ) THEN
WR13ID = 4*N + 4
ELSE
WR13ID = MAX( I0, 2*( I1 - 1 ), 8 )
END IF
END IF
MINWRK = MAX( MINWRK, I2 + WR13ID )
IF( LQUERY ) THEN
DUM( 1 ) = ZERO
DUM( 2 ) = ZERO
DUM( 3 ) = ZERO
ISPROP = AB13ID( JOBSYS, JOBEIG, NEQUIL, NCSING,
$ RESTOR, UPDATE, N, M, P, DWORK,
$ N, DWORK, N, DWORK, N, DWORK,
$ MAXPM, N, RNKE, DUM, IWORK,
$ DWORK, -1, IWARN, IERR )
MAXWRK = MAX( MAXWRK, I2 + INT( DWORK( 1 ) ) )
END IF
END IF
C
IF( .NOT.DISCR ) THEN
I1 = ( N + P )*M
IF( CMPRE ) THEN
C
C Workspace for finding the largest singular value
C of G(infinity).
C
MINWRK = MAX( MINWRK, IR + MAX( N*( N + M + 4 ),
$ I1 + MNW13X ) )
END IF
IF( LQUERY )
$ MAXWRK = MAX( MAXWRK, I1 + ODW13X, MINWRK )
END IF
C
C Workspace for computing Hessenberg-triangular form.
C
I1 = IBT + N
IF( NSRT ) THEN
MINWRK = MAX( MINWRK, I1 + MAX( M, 2*NN + N ) )
ELSE
I1 = I1 + 2*NN + TN
MINWRK = MAX( MINWRK, I1 + TN )
END IF
IF( LQUERY ) THEN
CALL DGEQRF( N, N, A, LDA, DWORK, DWORK, -1, IERR )
CALL DORMQR( 'Left', TRANS, N, N, N, DWORK, N,
$ DWORK, DWORK, N, DUM, -1, IERR )
IF( NSRT ) THEN
CALL DORMQR( 'Left', TRANS, N, M, N, DWORK, N,
$ DWORK, DWORK, N, DUM( 2 ), -1,
$ IERR )
ELSE
CALL DORMQR( 'Right', NTRAN, N, N, N, DWORK, N,
$ DWORK, DWORK, N, DUM( 2 ), -1,
$ IERR )
END IF
MAXWRK = MAX( I1 + MAX( INT( DWORK( 1 ) ),
$ INT( DUM( 1 ) ),
$ INT( DUM( 2 ) ) ), MAXWRK )
END IF
C
IF( .NOT.NSRT ) THEN
C
C Workspace for moving finite eigenvalues to the top.
C
MINWRK = MAX( MINWRK, I1 + MAX( 4*N + 16,
$ N*MAXPM ) )
C
C Workspace for finding the largest singular value of
C G(infinity).
C
I1 = IBT + N + P*M
I2 = I1 + ( N - 1 )*PM
MINWRK = MAX( MINWRK,
$ I2 + ( N - 1 )*( N + M + 2 ) )
IF( LQUERY ) THEN
CALL SB04OD( 'NoReduction', NTRAN, 'Fro', N, N,
$ DWORK, N, DWORK, N, DWORK, N,
$ DWORK, N, DWORK, N, DWORK, N, SCL,
$ DIF, DWORK, 1, DWORK, 1, DWORK, 1,
$ DWORK, 1, IWORK, DWORK, -1, IERR )
MAXWRK = MAX( MAXWRK, I2 + N*( N + 1 ) / 2 +
$ INT( DWORK( 1 ) ) )
END IF
IF( WITHD ) THEN
MINWRK = MAX( MINWRK, I1 + MNW13X )
IF( LQUERY )
$ MAXWRK = MAX( MAXWRK, I1 + ODW13X )
END IF
END IF
C
ELSE
II = IR + N
IF( LQUERY ) THEN
CALL DGEHRD( N, 1, N, DWORK, N, DWORK, DWORK, -1,
$ IERR )
CALL DORMHR( 'Left', TRANS, N, M, 1, N, DWORK, N,
$ DWORK, DWORK, N, DUM, -1, IERR )
CALL DORMHR( 'Right', NTRAN, P, N, 1, N, DWORK, N,
$ DWORK, DWORK, P, DUM( 2 ), -1, IERR )
CALL DHSEQR( EIGENV, NOVECT, N, 1, N, DWORK, N,
$ DWORK, DWORK, DWORK, 1, DUM( 3 ), -1,
$ IERR )
MAXWRK = MAX( II + MAX( INT( DWORK( 1 ) ),
$ INT( DUM( 1 ) ),
$ INT( DUM( 2 ) ) ),
$ IBT + NN + INT( DUM( 3 ) ), MAXWRK )
END IF
END IF
C
C Workspace for finding eigenvalues on the boundary of
C stability domain and the maximum singular value of G on
C test frequencies.
C
IWRK = IBT + N
IF( WITHE )
$ IWRK = IWRK + N
IF( .NOT.DISCR )
$ IWRK = IWRK + NN + M*( N + P )
MINWRK = MAX( MINWRK, IWRK + MNW13X )
IF( LQUERY )
$ MAXWRK = MAX( MAXWRK, IWRK + ODW13X )
C
C Workspace for the modified gamma iteration.
C
IF( UNITE .AND. .NOT.DISCR .AND. ( ZEROD .OR. FULLRD ) )
$ THEN
I0 = 2*NN + N
I1 = I0 + 7*N
I2 = IBT + I0
IF( LQUERY ) THEN
CALL MB03XD( 'Both', EIGENV, NOVECT, NOVECT, N,
$ DWORK, N, DWORK, N, DWORK, N, DUM, 1,
$ DUM, 1, DUM, 1, DUM, 1, DWORK, DWORK,
$ 1, DWORK, DWORK, -1, IERR )
MAXWRK = MAX( MAXWRK, I2 + NN + N +
$ INT( DWORK( 1 ) ), II + ODW13X )
END IF
IF( ZEROD ) THEN
I2 = I2 + I1
ELSE
I2 = I2 + MAX( MAXPM + N*PM, I1 )
END IF
MINWRK = MAX( MINWRK, I2 )
ELSE
R = MOD( PM, 2 )
NBLK = N + ( PM + R ) / 2
NBLK2 = NBLK*NBLK
I0 = IR + 7*NBLK2 + 5*NBLK
L = 8*NBLK
IF( MOD( NBLK, 2 ).EQ.0 )
$ L = L + 4
MINWRK = MAX( MINWRK, I0 + 4*NBLK2 + MAX( L, 36 ) )
END IF
C
IF( LQUERY ) THEN
MAXWRK = MAX( MINWRK, MAXWRK )
MAXCWK = MAX( MINCWK, MAXCWK )
END IF
END IF
END IF
C
IF( LQUERY ) THEN
DWORK( 1 ) = MAXWRK
ZWORK( 1 ) = MAXCWK
RETURN
ELSE
IF( LDWORK.LT.MINWRK ) THEN
INFO = -28
DWORK( 1 ) = MINWRK
END IF
IF( LZWORK.LT.MINCWK ) THEN
INFO = -30
ZWORK( 1 ) = MINCWK
END IF
END IF
C
END IF
C
IF( INFO.NE.0 ) THEN
IF( LDWORK.NE.0 .AND. LZWORK.NE.0 )
$ CALL XERBLA( 'AB13HD', -INFO )
RETURN
END IF
C
C Quick return if possible.
C
ITER = 0
C
IF( MINPM.EQ.0 ) THEN
GPEAK( 1 ) = ZERO
GPEAK( 2 ) = ONE
FPEAK( 1 ) = ZERO
FPEAK( 2 ) = ONE
DWORK( 1 ) = ONE
ZWORK( 1 ) = CONE
IWORK( 1 ) = ITER
RETURN
END IF
C
C Determine the maximum singular value of G(infinity) = D,
C if JOBD <> 'Z' and (N = 0, or B = 0, or C = 0, or
C (DICO = 'C' and (JOBE = 'I' or (JOBE = 'C' and RANKE = N))) ).
C
C If DICO = 'C' and JOBE = 'I', the full SVD of D, D = U*S*V', is
C computed; then B and C are updated in the workspace and saved for
C later use.
C
C (Note: Comments in the code beginning "Workspace:" describe the
C minimal amount of real workspace needed at that point in the
C code, as well as the preferred amount for good performance.
C NB refers to the optimal block size for the immediately
C following subroutine, as returned by ILAENV.)
C
IF( WITHD ) THEN
OZ = ONE
WNRMD = NODYN .OR. ( ( UNITE .OR. NCMPRE ) .AND. .NOT.DISCR )
IF( WNRMD ) THEN
IU = IU + 1
IF( .NOT.NODYN .AND. UNITE ) THEN
IBV = 1
ICU = IBV + N*M
IS = ICU + P*N
IV = IU + P*P
ID = IV + M*M
ELSE
IS = 1
IV = 1
ID = 1 + MINPM
END IF
IWRK = ID + P*M
C
C Workspace: need P*M + MIN(P,M) + V +
C MAX( 3*MIN(P,M) + MAX(P,M), 5*MIN(P,M) ),
C where V = N*(M+P) + P*P + M*M, if
C DICO = 'C', JOBE = 'I',
C JOBD <> 'Z', B <> 0, and C <> 0,
C V = 0, if (DICO = 'C', JOBE = 'C',
C RANKE = N, JOBD <> 'Z'), or
C B = 0, or C = 0;
C prefer larger.
C
CALL DLACPY( 'Full', P, M, D, LDD, DWORK( ID ), P )
CALL DGESVD( SVEC, SVEC, P, M, DWORK( ID ), P, DWORK( IS ),
$ DWORK( IU ), P, DWORK( IV ), M, DWORK( IWRK ),
$ LDWORK-IWRK+1, IERR )
IF( IERR.GT.0 ) THEN
INFO = 3