1
subroutine sszer(n,m,p,a,na,b,c,nc,d,eps,zeror,zeroi,nu,irank,af,
2
& naf,bf,mplusn,wrka,wrk1,nwrk1,wrk2,nwrk2,ierr)
6
C subroutine sszer(n,m,p,a,na,b,c,nc,d,zeror,zeroi,nu,irank,
7
C 1 af,naf,bf,mplusn,wrka,wrk1,nwrk1,wrk2,nwrk2,ierr)
9
C integer n,m,p,na,nc,nu,irank,nabf,mplusn,nwrk1,nwrk2,ierr
11
C double precision a(na,n),b(na,m),c(nc,n),d(nc,m),wrka(na,n)
12
C double precision af(naf,mplusn),bf(naf,mplusn)
13
C double precision wrk1(nwrk1),wrk2(nwrk2)
14
C double precision zeror(n),zeroi(n)
19
C -the number of state variables in the system
22
C -the number of inputs to the system
25
C -the number of outputs from the system
27
C a double precision (n,n)
28
C -the state dynamics matrix of the system
31
C -the declared first dimension of matrices a and b
33
C b double precision (n,m)
34
C -the input/state matrix of the system
36
C c double precision (p,n)
37
C -the state/output matrix of the system
40
C -the declared first dimension of matrices c and d
42
C d double precision (p,m)
43
C -the input/output matrix of the system
46
C -the declared first dimension of matrices af and bf
47
C naf must be at least n + p
50
C -the second dimension of af and bf. mplusn must be
54
C -the length of work vector wrk1.
55
C nwrk1 must be at least max(m,p)
58
C -the length of work vector wrk2.
59
C nwrk2 must be at least max(n,m,p)+1
64
C -the number of (finite) invariant zeros
67
C -the normal rank of the transfer function
69
C zeror double precision (n)
70
C zeroi double precision (n)
71
C -the real and imaginary parts of the zeros
73
C af double precision ( n+p , m+n )
74
C bf double precision ( n+p , m+n )
75
C -the coefficient matrices of the reduced pencil
80
C ierr = 0 successful return
82
C ierr = 1 incorrect dimensions of matrices
84
C ierr = 2 attempt to divide by zero
86
C ierr = i > 2 ierr value i-2 from qitz (eispack)
90
C wrka double precision (na,n)
92
C wrk1 double precision (nwrk1)
94
C wrk2 double precision (nwrk2)
98
C to compute the invariant zeros of a linear multivariable
99
C system given in state space form.
103
C this routine extracts from the system matrix of a state-space
104
C system a,b,c,d a regular pencil lambda * bf - af
105
C which has the invariant zeros of the system as generalized
110
C emami-naeini, a. and van dooren, p.
111
C 'computation of zeros of linear multivariable systems'
112
C report na-80-03, computer science department, stanford univ.
116
C a.emami-naeini, computer science department,
117
C stanford university.
120
integer n,m,p,na,nc,nu,irank,naf,mplusn,nwrk1,nwrk2,ierr
122
double precision a(na,n),b(na,m),c(nc,n),d(nc,m)
123
double precision wrka(na,n),zeror(n),zeroi(n)
124
double precision af(naf,mplusn),bf(naf,mplusn),wrk1(nwrk1),
126
double precision eps,sum,heps,xxx(1,1)
130
logical zero,matq,matz
132
integer mm,nn,pp,mu,iro,isigma,numu,mnu,numu1,mnu1,i,j,j1
137
if (na .lt. n) return
138
if (nc .lt. p) return
139
if (naf .lt. n+p) return
140
if (nwrk1 .lt. m) return
141
if (nwrk1 .lt. p) return
142
if (nwrk2 .lt. n) return
143
if (nwrk2 .lt. m) return
144
if (nwrk2 .lt. p) return
145
if (mplusn .lt. m+n) return
147
C construct the compound matrix (b a) of dimension
155
sum = sum + (b(i,j)*b(i,j))
160
sum = sum + (a(i,j)*a(i,j))
167
sum = sum + (d(i,j)*d(i,j))
172
sum = sum + (c(i,j)*c(i,j))
175
heps = eps * sqrt(sum)
177
C reduce this system to one with the same invariant zeros and with
178
C d full row rank mu (the normal rank of the original system)
183
call preduc(bf,naf,mplusn,m,n,p,heps,iro,isigma,mu,nu,wrk1,nwrk1,
187
if (nu .eq. 0) return
189
C pertranspose the system
205
if (mu .eq. mm) goto 80
210
C reduce the system to one with the same invariant zeros and with
211
C d square and of full rank
216
call preduc(af,naf,mplusn,mm,nn,pp,heps,iro,isigma,mu,nu,wrk1,
219
if (nu .eq. 0) return
230
if (irank .eq. 0) return
238
wrk2(j) = af(numu,mj)
241
call house(wrk2,nu1,nu1,heps,zero,s)
242
call tr2(af,naf,mplusn,wrk2,s,1,numu,j1,nu1)
243
call tr2(bf,naf,mplusn,wrk2,s,1,nu,j1,nu1)
250
call qhesz(naf,nu,af,bf,matq,xxx,matz,wrka)
251
call qitz(naf,nu,af,bf,eps,matq,xxx,matz,wrka,ierr)
252
if (ierr .ne. 0) goto 150
254
call qvalz(naf,nu,af,bf,eps,zeror,zeroi,wrk2,matq,xxx,matz,wrka)
257
C if (wrk2(i) .eq. 0.0d+0) go to 140
258
C zeror(i) = zeror(i)/wrk2(i)
259
C zeroi(i) = zeroi(i)/wrk2(i)
262
Cc successful completion
267
Cc attempt to divide by zero
272
Cc failure in subroutine qzit
277
subroutine preduc(abf,naf,mplusn,m,n,p,heps,iro,isigma,mu,nu,
278
1 wrk1,nwrk1,wrk2,nwrk2)
280
c subroutine preduc(abf,naf,mplusn,m,n,p,heps,iro,isigma,mu,nu,
281
c 1 wrk1,nwrk1,wrk2,nwrk2)
282
c integer naf,mplusn,m,n,p,iro,isigma,mu,nu,nwrk1,nwrk2
283
c double precision abf(naf,mplusn),wrk1(nwrk1),wrk2(nwrk2)
287
c this routine is only to be called from slice routine sszer
289
integer naf,mplusn,m,n,p,iro,isigma,mu,nu,nwrk1,nwrk2
291
double precision abf(naf,mplusn),wrk1(nwrk1),wrk2(nwrk2)
295
integer i,j,i1,m1,n1,i2,mm1,mn1,irj,itau,iro1,icol
296
integer ibar,numu,irow
300
double precision s,temp
302
double precision sum,heps
307
10 if (mu .eq. 0) return
311
if (m .eq. 0) go to 120
314
if (isigma .le. 1) go to 40
316
c compress rows of d: first exploit triangular shape
322
wrk2(j) = abf(irj,icol)
325
call house(wrk2,iro1,1,heps,zero,s)
327
call tr1(abf,naf,mplusn,wrk2,s,irow,iro1,icol,mnu)
332
c continue with householder transformation with pivoting
334
40 if (isigma .ne. 0) go to 45
337
45 if (isigma .eq. m) go to 60
338
do 55 icol = isigma,m
342
sum = sum + (abf(irj,icol) * abf(irj,icol) )
348
do 100 icol = isigma,m
352
if (icol .eq. m) go to 80
354
call pivot(wrk1,temp,ibar,icol,m)
356
if (ibar .eq. icol) go to 80
357
wrk1(ibar) = wrk1(icol)
361
abf(i,icol) = abf(i,ibar)
362
70 abf(i,ibar) = temp
364
c perform householder transformation
369
90 wrk2(i) = abf(irj,icol)
371
call house(wrk2,iro1,1,heps,zero,s)
374
if (iro1 .eq. 1) return
376
call tr1(abf,naf,mplusn,wrk2,s,irow,iro1,icol,mnu)
381
100 wrk1(j) = wrk1(j) - (abf(irow,j) * abf(irow,j) )
386
c compress the columns of c
391
if (itau .eq. 1) go to 140
396
130 sum = sum + (abf(irj,j) * abf(irj,j) )
407
if (i .eq. 1) go to 160
409
call pivot(wrk1,temp,ibar,1,i)
411
if (ibar .eq. i) go to 160
417
abf(i2,j) = abf(irj,j)
418
150 abf(irj,j) = temp
420
c perform householder transformation
424
170 wrk2(j) = abf(i2,irj)
426
call house(wrk2,n1,n1,heps,zero,s)
429
if (n1 .eq. 1) go to 220
431
call tr2(abf,naf,mplusn,wrk2,s,1,i2,m,n1)
435
call tr1(abf,naf,mplusn,wrk2,s,0,n1,1,mn1)
439
190 wrk1(j) = wrk1(j) - (abf(irj,mn1) * abf(irj,mn1) )
446
if (iro .eq. 0) return
454
subroutine house(wrk2,k,j,heps,zero,s)
456
c warning - this routine is only to be called from slice routine
460
c this routine constructs a householder transformation h = i-s.uu
461
c that 'mirrors' a vector wrk2(1,...,k) to the j-th unit vector.
462
c if norm(wrk2) < heps, zero is put equal to .true.
463
c upon return, u is stored in wrk2
468
double precision wrk2(k),heps,s
476
double precision alfa,dum1
484
10 sum = sum + (wrk2(i) * wrk2(i) )
487
if (alfa .le. heps) return
491
if (dum1 .gt. 0.0d+0) alfa = -alfa
492
wrk2(j) = dum1 - alfa
493
s = 1.0d+0 / (sum - (alfa * dum1) )
498
subroutine tr1(a,na,n,u,s,i1,i2,j1,j2)
501
c subroutine tr1(a,na,n,u,s,i1,i2,j1,j2)
505
c this subroutine performs the householder transformation
507
c on the rows i1 + 1 to i1 + i2 of a, this from columns j1 to j2.
510
c warning - this routine is only to be called from slice routine
514
integer na,n,i1,i2,j1,j2
516
double precision a(na,n),u(i2),s
531
10 sum = sum + (u(i) * a(irj,j) )
537
20 a(irj,j) = a(irj,j) - (u(i) * y)
542
subroutine tr2(a,na,n,u,s,i1,i2,j1,j2)
545
c subroutine tr2(a,na,n,u,s,i1,i2,j1,j2)
548
c this routine performs the householder transformation h = i-s.uu
549
c on the columns j1 + 1 to j1 + j2 of a, this from rows i1 to i2.
553
c warning - this routine is only to be called from slice routine
556
integer na,n,i1,i2,j1,j2
558
double precision a(na,n),u(j2),s
573
10 sum = sum + (u(j) * a(i,irj) )
579
20 a(i,irj) = a(i,irj) - (u(j) * y)
584
subroutine pivot(vec,vmax,ibar,i1,i2)
586
c subroutine pivot(vec,vmax,ibar,i1,i2)
588
c double precision vec(i2),vmax
592
c this subroutine computes the maximal norm element (vthe max)
593
c of the vector vec(i1,...,i2), and its location ibar
595
c this routine is only to be called from slice routine sszer
600
double precision vec(i2),vmax
609
if (i1 .ge. i2) go to 20
612
if (abs(vec(i) ) .lt. vmax) go to 10
617
20 if (vec(ibar) .lt. 0.0d+0) vmax = -vmax