File: f_mini.sci

package info (click to toggle)
scilab 2.6-4
  • links: PTS
  • area: non-free
  • in suites: woody
  • size: 54,632 kB
  • ctags: 40,267
  • sloc: ansic: 267,851; fortran: 166,549; sh: 10,005; makefile: 4,119; tcl: 1,070; cpp: 233; csh: 143; asm: 135; perl: 130; java: 39
file content (51 lines) | stat: -rw-r--r-- 1,368 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
function [stk,nwrk,txt,top]=f_mini(nwrk)
//!purpose
//  Scilab mini function translation
//!
txt=[]
select rhs
case 1 then
  s2=stk(top)
  if lhs==1 then
    if s2(3)=='0' then fun='ivmin',else fun='dvmin',end
    nwrk=dclfun(nwrk,fun,s2(3))
    out=callfun([fun,mulf(s2(4),s2(5)),s2(1),'1'],s2(3))
    stk=list(out,'0',s2(3),'1','1')
  else
    [out,nwrk,t1]=outname(nwrk,[s2(3);'0'],['1';'1'],['1';'1'])
    w=getentry1(s2(1),'loop')
    txt=[t1;
	' '+out(2)+'='+getentry1(s2(1),'1')
	' do loop=2,'+mulf(s2(4),s2(5))
	indentfor(genif(w+'.lt.'+out(2),..
	    [' '+out(2)+'='+w;
	     ' '+out(1)+'=loop']))
       ' enddo']
    stk=list(list(out(1),'-1','1','1','1'),list(out(2),'-1','0','1','1'))
  end
case 2 then
  s2=stk(top);s1=stk(top-1);top=top-1
  if lhs==1 then
    if s2(4)=='1'&s2(5)=='1'&s1(4)=='1'&s1(5)=='1'then
      stk=list('min('+s1(1)+','+s2(1)+')','0',s2(3),'1','1')
    else
      warning('min with 2 matrix args not translated')
    end
  else
    warning('min with 2 lhs arguments not translated')
  end
else
  warning('min with more than 2 args not translated')
end

function var=getentry1(var,i)
if part(var,1:5)=='work(' then
  pti=part(var,6:length(var)-1)
  
  var='work('+addf(pti,addf(i,'-1'))+')'
elseif  part(var,1:6)=='iwork(' then
  pti=part(var,7:length(var)-1)
  var='iwork('+addf(pti,addf(i,'-1'))+')'
else
  var=var+'('+i+')'
end