
function [a,o,s,n,k] =  ppivot(a,o,s,n,k);


%partial pivoting function to work on the kth row
%scale to determine row order, but do not change a(i,j) values
%note that rows are not physically swapped only the order array o(n)
%is changed

p=k;
big=abs(a(o(k),k)/s(o(k)));

for ii = k+1:n
    dummy=abs(a(o(ii),k)/s(o(ii)));
    if dummy > big
        big=dummy;
        p=ii;
    end
end %end for loop

%Now change the order array
dummy=o(p);     %dummy takes on the old value temporarily
o(p) = o(k);    %o(p) takes on the new order position
o(k) = dummy;   %o(k) switch position with p

