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
|
subroutine hmcreate(lw,nz,sz,typv,iflag,retval)
c lw : number of the variable
c nz : number of dimensions
c sz : dimensions
c typv : Matlab class
c iflag = 0 or 1 (real or complex)
include '../stack.h'
integer nz,sz(nz),szv,retval
integer typv
integer hmsz
integer int8,uint8,int16,uint16,int32,uint32
parameter(int8=8,uint8=9,int16=10,uint16=11,int32=12,uint32=13)
c
integer iadr,sadr
c
iadr(l)=l+l-1
sadr(l)=(l/2)+1
c
retval=0
l0=lstk(lw)
if (lw.gt.intersiz) then
buf = 'createvar :too many arguments in the stack' //
$ ' edit stack.h and enlarge intersiz'
call error(998)
goto 999
endif
iii=hmsz(nz,sz,typv,iflag)
err=l0+iii-lstk(bot)
if(err.gt.0) then
call error(17)
goto 999
endif
lstk(lw+1)=l0+iii
retval=1
ntypes(lw-top+rhs) = 36
iwhere(lw-top+rhs)= lstk(lw)
c lad(lw-top+rhs) = should point to numeric data
c create the mlist header
il=iadr(l0)
istk(il)=17
istk(il+1)=3
istk(il+2)=1
c
c set mlist type entry
call hmtyp(n1,'size')
istk(il+3)=istk(il+2)+n1
l=sadr(il+6)
call hmtyp(istk(iadr(l)),'set')
l=l+n1
c set the size field
ilsz=iadr(l)
istk(ilsz)=8
istk(ilsz+1)=1
istk(ilsz+2)=nz
istk(ilsz+3)=4
l=sadr(ilsz+4)
c call int2db(nz,sz,1,stk(l),1) FD
call icopy(nz,sz,1,istk(ilsz+4),1)
l=l+nz
istk(il+4)=istk(il+3)+nz+2
c
c set the value field
c 1 - compute the number of elements
nv=1
do 10 i=1,nz
nv=nv*sz(i)
10 continue
ilv=iadr(l)
c 2 - set the value header
if(typv.eq.6) then
c . double
istk(ilv)=1
istk(ilv+1)=nv
istk(ilv+2)=1
istk(ilv+3)=iflag
l=sadr(ilv+4)
call dset(nv*(iflag+1),0.0d0,stk(l),1)
szv=nv*(iflag+1)+2
istk(il+5)=istk(il+4)+szv
elseif(typv.eq.4) then
c . string
istk(ilv)=10
istk(ilv+1)=1
istk(ilv+2)=1
istk(ilv+3)=0
istk(ilv+4)=1
istk(ilv+5)=1+nv
l=ilv+6
call iset(nv,40,istk(l),1)
szv=sadr(l+nv)-sadr(l)
istk(il+5)=istk(il+4)+szv
else
if(typv.eq.int8) then
it=1
elseif(typv.eq.uint8) then
it=11
elseif(typv.eq.int16) then
it=2
elseif(typv.eq.uint16) then
it=12
elseif(typv.eq.int32) then
it=4
elseif(typv.eq.uint32) then
it=14
endif
istk(ilv)=8
istk(ilv+1)=nv
istk(ilv+2)=1
istk(ilv+3)=it
l=ilv+4
call genset(it,nv,0,istk(l),1)
szv=sadr(memused(it,nv)+4)
istk(il+5)=istk(il+4)+szv
endif
999 continue
return
end
subroutine hmtyp(ivt,job)
c definition of first field of tlist's type: hm
c tlist fields are:
c dims
c entries
c
integer ivt(*),l
character*(*) job
integer iadr,sadr
c
iadr(l)=l+l-1
sadr(l)=(l/2)+1
c
if(job.eq.'size') then
c size of the data structure
ivt(1)=11
elseif(job.eq.'nchar') then
c number of chars defining the type field
ivt(1)=13
elseif(job.eq.'nfield') then
c number of fields in the tlist
ivt(1)=3
elseif(job.eq.'ptr') then
c pointers on individual strings
ivt(1)=1
ivt(2)=3
ivt(3)=7
ivt(4)=14
else
c Character string Variable header
ivt(1)=10
ivt(2)=1
ivt(3)=3
ivt(4)=0
ivt(5)=1
l=8
c entry (1,1) = "hm"
ivt(l+1)=17
ivt(l+2)=22
ivt(6)=ivt(5)+2
l=l+2
c entry (2,1) = "dims"
ivt(l+1)=13
ivt(l+2)=18
ivt(l+3)=22
ivt(l+4)=28
ivt(7)=ivt(6)+4
l=l+4
c entry (3,1) = "entries"
ivt(l+1)=14
ivt(l+2)=23
ivt(l+3)=29
ivt(l+4)=27
ivt(l+5)=18
ivt(l+6)=14
ivt(l+7)=28
ivt(8)=ivt(7)+7
l=l+7
endif
return
end
integer function hmsz(nz,sz,typv,iflag)
c sz = dimensions
include '../stack.h'
integer nz,sz(nz)
integer nv
integer typv
integer iadr,sadr
c
iadr(l)=l+l-1
sadr(l)=(l/2)+1
c
c mlist header size
il=1
l=sadr(il+6)
c first field size
call hmtyp(n1,'size')
l=l+n1
c set the size field
ilsz=iadr(l)
l=sadr(ilsz+4)+nz
c
c set the value field size
nv=1
do 10 i=1,nz
nv=nv*sz(i)
10 continue
ilv=iadr(l)
if(typv.eq.6) then
c . double
l=sadr(ilv+4)+nv*(iflag+1)
elseif(typv.eq.4) then
c . string
l=sadr(ilv+6+nv)
else
if(typv.eq.8) then
c if(typv.eq.'int8') then
it=1
elseif(typv.eq.9) then
c elseif(typv.eq.'uint8') then
it=11
elseif(typv.eq.10) then
c elseif(typv.eq.'int16') then
it=2
elseif(typv.eq.11) then
c elseif(typv.eq.'uint16') then
it=12
elseif(typv.eq.12) then
c elseif(typv.eq.'int32') then
it=4
elseif(typv.eq.13) then
c elseif(typv.eq.'uint32') then
it=14
endif
l=sadr(ilv+4)+memused(it,nv)
endif
hmsz=l-1
return
end
|