summaryrefslogtreecommitdiff
path: root/modules/overloading/macros/%st_c_st.sci
blob: 7e98f954657d08d04c67e8122c44be02581858eb (plain)
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
// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
// Copyright (C) INRIA
//
// This file must be used under the terms of the CeCILL.
// This source file is licensed as described in the file COPYING, which
// you should have received as part of this distribution.  The terms
// are also available at
// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt

function R=%st_c_st(M1,M2)

    d1=M1.dims;
    d2=M2.dims;
    if size(d1,"*")<>size(d2,"*") then
        error(msprintf(_("%s: In concatenation the number of dimensions for each component must match.\n"),"%st_c_st"));
    end
    F=getfield(1,M1)
    if or(F<>getfield(1,M2)) then
        error(msprintf(_("%s: Field names mismatch.\n"),"%st_c_st"));
    end
    kd=find(d1<>d2)

    kd(find(kd==2))=[]

    if kd<>[] then
        error(msprintf(_("%s: Inconsistent dimensions.\n"),"%st_c_st"));
    end
    newdim=d1;newdim(2)=d1(2)+d2(2)
    R=mlist(F,newdim)
    for k=3:size(F,"*") //loop on fields
        x1=getfield(k,M1),if type(x1)<>15 then x1=list(x1),end
        x2=getfield(k,M2),if type(x2)<>15 then x2=list(x2),end
        setfield(k,lstcat(x1,x2),R)
    end
endfunction