function [Utri,q,r] = lusolU(mylu)

%        [Utri,q,r] = lusolU(mylu);
%
% forms nonsingular Utri from mylu.U and sparse I.

% 10 Nov 2015: First version of lusolU.

U     = mylu.U;
p     = mylu.p;
q     = mylu.q;
r     = mylu.rank;

[~,n] = size(U);
I     = speye(n);
Utri  = [ U(p(1:r),q);
          I(r+1:n,1:n) ];