a871a1f50fdce4cf4bfc84a4f34b04db209bf126
[scilab.git] / scilab / modules / overloading / macros / %s_i_lss.sci
1 // Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
2 // Copyright (C) INRIA - Serge Steer
3 //
4 // Copyright (C) 2012 - 2016 - Scilab Enterprises
5 //
6 // This file is hereby licensed under the terms of the GNU GPL v2.0,
7 // pursuant to article 5.3.4 of the CeCILL v.2.1.
8 // This file was originally licensed under the terms of the CeCILL v2.1,
9 // and continues to be available under such terms.
10 // For more information, see the COPYING file which you should have received
11 // along with this program.
12
13 function s2=%s_i_lss(i,j,s1,s2)
14     // s2(i,j)=s1
15     //!
16     if type(i)==10 then  // sl('A'),sl('B'),sl('C'),sl('D'),sl('X'),sl('dt')
17         [lhs,rhs]=argn(0)
18         if rhs<>3 then  error(21),end
19         nams=["A","B","C","D","X","dt"]
20         kf=find(convstr(i,"u")==nams)
21         if kf==[] then error(21),end
22         s2=s1;kf=kf+1
23         if size(s2(kf))<>size(j) then
24             if kf<>7|prod(size(j))>1 then
25                 warning("inserted element "+i+" has inconsistent dimension")
26             end
27         end
28         s2(kf)=j
29         return
30     end
31     if s1==[] then  // insertion d'une matrice vide
32         row=%f
33         col=%f
34         [m,n]=size(s2)
35         if and(size(i)==[-1 -1]) then
36             row=%t
37         else
38             if and(i(:)==(1:m)') then row=%t,end
39         end
40         if and(size(j)==[-1 -1]) then
41             col=%t
42         else
43             if and(j(:)==(1:n)') then col=%t,end
44         end
45         if ~row&~col then error("inserting [] in submatrix --> forbidden!"),end
46         if row&col then s2=[],return,end
47         if row then
48             j1=[]
49             for jj=1:n
50                 if ~or(jj==j) then  j1=[j1 jj] ,end
51             end
52             s2=s2(:,j1)
53         else
54             i1=[]
55             for ii=1:m
56                 if ~or(ii==i) then  i1=[i1 ii] ,end
57             end
58             s2=s2(i1,:)
59         end
60     else
61         s1=tlist(["lss","A","B","C","D","X0","dt"],[],[],[],s1,[],[])
62         s2(i,j)=s1
63     end
64 endfunction