1// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
2// Copyright (C) INRIA
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
13function f=%p_a_r(m,f)
14    //f=  m+f
15    // author Serge Steer, INRIA
16    //!
17    [num,den]=f(["num","den"])
18    szf=size(den)
19    szm=size(m)
20
21    if and(szf>=0)&and(szm>=0) then
22        if prod(szf)==1&prod(szm)>1 then
23            den=den(ones(m))
24            szf=szm
25        end
26
27        if size(szf,"*")>2 then
28            num=num(:);den=den(:);m=m(:)
29        end
30        [num,den]=simp(num+m.*den,den)
31        num=matrix(num,szf)
32        den=matrix(den,szf)
33    else
34        //at leat one matrix is eye*x
35        if size(szf,"*")>2 | size(szm,"*")>2 then
36            msg = gettext("%s: Eye variable undefined in this context.\n")
37            error(msprintf(msg, "%p_a_r"));
38        end
39        if or(szf<0)&or(szm<0) then
40            [num,den]=simp(num+m.*den,den)
41        elseif or(szf<0) then
42            [num,den]=simp(num+m.*den,den*ones(m))
43        elseif or(szm<0) then
44            [num,den]=simp(num+(m+0)*eye(den).*den,den)
45        end
46    end
47    f=rlist(num,den,f.dt)
48endfunction
49
50