function A = etchg(A,E,i,j,d) % ETCHG Change entries of matrices of polynomials in long format. % A = ETCHG(A,E,i,j) substitutes the rows of E for the (i,j) % entries of an m-by-n matrix of polynomials stored in an % (m*n + 2)-by-(k+1) matrix (long format). % k is the highest degree of the polynomials in A. % % ETCHG(A,E,i,j,d) assumes that E contains only integers and % uses d as the common denominator of the entries in E. % % See also ELCHG, PRTV % Written by Serge Tchikanda 06/14/96. % Last revised by Serge Tchikanda 06/17/96. [m,n]=psize(A); if isempty(m) | isempty(n) return end if strcmp(':',i) i = 1:m; end if strcmp(':',j) j = 1:n; end idx = etplf(A,i,j); if isempty(idx) return end D = A(2,1); [m1,n1]=size(A); [mE,nE]=size(E); if mE ~= (length(i)) disp(' ') disp(' The number of (i,j) entries must agree') disp(' with the number of rows of the second input.') return end if nE < n1 E = [zeros(mE,n1-nE) E]; elseif nE > n1 A(1:2)=[0;0]; A = [zeros(m1,nE-n1) A]; A(1:2) = [m;D]; end if nargin < 5 [num,den]=rat(E); d=matlcm(den); A(idx,:)=E*D; A(2:m1,:)=A(2:m1,:)*d; else A(2:m1,:)=A(2:m1,:)*d; A(idx,:)=E*D; end A = prtv(A,':',':'); % In case d was not gcd(E)