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
13
14function [n,m,x,y,nt,mt,xt,yt]=dcf(g,polf,polc,tol)
15    //[n,m,x,y,nt,mt,xt,yt]=dcf(g,[polf,polc,[tol]]) returns eight
16    //stable systems (n,m,x,y,nt,mt,xt,yt) for the doubly coprime factorization
17    //
18    //                 !xt  -yt! ! m  y !
19    //                 !       !*!      ! = eye
20    //                 !-nt  mt! ! n  x !
21    // G must be stabilizable and detectable.
22    // See copfac for a description of parameters.
23    //!
24
25    [lhs,rhs]=argn(0),
26    n1=contr(g(2),g(3)),n2=contr(g(2)',g(4)'),
27    select rhs,
28    case 1 then
29        polc=-ones(1,n1),polf=-ones(1,n2),tol=1000*%eps,
30    case 2 then
31        tol=polf,polc=-ones(1,n1),polf=-ones(1,n2),
32    case 3 then tol=1000*%eps,
33    end,
34    [n,m,xt,yt]=copfac(g,polf,polc,tol),
35    [nt,mt,x,y]=copfac(g',polc,polf,tol),
36    nt=nt',mt=mt',x=x',y=y',
37endfunction
38