File: matric.f

package info (click to toggle)
scilab 2.6-4
  • links: PTS
  • area: non-free
  • in suites: woody
  • size: 54,632 kB
  • ctags: 40,267
  • sloc: ansic: 267,851; fortran: 166,549; sh: 10,005; makefile: 4,119; tcl: 1,070; cpp: 233; csh: 143; asm: 135; perl: 130; java: 39
file content (309 lines) | stat: -rw-r--r-- 6,448 bytes parent folder | download
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
      subroutine matric
c ================================== ( Inria    ) =============
c       equations de lyapounov,sylvester et riccati
c ====================================================================
c     Copyright INRIA
      include '../stack.h'
      integer iadr,sadr
c
      double precision eps,rcond
      integer cont,disc
      data disc/13/,cont/12/
c
c    fin    1       2       3
c         lyap    sylv     ricc
c
c
      iadr(l)=l+l-1
      sadr(l)=(l/2)+1
c
      if (ddt .eq. 4) then
         write(buf(1:4),'(i4)') fin
         call basout(io,wte,' matric '//buf(1:4))
      endif
c
      eps=stk(leps)
      lz=lstk(top+1)
c
      if(fin.eq.1) then
         if(rhs.ne.3) then
            call error(39)
            return
         endif
      endif
      if(fin.eq.2.or.fin.eq.3) then
         if(rhs.ne.4) then
            call error(39)
            return
         endif
      endif
      ilcd=iadr(lstk(top))
      if(istk(ilcd).ne.10) then
         err=rhs
         call error(55)
         return
      endif
      icd=abs(istk(ilcd+5+istk(ilcd+1)*istk(ilcd+2)))
      if(icd.ne.cont .and. icd.ne.disc) then
         err=rhs
         call error(36)
         return
      endif
c
c     second membre
      top=top-1
      ic=iadr(lstk(top))
      if(istk(ic).ne.1) then
         err=rhs-1
         call error(53)
         return
      endif
      if(istk(ic+3).ne.0) then
         err=rhs-1
         call error(52)
         return
      endif
      mc=istk(ic+1)
      nc=istk(ic+2)
      nnc=nc*mc
      lc=sadr(ic+4)
      top=top-1
c
      err=0
      goto(10,20,30) fin
c lyapounov
  10  continue
c
      if(mc.ne.nc) then
         err=2
         call error(20)
         return
      endif
c
c    dynamique
      ia=iadr(lstk(top))
      if(istk(ia).ne.1) then
         err=1
         call error(53)
         return
      endif
      if(istk(ia+3).ne.0) then
         err=1
         call error(52)
         return
      endif
      ma=istk(ia+1)
      na=istk(ia+2)
      nna=na*ma
      la=sadr(ia+4)
      if(ma.ne.na) then
         call error(20)
         return
      endif
c
      if(ma.ne.mc) then
         call error(60)
         return
      endif
c
      err=lz+nna+na - lstk(bot)
      if(err.gt.0) then
         call error(17)
         return
      endif
c
      if(icd.eq.cont) call lybsc(na,stk(la),na,stk(lc),stk(lc),
     x                           stk(lz),eps,stk(lz+nna),0,err)
      if(icd.eq.disc) call lybad(na,stk(la),na,stk(lc),stk(lc),
     x                           stk(lz),eps,stk(lz+nna),0,err)
      if(err.gt.0) then
         call error(24)
         return
      endif
      call unsfdcopy(nna,stk(lc),1,stk(la),1)
      return
c
  20  continue
c    sylvester a*x+x*b=c
c
c    matrice b
      ib=iadr(lstk(top))
      if(istk(ib).ne.1) then
         err=2
         call error(53)
         return
      endif
      if(istk(ib+3).ne.0) then
         err=2
         call error(52)
         return
      endif
      mb=istk(ib+1)
      nb=istk(ib+2)
      if(mb.ne.nb) then
         err=2
         call error(20)
         return
      endif
      nnb=nb*mb
      lb=sadr(ib+4)
c
c       matrice a
      top=top-1
      ia=iadr(lstk(top))
      if(istk(ia).ne.1) then
         err=1
         call error(53)
         return
      endif
      if(istk(ia+3).ne.0) then
         err=1
         call error(52)
         return
      endif
      ma=istk(ia+1)
      na=istk(ia+2)
      if(ma.ne.na) then
         err=1
         call error(20)
         return
      endif
      nna=ma*na
      ita=istk(ia+3)
      la=sadr(ia+4)
c
      if(na.ne.mc.or.nc.ne.mb) then
         call error(60)
         return
      endif
c
      if(icd.eq.disc) goto 25
      nw1=2*nna+7*na
      nw2=max(na,nb)
      nw3=4*na
      err=lz+nna+nw1+nw2+nw3-lstk(bot)
      if(err.gt.0) then
         call error(17)
         return
      endif
c
      na4=na+4
      call syhsc(na,nb,stk(la),na,stk(lb),nb,stk(lc),
     x                 stk(lz),eps,stk(lz+nnb),
     x           nw1,stk(lz+nnb+nw1),nw2,stk(lz+nnb+nw1+nw2),nw3,err)
      if(err.gt.0) then
         call error(19)
         return
      endif
      call unsfdcopy(nnc,stk(lc),1,stk(la),1)
      istk(ia+1)=mc
      istk(ia+2)=nc
      lstk(top+1)=la+mc*nc
      return
   25 continue
      lu=lz
      lv=lu+na*na
      lw=lv+nb*nb
      err=lw+max(na,nb)-lstk(bot)
      if(err.gt.0) then
         call error(17)
         return
      endif
      call sybad(na,nb,stk(la),na,stk(lb),nb,stk(lc),na,stk(lu),
     1           stk(lv),eps,stk(lw),0,err)
      if(err.gt.0) then
         call error(19)
         return
      endif
      call unsfdcopy(na*nb,stk(lc),1,stk(la),1)
      istk(ia+1)=mc
      istk(ia+2)=nc
      lstk(top+1)=la+mc*nc
      return
c
c    riccati
c
  30  continue
c
c    a'*x+x*a-x*b*x+c=0
c
c         matrice b
      ib=iadr(lstk(top))
      if(istk(ib).ne.1) then
         err=2
         call error(53)
         return
      endif
      if(istk(ib+3).ne.0) then
         err=2
         call error(52)
         return
      endif
      mb=istk(ib+1)
      nb=istk(ib+2)
      if(mb.ne.nb) then
         err=2
         call error(20)
         return
      endif
      nnb=mb*nb
      lb=sadr(ib+4)
c
      top=top-1
      ia=iadr(lstk(top))
      if(istk(ia).ne.1) then
         err=1
         call error(53)
         return
      endif
      if(istk(ia+3).ne.0) then
         err=1
         call error(52)
         return
      endif
      ma=istk(ia+1)
      na=istk(ia+2)
      if(ma.ne.na) then
         err=1
         call error(20)
         return
      endif
      nna=na*ma
      nn=na+na
      la =sadr(ia+4)
c
      if(ma.ne.mb) then
         call error(42)
         return
      endif
c
      lw=lz
      lz=lw+nn*nn
      lw1=lz+nn*nn
      lw2=lw1+nn
      lw3=lw2+nn
      err=lw3+nn-lstk(bot)
      if(err.gt.0) then
         call error(17)
         return
      endif
c
      if(icd.eq.disc) goto 31
      call rilac(na,nn,stk(la),na,stk(lc),stk(lb),rcond,stk(la),
     x           stk(lw),nn,stk(lz),eps,stk(lw3),
     x           stk(lw1),stk(lw2),err)
      if(err.ne.0) then
         call error(24)
         return
      endif
      return
  31  continue
      call ricd(na,nn,stk(la),na,stk(lc),stk(lb),rcond,stk(la),
     x          stk(lw),nn,stk(lz),eps,stk(lw3),
     x          stk(lw1),stk(lw2),err)
      if(err.ne.0) then
         call error(24)
         return
      endif
      return
      end