1// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
2// Copyright (C)  2016 - INRIA - Serge Steer
3//
4// This file is licensed under the terms of the GNU GPL v2.0,
5// pursuant to article 5.3.4 of the CeCILL v.2.1.
6// For more information, see the COPYING file which you should have received
7// along with this program.
8function r=%zpk_d_zpk(a,b)
9    //r=a./b for zpk systems
10    [ma,na]=size(a)
11    [mb,nb]=size(b)
12    if a.dt<>b.dt then
13        error(msprintf(_("%s: time domains are not compatible.\n"),"[a,b]"))
14    end
15    if ma*na==1 then
16        Z=cell(mb,nb);P=cell(mb,nb);
17        for k=1:nb
18            for l=1:mb
19                [Z{l,k},P{l,k}]=simplify_zp([b.P{l,k};a.Z{1}],[b.Z{l,k};a.P{1}]);
20            end
21        end
22        K=a.K./b.K
23    elseif mb*nb==1 then
24        Z=cell(ma,na);P=cell(ma,na);K=zeros(ma,na);
25        for k=1:na
26            for l=1:ma
27                [Z{l,k},P{l,k}]=simplify_zp([b.P{1};a.Z{l,k}],[b.Z{1};a.P{l,k}]);
28            end
29        end
30        K=a.K./b.K
31    else
32        if ma<>mb|na<>nb then
33            error(msprintf(_("%s: Incompatible input arguments #%d and #%d: Same number of rows expected.\n"),"[a,b]",1,2))
34        end
35        Z=cell(ma,na);P=cell(ma,na);K=zeros(ma,na);
36        for k=1:na
37            for l=1:ma
38                [Z{l,k},P{l,k}]=simplify_zp([b.P{l,k};a.Z{l,k}],[b.Z{l,k};a.P{l,k}]);
39            end
40        end
41        K=a.K./b.K
42    end
43    r=zpk(Z,P,K,a.dt);
44endfunction
45