File: sci_eig.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 (53 lines) | stat: -rw-r--r-- 1,624 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
function [stk,txt,top]=sci_eig()
// Copyright INRIA
txt=[]
if rhs==1 then
  if lhs==1 then
    stk=list('spec'+'('+stk(top)(1)+')','0',stk(top)(3),'1','?')
  else
    //eig is called with to lhs arguments. Get their names
    [v,d]=lhsvarsnames()
    txt=lhsargs([d,v])+'=bdiag('+stk(top)(1)+'+0*%i,1/%eps)'
    sz=stk(top)(3)
    //eig output variable are already defined in txt, set expr_type to '-2' 
    //for both
    stk=list(list('?','-2',sz,sz,'?'),list('?','-2',sz,sz,'?'))
  end
else // more than one input argument (option or generalized eigen values?)
  if stk(top)(5)=='10' then  //option
    write(logfile,'Eig : '''+stk(top)(1)+''' option not translated')
    top=top-1
    if lhs==1 then
      stk=list('spec'+'('+stk(top)(1)+')','0',stk(top)(3),'1','?')
    else
      [v,d]=lhsvarsnames()
      txt=lhsargs([d,v])+'=bdiag('+stk(top)(1)+'+0*%i,1/%eps)'
      sz=stk(top)(3)
      stk=list(list('?','-2',sz,sz,'?'),list('?','-2',sz,sz,'?'))
    end
    return
  end
  if stk(top)(5)<>'1' then
    txt='Eig with 2 rhs args: generalized eigen assumed. Check '
    write(logfile,'Warning: '+txt)
    txt='//'+txt
  end  
  if lhs==1 then
    al=gettempvar()
    be=gettempvar()
    V=lhsvarsnames()
    txt=[txt;
        lhsargs([al,be,V])+' = gspec'+rhsargs([stk(top-1)(1),stk(top)(1)])+';']
    stk=list(' ','-2','0','0','0')
  else
    al=gettempvar(1)
    be=gettempvar(2)
    [V,D]=lhsvarsnames()
    txt=[txt;
        lhsargs([al,be,V])+' = gspec'+rhsargs([stk(top-1)(1),stk(top)(1)])+';'
        D+' = '+al+'./'+be+';']
    stk=list(list(' ','-2','0','0','0'),list(' ','-2','0','0','0'))
  end
end