File: lij2sp.f

package info (click to toggle)
scilab 2.2-4
  • links: PTS
  • area: non-free
  • in suites: hamm
  • size: 31,472 kB
  • ctags: 21,963
  • sloc: fortran: 110,983; ansic: 89,717; makefile: 3,016; sh: 1,892; csh: 150; cpp: 101
file content (53 lines) | stat: -rw-r--r-- 1,221 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
      subroutine lij2sp(m,n,nel,ij,v,ind,nind,iw,ierr)
      integer v(nel)
      integer ij(nel,2),ind(nind),iw(nel)
c
      ierr=0
      if(nel.eq.0) then
         call iset(m,0,ind,1)
         return
      endif
      call isort1(ij(1,1),nel,iw,1)
      call iperm(ij(1,2),nel,iw)
      call iperm(v,nel,iw)
c     mm=max(i),nn=max(j)
      mm=ij(nel,1)
      nm=0
      if(nel.gt.0) then
         do 10 k=1,nel
            nm=max(nm,ij(k,2))
 10      continue
      endif
      if(n.gt.0) then
         if(n.lt.nm.or.m.lt.mm) then
            ierr=1
            return
         endif
      else
         n=nm
         m=mm  
      endif
      if(nind.lt.m+nel) then
         ierr=2
         return
      endif
c     calcul du nombre d'element non nul par lignes et tri par colonne    
      i0=1
      do 20 lp=1,m
         i=i0-1
 21      i=i+1
         if(i.le.nel) then
            if(ij(i,1).eq.lp) goto 21
         endif
         nl=i-i0
c     nl est le nombre d'element dans la ligne
         ind(lp)=nl
         if(nl.gt.1) then
            call isort1(ij(i0,2),nl,iw,1)
            call iperm(v(i0),nl,iw)
         endif
         i0=i
 20   continue
      call icopy(nel,ij(1,2),1,ind(m+1),1)
      end