function [A1, B1, C1, const] = fixrs2( A, B, C, r, s);
  
% QAP instance with (A,B,C) is given. A,B symmetric assumed
% new instance is generated in which r is assigned to s
% resulting in a problem of smaller dimension + constant
% two 'steps' down!
% call: [A1, B1, C1, const] = fixrs2(1 A, B, C, r, s);

  
n = size(A,1);

N = 1:n;
I = setdiff( N, r);        % take away element r
J = setdiff( N, s);        % take away element s

A1 = A(I,I);               % delete row and column r 
B1 = B(J,J);               % delete row and column s

ar = A(:, r);              % extract column r 
ar = ar(I,:);

bs = B(:, s);              % extract column s
bs = bs(J,:);

C1 = C(I,J) +  2*ar(:,1)*bs(:,1)'+ 2*ar(:,2)*bs(:,2)';                     		    
const = A(r(1),r(1)) * B(s(1),s(1)) + C(r(1),s(1)) + ...
	A(r(2),r(2)) * B(s(2),s(2)) + C(r(2),s(2)) + ...
	2*A(r(1),r(2)) * B(s(1),s(2));


% testings:
% I=[2 5 4 7 9 1 3 6 8 12 11 10]; pom=eye(n);
% X=pom(I,:);
% test1=trace(  A*X*B*X' + C*X')  
% N = 1:n;II = setdiff( N, r);JJ = setdiff( N, s); X1=X(II,JJ);
% [A1, B1, C1, const] = fixrs2( A, B, C, r, s);
% test2=trace(  A1*X1*B1*X1' + C1*X1'); test2=test2+const
