function A = rcop(A,a,b,c,d) % RCOP Row column operations % A = RCOP(A,a,b,c,d) performs an operation on matrix A % according to the following prescription: % If a = 1, add b times row c to row d. If a = 2, do a % column operation. % % A = RCOP(A,v) does the same thing with v = [a b c d]. % % See also UNIMOD, UNIMOD2, QUICK, QUICK2, ALGO, ALGO2, % RC_OP, MODIFY, AUTOMOD % Adapted from Harold M. Edwards, "Linear Algebra." % Written by Serge Tchikanda 02/14/96. % Last revised by Serge Tchikanda 02/24/96. [mrows,ncols]=size(A); if (nargin == 2) & (length(a) == 4) b = a(2); c = a(3); d = a(4); a = a(1); elseif (nargin == 2 | nargin == 3) & (length(a) ~= 4) disp(' ') disp(' When using 2 input arguments, second input must') disp(' contain 4 elements. No operation was performed.') break end if a == 1 if (c > mrows) | (d > mrows) | (c <= 0) | (d <= 0) disp(' ') str1=[' Invalid index specification. ']; str2=['The matrix has ',int2str(mrows),' row(s).']; disp([str1 str2]) disp(' No operation was performed.') elseif (c == d) disp(' ') disp([' Invalid index specification. Indices c and d must']) disp([' be different. No operation was performed. ']) else A(d,:) = A(d,:) + b*A(c,:); str = [int2str(b),' times ','row ',int2str(c), ... ' was added to row ',int2str(d),'.']; disp(str) end elseif a == 2 if (c > ncols) | (d > ncols) | (c <= 0) | (d <= 0) disp(' ') str1=[' Invalid index specification. ']; str2=['The matrix has ',int2str(ncols),' column(s).']; disp([str1 str2]) disp(' No operation was performed.') elseif (c == d) disp(' ') disp([' Invalid index specification. Indices c and d must']) disp([' be different. No operation was performed. ']) else A(:,d) = A(:,d) + b*A(:,c); str = [int2str(b),' times ','column ',int2str(c), ... ' was added to column ',int2str(d),'.']; disp(str) end else disp(' ') disp(' Invalid selection, index a must be 1 or 2.') disp(' No operation was performed.') end