File: indxg.f

package info (click to toggle)
scilab 2.4-1
  • links: PTS
  • area: non-free
  • in suites: potato, slink
  • size: 55,196 kB
  • ctags: 38,019
  • sloc: ansic: 231,970; fortran: 148,976; tcl: 7,099; makefile: 4,585; sh: 2,978; csh: 154; cpp: 101; asm: 39; sed: 5
file content (248 lines) | stat: -rw-r--r-- 6,552 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
      subroutine indxg(il,siz,ilr,mi,mx,lw,iopt1)
c!Purpose
c     Converts a scilab index variable to a vector of indices
c!Calling sequence
c     subroutine indxg(il,siz,ilr,mi,lw,iopt)
c     il    : beginning of a  a  scilab variable structure. 
c     siz   : integer, matrix size, used for implicits index descriptions
c     ilr   : adress of first elment of resulting vector of indices in
c            istk
c     mi    : size of resulting vector of indices 
c     mx    : maximum value of resulting vector of indices
c     lw    : pointer to free space in stk (modified by execution)
c     iopt1 : flag with decimal form n+10*i
c            if n==0 null indices are accepted
c            else null indices are rejected
c            if i==0 
c               implicit indices ":" gives a vector istk(ilr)=1:siz, mi=siz,mx=siz
c            else 
c               implicit indice ":" gives mi=-1,mx=siz
c!

c     Copyright INRIA
      include '../stack.h'
      integer siz,iopt1,iopt
      double precision e1,v(3)
      integer iadr,sadr
c
      iadr(l)=l+l-1
      sadr(l)=(l/2)+1

c
c     
      impl=iopt1/10
      iopt=iopt1-10*impl
c
      if(istk(il).lt.0) il=istk(il+1)

      if(istk(il).eq.1) then
c     Index is a vector of scalars
         m=istk(il+1)
         n=istk(il+2)
         if(istk(il+3).ne.0) then 
            call error(21)
            return
         endif
         if(m.ge.1) then
c     .     general case
            l=sadr(il+4)
            ilr=iadr(lw)
            lw=sadr(ilr+m*n)
            err=lw-lstk(bot)
            if(err.gt.0) then
               call error(17)
               return
            endif
            call entier(m*n,stk(l),istk(ilr))
            mi=m*n
            mx=0
            do 05 i=0,m*n-1
               if(iopt.eq.1.and.istk(ilr+i).le.0) then
                  call error(21)
                  return
               else
                  mx=max(mx,istk(ilr+i))
               endif
 05         continue
         elseif(m.eq.0) then
c     .     index is []
            ilr=il
            mi=0
            mx=0
         elseif(m.eq.-1) then
c     .     index is : 
            ilr=iadr(lw)
            if(impl.eq.0) then
               if(siz.gt.0) then
                  lw=sadr(ilr+siz)
                  err=lw-lstk(bot)
                  if(err.gt.0) then
                     call error(17)
                     return
                  endif
                  do 10 i=1,siz
                     istk(ilr-1+i)=i
 10               continue
               endif
               mi=siz
            else
               mi=-1
            endif
            mx=siz
         endif
      elseif (istk(il).eq.2) then
c     .  Index is a vector of polynomial
         m=istk(il+1)
         n=istk(il+2)
         if(istk(il+3).ne.0) then 
            call error(21)
            return
         endif
         mi=m*n
         l=sadr(il+9+mi)
         lr=lw
         ilr=iadr(lr)
         lw=lr+mi
         err=lw-lstk(bot)
         if(err.gt.0) then
            call error(17)
            return
         endif
c     .  evaluate it for siz
         e1=siz
         call ddmpev(stk(l),istk(il+8),1,e1,stk(lr),1,1,mi)
         call entier(mi,stk(lr),istk(ilr))
         lw=sadr(ilr+mi)
         mx=0
         do 15 i=0,mi-1
            if(istk(ilr+i).le.0) then
               call error(21)
               return
            else
               mx=max(mx,istk(ilr+i))
            endif
 15      continue
      elseif (istk(il).eq.129) then
c     .  Index is an implicit polynomial vector (beg:step:end)
         e1=siz
         l=sadr(il+12)
         
         call ddmpev(stk(l),istk(il+8),1,e1,v,1,1,3)
         ideb=v(1)
         ipas=v(2)
         ifin=v(3)
         if(ipas.eq.0.or.(ifin-ideb)*ipas.lt.0) then
            mi=0
            mx=0
         else
            if(ipas.lt.0.and.ifin.le.0.or.ipas.gt.0.and.ideb.le.0) then
               call error(21)
               return
            endif
            mi=int((abs(ifin-ideb)+1)/abs(ipas))

            ilr=iadr(lw)
            lw=sadr(ilr+mi+1)
            err=lw-lstk(bot)
            if(err.gt.0) then
               call error(17)
               return
            endif
            k=0
            do 20 i=ideb,ifin,ipas
               istk(ilr+k)=i
               k=k+1
 20         continue
            mi=k
            if(ipas.gt.0) then
               mx=istk(ilr-1+mi)
            else
               mx=istk(ilr)
            endif
         endif
      elseif (istk(il).eq.4) then
c     .  index is a boolean vector
         m=istk(il+1)
         n=istk(il+2)
c         if(m*n.ne.siz) then 
c            call error(21)
c            return
c         endif
         ilr=iadr(lw)
         lw=sadr(ilr+m*n)
         err=lw-lstk(bot)
         if(err.gt.0) then
            call error(17)
            return
         endif
         mi=0
         do 30 i=1,m*n
            if(istk(il+2+i).eq.1) then
               istk(ilr+mi)=i
               mi=mi+1
            endif
 30      continue
         if(mi.eq.0) then
            mx=0
         else
            mx=istk(ilr-1+mi)
         endif
         lw=sadr(ilr+mi)
      else
         call error(21)
         return
      endif
      return
      end


      subroutine indxgc(il,siz,ilr,mi,mx,lw)
c!Purpose
c     Converts a scilab index variable to the complementary vector of indices
c!Calling sequence
c     subroutine indxg(il,siz,ilr,mi,lw)
c     il   : beginning of a  a  scilab variable structure. 
c     siz  : integer, matrix size, used for implicits index descriptions
c     ilr  : adress of first elment of resulting vector of indices in
c            istk
c     mi   : size of resulting vector of indices 
c     mx   : maximum value of resulting vector of indices
c     lw   : pointer to free space in stk (modified by execution)
c!

      include '../stack.h'
      integer siz
      logical test
      integer iadr,sadr
c
      iadr(l)=l+l-1
      sadr(l)=(l/2)+1

      call indxg(il,siz,ilr,mi,mx,lw,1)
      if(err.gt.0) return
c     computes complement
      ilc=iadr(lw)
      lw=sadr(ilc+siz)
      err=lw-lstk(bot)
      if(err.gt.0) then
         call error(17)
         return
      endif
      k=0
      do 20 i=1,siz
         test=.true.
         do 10 j=1,mi
            test=test.and.istk(ilr-1+j).ne.i
 10      continue
         if(test) then
            istk(ilc+k)=i
            k=k+1
         endif
 20   continue
      mx=istk(ilc-1+k)
      mi=k
      ilr=ilc
c      call icopy(mi,istk(ilc),1,istk(ilr),1)
      lw=sadr(ilr+mi)
      return
      end