
function X = r_solve(R,B)

% function X = r_solve(R,B)
% solution of a nonsingular upper triangular system RX = B

[n,m] = size(B); X = zeros(n,m);

X(n,:) = B(n,:)/R(n,n);
for i=n-1:-1:1;
   J=[i+1:n];
   X(i,:) = (B(i,:) - R(i,J) * X(J,:)) / R(i,i);
end;

