File: sci_rot90.sci

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 (61 lines) | stat: -rw-r--r-- 1,450 bytes parent folder | download | duplicates (2)
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
function [stk,txt,top]=sci_rot90()
// Copyright INRIA
txt=[]
if rhs==1 then
  if isname(stk(top)(1)) then
    stk=list(stk(top)(1)+'(:,$:-1:1).''','0',stk(top)(3),stk(top)(4),'1')
  else
    v=gettempvar()
    txt=v+' = '+stk(top)(1)
    stk=list(v+'(:,$:-1:1).''','0',stk(top)(3),stk(top)(4),'1')
  end
else
  if isname(stk(top-1)(1)) then
    v=stk(top-1)(1)
  else
    v=gettempvar()
    txt=v+' = '+stk(top-1)(1)
  end
  
  k=stk(top)(1)
  if isnum(k) then
    k=evstr(k)
    k = k-fix(k./4).*4;
    if k<0 then k = k+4;end
    if k==1 then
      stk=list(v+'(:,$:-1:1).''','0',stk(top)(3),stk(top)(4),'1')
    elseif k==2 then
      stk=list(v+'($:-1:1,$:-1:1)','0',stk(top)(3),stk(top)(4),'1')
    elseif k==3 then
      stk=list(v+'($:-1:1,:).''','0',stk(top)(3),stk(top)(4),'1')
    else
      stk=list(stk(top-1)(1),'0',stk(top)(3),stk(top)(4),'1')
      txt=[]
    end
    top=top-1
    return
  elseif isname(stk(top)(1)) then
    k=stk(top)(1)
  else
    k=gettempvar(1)
    txt=k+' = '+stk(top)(1)
  end
  B=gettempvar(2)
  txt=[txt;
      k+' = '+k+'-fix('+k+'./4).*4;'
      'if '+k+'<0 then '+k+' = '+k+'+4;end'
      'if '+k+'==1 then'
      '  '+B+' = '+v+'(:,$:-1:1).'''
      'elseif '+k+'==2 then'
      '  '+B+' = '+v+'($:-1:1,$:-1:1)'
      'elseif '+k+'==3 then'
      '  '+B+' = '+v+'($:-1:1,:).'''
      'else'
      '  '+B+' = '+v
      'end']

  stk=list(B,'0',stk(top-1)(3),stk(top-1)(4),stk(top-1)(5))
  top=top-1
end