~ubuntu-branches/ubuntu/karmic/scilab/karmic

« back to all changes in this revision

Viewing changes to macros/m2sci/%e2sci.sci

  • Committer: Bazaar Package Importer
  • Author(s): Torsten Werner
  • Date: 2002-03-21 16:57:43 UTC
  • Revision ID: james.westby@ubuntu.com-20020321165743-e9mv12c1tb1plztg
Tags: upstream-2.6
ImportĀ upstreamĀ versionĀ 2.6

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
function [stk,txt,top]=%e2sci()
 
2
// genere le code relatif a l'extraction d'une sous matrice
 
3
//!
 
4
// Copyright INRIA
 
5
txt=[]
 
6
rhs=maxi(0,abs(evstr(op(3)))-1)
 
7
sn=stk(top);top=top-1
 
8
s2=stk(top)
 
9
if rhs==1 then
 
10
  // jpc 6 oct 16h pause
 
11
  if type(s2(1))==1 then // recursive extraction
 
12
    n=s2(1)(1)
 
13
    m=s2(1)(2)
 
14
    ex=sn(1)
 
15
    if m>1 then n=n-1,end
 
16
    for k=1:n
 
17
      ik=s2(k+1)
 
18
      //if ik(5)=='10' then
 
19
      //  ex=ex+'.'+part(ik(1),2:length(ik(1))-1)
 
20
      //else
 
21
        ex=ex+'('+ik(1)+')'
 
22
      //end
 
23
    end
 
24
    if m>1 then
 
25
      args=[]
 
26
      for k=1:m,args=[args s2(n+1+k)(1)],end
 
27
      ex=ex+'('+makeargs(args)+')'
 
28
      stk=list(ex,'0','?','1','?')
 
29
    else
 
30
      stk=list(ex,'0','?','1','?')
 
31
    end
 
32
  elseif sn(5)=='10' then // extraction pour les chaines
 
33
    stk=list('part('+sn(1)+','+s2(1)+')','0','1','1',sn(5))
 
34
  else
 
35
    [mn,nn]=checkdims(sn);
 
36
    [m2,n2]=checkdims(s2);
 
37
    if s2(1)==':' then
 
38
      if mn<>-1&nn<>-1 then
 
39
        stk=list(sn(1)+'('+s2(1)+')','0',string(mn*nn),'1',sn(5))
 
40
      else
 
41
        stk=list(sn(1)+'('+s2(1)+')','0','?','1',sn(5))
 
42
      end
 
43
    elseif mn==1 then
 
44
      stk=list(sn(1)+'('+s2(1)+')','0','1','?',sn(5))
 
45
    elseif nn==1 then
 
46
      stk=list(sn(1)+'('+s2(1)+')','0','?','1',sn(5))
 
47
    elseif n2==1 then
 
48
      stk=list(sn(1)+'('+s2(1)+')','0','?','1',sn(5))
 
49
    elseif m2==1 then
 
50
      stk=list(sn(1)+'('+s2(1)+')','0','1','?',sn(5))
 
51
    elseif mn<>-1&nn<>-1 then
 
52
      stk=list(sn(1)+'('+s2(1)+').''','0','?','1',sn(5))
 
53
    else // at leat one dimension unknown
 
54
      v='mtlb_e'+rhsargs([sn(1),s2(1)])
 
55
      set_infos([v+' may be replaced by '+sn(1)+'('+s2(1)+')'
 
56
                '   '+sn(1)+'('+s2(1)+') if '+sn(1)+' is a vector,'
 
57
                '   '+sn(1)+'('+s2(1)+').'' if '+sn(1)+' is a matrix.'],1)
 
58
      stk=list(v,'0','?','?',sn(5))
 
59
    end
 
60
  end
 
61
else
 
62
  s1=stk(top-1);top=top-1
 
63
  if sn(5)=='10' then // extraction pour les chaines 
 
64
    if s1(3)=='1'&s1(4)=='1' then
 
65
      stk=list('part('+sn(1)+'('+s1(1)+'),'+s2(1)+')','0','1','1',sn(5))
 
66
    elseif s1(3)=='1' then
 
67
      stk=list('part('+sn(1)+'('+s1(1)+'),'+s2(1)+')','0',s1(4),'1',sn(5))
 
68
    elseif s1(4)=='1' then
 
69
      stk=list('part('+sn(1)+'('+s1(1)+'),'+s2(1)+')','0',s1(3),'1',sn(5))
 
70
    else
 
71
      stk=list('part('+sn(1)+'('+s1(1)+'),'+s2(1)+')','0','?','1',sn(5))
 
72
    end
 
73
  elseif s1(3)=='1'&s1(4)=='1' then
 
74
    stk=list(sn(1)+rhsargs([s1(1),s2(1)]),'0','1','?',sn(5))
 
75
  elseif  s2(3)=='1'&s2(4)=='1' then
 
76
    stk=list(sn(1)+rhsargs([s1(1),s2(1)]),'0','?','1',sn(5))
 
77
  else
 
78
    stk=list(sn(1)+rhsargs([s1(1),s2(1)]),'0','?','?',sn(5))
 
79
  end
 
80
end