~ubuntu-branches/ubuntu/hoary/scilab/hoary

« back to all changes in this revision

Viewing changes to routines/sparse/dspt.f

  • Committer: Bazaar Package Importer
  • Author(s): Torsten Werner
  • Date: 2002-03-21 16:57:43 UTC
  • Revision ID: james.westby@ubuntu.com-20020321165743-e9mv12c1tb1plztg
Tags: upstream-2.6
ImportĀ upstreamĀ versionĀ 2.6

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
      subroutine dspt(r,s,a,nela,inda,ia, at,iat,indat)  
 
2
c transpose a sparse matrix using a distribution count sort.
 
3
c*** input
 
4
c r,s          number of rows,columns in a.
 
5
c a            a one-dimensional array containing the non-zero
 
6
c                elements of matrix a,arranged row-wise,but in
 
7
c                general not ordered within rows.
 
8
c  ma         as in msmgus.
 
9
c  ia         ia(i) is address in a of first element of row i of a.
 
10
c                ia(number of rows + 1) is number of elements in a,+1.
 
11
c*** output
 
12
c at           a one-dimensional array containing non-zero elements
 
13
c                of matrix a transposed,arranged row-wise,and in
 
14
c                order within rows.
 
15
c  mat        contains control information and column indices for at,
 
16
c               in same format as ma...see msmgus.
 
17
c*** working storage.
 
18
c  iat        iat(i) is address in at of first element in row i of at.
 
19
c               iat(s+1) contains number of elements in at,plus 1.
 
20
c     Copyright INRIA
 
21
      double precision a(*), at(nela)
 
22
      integer inda(*), ia(*), indat(*), iat(*)
 
23
      integer r, s
 
24
c
 
25
c determine column counts of matrix a(i.e row counts of at)
 
26
c  in array iat.
 
27
c
 
28
      do 10 i=1,s+1
 
29
        iat(i) = 0
 
30
   10 continue
 
31
 
 
32
c     computes number of elements for each column
 
33
      do 20 i=1,nela
 
34
        k = inda(i+r)
 
35
        iat(k) = iat(k) + 1
 
36
   20 continue
 
37
c
 
38
c calculate row pointers of at from column counts obtained above.
 
39
c pointer for row i stored in location i+1.
 
40
c
 
41
      itemp1 = iat(1)
 
42
      itemp2 = iat(2)
 
43
      iat(2) = 1
 
44
      if (s.le.1) go to 40
 
45
      do 30 i=2,s
 
46
        itemp3 = iat(i+1)
 
47
        iat(i+1) = iat(i) + itemp1
 
48
        itemp1 = itemp2
 
49
        itemp2 = itemp3
 
50
   30 continue
 
51
c
 
52
c calculate column indices(in array indat) and numerical values (in array
 
53
c  at) of matrix a-transposed using the list pointers iat(i+1) which
 
54
c  always point to the next element to be entered in row i of at.
 
55
   40 do 60 i=1,r
 
56
        j1 = ia(i)
 
57
        j2 = ia(i+1) - 1
 
58
        if (j1.gt.j2) go to 60
 
59
        do 50 jp=j1,j2
 
60
          j = inda(jp + r)
 
61
          jpt = iat(j+1)
 
62
          indat(jpt + s) = i
 
63
          at(jpt) = a(jp)
 
64
          iat(j+1) = jpt + 1
 
65
   50   continue
 
66
   60 continue
 
67
c
 
68
c now all row pointers iat for at have correct values except position 1.
 
69
c  fix it.
 
70
      iat(1) = 1
 
71
c  extract needed control information in indat.
 
72
      do 70 i=1,s
 
73
        indat(i) = iat(i+1) - iat(i)
 
74
   70 continue
 
75
      return
 
76
      end