File: sci_sparse.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 (47 lines) | stat: -rw-r--r-- 1,426 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
function [stk,txt,top]=sci_sparse()
// Copyright INRIA
txt=[]
V1=gettempvar(1)
V1=gettempvar(2)
if rhs==6 then rhs=5;top=top-1,end
if rhs==1 then
  stk=list('sparse('+stk(top)(1)+')','0',stk(top)(3),stk(top)(4),'5')
elseif rhs==2 then
  stk=list('sparse([],[],['+stk(top-1)(1)+','+stk(top)(1)+'])','0',stk(top-1)(1),stk(top)(1),'5')
  top=top-1 
elseif rhs==3 then    
  s1=stk(top-2)
  s2=stk(top-1)
  s3=stk(top)
  if s1(4)=='1'&s2(4)=='1' then
    stk=list('sparse(['+s1(1)+','+s2(1)+'],'+s3(1)+')','0','?','?','5')
  elseif or(s1(1)==vnms(:,1))&or(s2(1)==vnms(:,1)) then
    stk=list('sparse(['+s1(1)+'(:),'+s2(1)+'(:)],'+s3(1)+')','0','?','?','5')
  else
        txt=[V1+' = '+s1(1)+';'+V1+'='+V1+'(:)';
             V2+' = '+s2(1)+';'+V2+'='+V2+'(:)'];
  
    stk=list('sparse(['+V1+','+V2+'],'+s3(1)+')','0','?','?','5')
  end
  
  top=top-2
elseif rhs==5 then    
  s1=stk(top-4)
  s2=stk(top-3)
  s3=stk(top-2)
  s4=stk(top-1)
  s5=stk(top)
  if s1(4)=='1'&s2(4)=='1' then
    stk=list('sparse(['+s1(1)+','+s2(1)+'],'+s3(1)+')','0','?','?','5')
  elseif or(s1(1)==vnms(:,1))&or(s2(1)==vnms(:,1)) then
    stk=list('sparse(['+s1(1)+'(:),'+s2(1)+'(:)],'+s3(1)+',['+s4(1)+','+s5(1)+'])','0','?','?','5')  
  else
    txt=[V1+' = '+s1(1)+';'+V1+'='+V1+'(:)';
         V2+' = '+s2(1)+';'+V2+'='+V2+'(:)'];
    stk=list('sparse(['+V1+','+V2+'],'+s3(1)+',['+s4(1)+','+s5(1)+'])','0','?','?','5')
  end
  
  top=top-4 
end