File: wspis.f

package info (click to toggle)
scilab 4.0-12
  • links: PTS
  • area: non-free
  • in suites: etch, etch-m68k
  • size: 100,640 kB
  • ctags: 57,333
  • sloc: ansic: 377,889; fortran: 242,862; xml: 179,819; tcl: 42,062; sh: 10,593; ml: 9,441; makefile: 4,377; cpp: 1,354; java: 621; csh: 260; yacc: 247; perl: 130; lex: 126; asm: 72; lisp: 30
file content (392 lines) | stat: -rw-r--r-- 13,295 bytes parent folder | download | duplicates (3)
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
      subroutine wspis(ma,na,ar,ai,nela,inda,i,ni,j,nj,
c     Copyright INRIA
     $     mb,nb,br,bi,mr,nr,rr,ri,nelr,indr,ierr,ita,itb)
c     insert a full submatrix in a sparse matrix
c     !
      integer inda(*),indr(*),i(*),j(*)
      integer mb,nb
      integer ma,na,ni,nj,mr,nr,nela,nelr,ierr
      double precision ar(nela),ai(nela),rr(*),ri(*),br(mb,*),bi(mb,*)
      double precision t
      logical allrow,allcol,bscal
      integer findl
      external findl
c     
      nelmx=nelr
      ierr=0
      mr=ni
      nr=nj
      allrow=ni.lt.0
      allcol=nj.lt.0
      if(allrow) then 
         mr=ma
         ni=mr
      else
         mi=0
         do 01 kk=1,ni
            mi=max(mi,i(kk))
 01      continue
         mr=max(ma,mi)
      endif
      if(allcol) then 
         nr=na
         nj=na
      else
         mj=0
         do 02 kk=1,nj
            mj=max(mj,j(kk))
 02      continue
         nr=max(na,mj)
      endif
      if (allrow.and.allcol) then
c     a(:,:)=b
         bscal=mb*nb.eq.1.and.ma*na.gt.1
         if(.not.bscal) then
            if(mb*nb.gt.nelmx) then
               ierr=1
               return
            endif
            call iset(mb,nb,indr,1)
            jr=1
            if(mb*nb.ne.0) then
               
               do 04 l=1,mb
                  do 03 k=1,nb
                     indr(mb+jr)=k
                     rr(jr)=br(l,k)
                     if(itb.ne.0) then
                        ri(jr)=bi(l,k)
                     else
                        ri(jr)=0.0d0
                     endif
                     jr=jr+1
 03               continue
 04            continue
            endif
            nelr=mb*nb
         else
            if(ma*na.gt.nelmx) then
               ierr=1
               return
            endif
            call iset(ma,0,indr,1)
            jr=1
            if(ma*na.ne.0) then
               do 06 l=1,ma
                  do 05 k=1,na
                     if(br(1,1).ne.0.0d0) then
                        indr(ma+jr)=k
                        rr(jr)=br(1,1)
                        if(itb.ne.0) then
                           ri(jr)=bi(1,1)
                        else
                           ri(jr)=0.0d0
                        endif
                        indr(l)=indr(l)+1
                        jr=jr+1
                     endif
 05               continue
 06            continue
            endif
            nelr=jr-1
         endif
      elseif(allcol) then
c     a(i,:)=b
         bscal=mb*nb.eq.1.and.na*ni.gt.1
         jr=1
         ja=1
         do 20 l=1,mr
            indr(l)=0
            ii=findl(l,i,ni)
            if(ii.eq.0) then
c     this line is not modified
               if(l.le.ma) then
                  indr(l)=inda(l)
                  call icopy(indr(l),inda(ma+ja),1,indr(mr+jr),1)
                  call unsfdcopy(indr(l),ar(ja),1,rr(jr),1)
                  if(ita.ne.0) then
                     call unsfdcopy(indr(l),ai(ja),1,ri(jr),1)
                  else
                     call dset(indr(l),0.0d0,ri(jr),1)
                  endif
                  jr=jr+indr(l)
                  ja=ja+indr(l)
               else
                  indr(l)=0
               endif
            else
c     all this line is replaced by corresponding b line
c     indr(l)=nb  ????
               if(.not.bscal) then 
                  if(nb.gt.0) then
                     if(jr+nb.gt.nelmx) then
                        ierr=1
                        return
                     endif
                     if(itb.eq.0) then
                        do 10 k1=1,nb
                           if(br(ii,k1).ne.0.0d0) then
                              indr(mr+jr)=k1
                              rr(jr)=br(ii,k1)
                              ri(jr)=0.0d0
                              jr=jr+1
                           endif
 10                     continue
                     else
                        do 11 k1=1,nb
                           if(abs(br(ii,k1))+abs(bi(ii,k1)).ne.0.0d0)
     $                          then
                              indr(mr+jr)=k1
                              rr(jr)=br(ii,k1)
                              ri(jr)=bi(ii,k1)
                              jr=jr+1
                           endif
 11                     continue
                     endif
                  endif
               else
                  if(na.gt.0) then
                     if(jr+na.gt.nelmx) then
                        ierr=1
                        return
                     endif
                     if(itb.eq.0) then
                        if(br(1,1).ne.0.0d0) then
                           do 12 k1=1,na
                              indr(mr+jr)=k1
                              rr(jr)=br(1,1)
                              ri(jr)=0.0d0
                              jr=jr+1
 12                        continue
                        endif
                     else
                        if(abs(br(1,1))+abs(bi(1,1)).ne.0.0d0) then
                           do 13 k1=1,na
                              indr(mr+jr)=k1
                              rr(jr)=br(1,1)
                              ri(jr)=bi(1,1)
                              jr=jr+1
 13                        continue
                        endif
                     endif
                  endif
                  if(l.le.ma) then
                     ja=ja+inda(l)
                  endif
               endif
            endif
 20      continue
         nelr=jr-1
      elseif(allrow) then
c     a(:,j)=b
         bscal=mb*nb.eq.1.and.na*nj.gt.1
         jr=1
         ja=0
         do 35 l=1,ma
            ja1=1
            nal=inda(l)
            indr(l)=0
            do 31 k=1,nr
               jj=findl(k,j,nj)
               if(jj.eq.0) then
c     the  a(l,k) element is not modified insert it in r if non zero
                  if(ja1.le.nal.and.inda(ma+ja+ja1).eq.k) then
c     *              a(l,k) element is non zero
                     rr(jr)=ar(ja+ja1)
                     if(ita.ne.0) then
                        ri(jr)=ai(ja+ja1)
                     else
                        ri(jr)=0.0d0
                     endif
                     indr(l)=indr(l)+1
                     indr(mr+jr)=k
                     jr=jr+1
                     ja1=ja1+1
                  endif
               else
c     the  a(l,k) element is replaced by b(l,jj) element 
                  if(.not.bscal) then
                     if(nb.gt.0) then
                        if(itb.eq.0) then
                           if(br(l,jj).ne.0.0d0) then
                              if(jr+1.gt.nelmx) then
                                 ierr=1
                                 return
                              endif
                              rr(jr)=br(l,jj)
                              ri(jr)=0.0d0
                              indr(l)=indr(l)+1
                              indr(mr+jr)=k
                              jr=jr+1
                           endif
                        else
                           if(abs(br(l,jj))+abs(bi(l,jj)).ne.0.0d0
     $                          ) then
                              if(jr+1.gt.nelmx) then
                                 ierr=1
                                 return
                              endif
                              rr(jr)=br(l,jj)
                              ri(jr)=bi(l,jj)
                              indr(l)=indr(l)+1
                              indr(mr+jr)=k
                              jr=jr+1
                           endif
                        endif
                     endif
                  else
                     if(itb.eq.0) then
                        if(br(1,1).ne.0.0d0) then
                           if(jr+1.gt.nelmx) then
                              ierr=1
                              return
                           endif
                           rr(jr)=br(1,1)
                           ri(jr)=0.0d0
                           indr(l)=indr(l)+1
                           indr(mr+jr)=k
                           jr=jr+1
                        endif
                     else
                        if(abs(br(1,1))+abs(bi(1,1)).ne.0.0d0)
     $                       then
                           if(jr+1.gt.nelmx) then
                              ierr=1
                              return
                           endif
                           rr(jr)=br(1,1)
                           ri(jr)=bi(1,1)
                           indr(l)=indr(l)+1
                           indr(mr+jr)=k
                           jr=jr+1
                        endif
                     endif
                  endif
               endif
               if(ja1.le.nal.and.inda(ma+ja+ja1).eq.k) ja1=ja1+1
 31         continue
            ja=ja+nal
 35      continue
         nelr=jr-1
         return
      else
c     a(i,j)=b
         bscal=mb*nb.eq.1.and.ni*nj.gt.1
         jr=1
         ja=0
         do 45 l=1,mr
            ja1=1
            if(l.le.ma) then 
               nal=inda(l)
            else
               nal=0
            endif
            indr(l)=0
            ii=findl(l,i,ni)
            if(ii.eq.0) then
c     *     the a(l,:) is not modified
               if(l.le.ma) then
                  indr(l)=inda(l)
                  call icopy(indr(l),inda(ma+ja+ja1),1,indr(mr+jr)
     $                 ,1)
                  call unsfdcopy(indr(l),ar(ja+ja1),1,rr(jr),1)
                  if(ita.ne.0) then
                     call unsfdcopy(indr(l),ai(ja+ja1),1,ri(jr),1)
                  else
                     call dset(indr(l),0.0d0,ri(jr),1)
                  endif
                  jr=jr+indr(l)
                  ja1=ja1+indr(l)
               else
                  indr(l)=0
               endif
            else
               do 42 k=1,nr
                  jj=findl(k,j,nj)
                  if(jj.eq.0) then
c     *           insert a(l,k) element  in r if non zero
                     if(ja1.le.nal.and.inda(ma+ja+ja1).eq.k) then
c     *              a(l,k) element is non zero
                        rr(jr)=ar(ja+ja1)
                        if(ita.ne.0) then
                           ri(jr)=ai(ja+ja1)
                        else
                           ri(jr)=0.0d0
                        endif
                        indr(l)=indr(l)+1
                        indr(mr+jr)=k
                        jr=jr+1
                        ja1=ja1+1
                     endif
                  else
c     *           replace a(l,k) element  by b(ii,jj) element if non
c     zero
                     if(.not.bscal) then
                        if(nb.gt.0) then
                           if(itb.eq.0) then
                              if(br(ii,jj).ne.0.0d0) then
                                 if(jr+1.gt.nelmx) then
                                    ierr=1
                                    return
                                 endif
                                 rr(jr)=br(ii,jj)
                                 ri(jr)=0.0d0
                                 indr(l)=indr(l)+1
                                 indr(mr+jr)=k
                                 jr=jr+1
                              endif
                           else
                              t=abs(br(ii,jj))+abs(bi(ii,jj))
                              if(t.ne.0.0d0) then
                                 if(jr+1.gt.nelmx) then
                                    ierr=1
                                    return
                                 endif
                                 rr(jr)=br(ii,jj)
                                 ri(jr)=bi(ii,jj)
                                 indr(l)=indr(l)+1
                                 indr(mr+jr)=k
                                 jr=jr+1
                              endif
                           endif
                        endif
                     else
                        if(itb.eq.0) then
                           if(br(1,1).ne.0.0d0) then
                              if(jr+1.gt.nelmx) then
                                 ierr=1
                                 return
                              endif
                              rr(jr)=br(1,1)
                              ri(jr)=0.0d0
                              indr(l)=indr(l)+1
                              indr(mr+jr)=k
                              jr=jr+1
                           endif
                        else
                           t=abs(br(1,1))+abs(bi(1,1))
                           if(t.ne.0.0d0) then
                              if(jr+1.gt.nelmx) then
                                 ierr=1
                                 return
                              endif
                              rr(jr)=br(1,1)
                              ri(jr)=bi(1,1)
                              indr(l)=indr(l)+1
                              indr(mr+jr)=k
                              jr=jr+1
                           endif
                        endif
                     endif
                     if(ja1.le.nal.and.inda(ma+ja+ja1).eq.k) ja1
     $                    =ja1+1
                  endif
 42            continue
            endif
            ja=ja+nal
 45      continue
         nelr=jr-1
      endif
      end