function[X0,degX0,Y0,degY0,R,degR,S,degS,tm,tn]=dioel(A,degA,B,degB,C,degC) %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % MATLAB function solves the linear Diophantine % % Equations for polynomial matrices. The equation is % % AX + BY = C % % where A,B and C are given polynomial matrices % % The general solution is % % X = X0 + RT % % Y = Y0 + ST % % Where T is an arbitrary matrix of % % dimensions tm(rows) and tn(columns) % % % % call: [X0,degX0,Y0,degY0,R,degR,S,degS,tm,tn]=.. % % dioel(A,degA,B,degB,C,degC) % % % % function used: polsize, polmul, polgld, spolcom % % spoldiv % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % S. Pejchova, Juni 13th 1994 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % dimensions check % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% [rA,cA]=polsize(A,degA); [rB,cB]=polsize(B,degB); [rC,cC]=polsize(C,degC); if (rA~=rB)|(rA~=rC) error('dioel: Inconsistent dimensions of input matrices'); end %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % matrix F = [A B] % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% [F,degF]=spolcom(A,degA,B,degB); %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % The greatest common left divisor of A and B % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% mes=0; [D,degD,U,degU,UI,degUI]=polgld(F,degF,mes); [rD,cD]=polsize(D,degD); % rank F raF=cD; %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % extracting the left divisor D of C % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% [C1,degC1]=spoldiv(D,degD,C,degC); if isempty(C1)==1 error('dioel:Matrix D is not a left divisor of C'); end %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % dimensions set % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% raD=cD; % rank D for i=1:cD Aux=D(:,(cD-i+1):cD:((cD-i+1)*(degD+1))); if Aux==zeros(size(Aux)) raD=raD-1; end end Aux=[]; [rC1,cC1]=polsize(C1,degC1); if (cC1~=cC)|(rC1>rC) error('dioel:Error in dimensions of C1'); end if rC1rA error('dioel: Error in column dimension of P1'); end Aux=[]; if cP1rA)|(rQ1~=cB) error('dioel: Error in dimensions of Q1') end Aux=[]; if cQ1cA+cB)|(cRcS)&(cR<=(cA+cB))&(cS>=(cA+cB-raF)) Aux=[]; Aux=zeros(rS,(degS+1)*(cR-cS)); S=[S Aux]; cS=cR; else if (cS>cR)&(cS<=(cA+cB))&(cR>=(cA+cB-raF)) Aux=[] Aux=zeros(rR,(degR+1)*(cS-cR)); R=[R Aux]; cR=cS; tm=cR; else error('dioel: Error in column dimensions of R and S') end end end if isempty(R)==1 degR=-inf; end if isempty(S)==1 degS=-inf; end tn=cC; if tm==0|((isempty(R))&(isempty(S))) tn=0; end %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % Particular solution X0 = P1 * C1 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% [X0,degX0]=polmul(P1,degP1,C1,degC1); %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % Particular solution Y0 = Q1 * C1 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% [Y0,degY0]=polmul(Q1,degQ1,C1,degC1);