function x_A = xminusa(A) % XMINUSA Matrix of polynomials xI - A. % X_A = XMINUSA(A) returns the matrix of polynomials xI - A % where A is an n-by-n matrix of integers. % X_A is an (nn + 2)-by-2 matrix in which the first row is % [n 0], the second row is [1 0] and the remaining rows are either % [1, -a] for the corresponding entry a of A or [0, -a], depending % on whether the row corresponds to a diagonal entry of A or not. % Adapted from Harold M. Edwards, "Linear Algebra." % Written by Serge Tchikanda 03/26/96. % Last revised by Serge Tchikanda 06/13/96. [m,n] = size(A); if n ~= m disp(' ') disp(' Matrix must be square.') return end v = ((n+1)*(0:(n-1))) + 1; x_A1 = zeros(n*n,1); x_A1(v) = ones(n,1); x_A2 = -A(:); x_A = [n 0;1 0;x_A1 x_A2];