function s = spqrZt(Z,t)

%        s = spqrZt(Z,t);
% takes an n-vector t and computes s = Z'*t,
% where Z satisfies S'*Z = 0.
% If t = S*u say, we will have s = Z'*S*u = 0.

% 02 Feb 2016: First working version of spqrZt.

r    = Z.info.rank_A_estimate;
n    = length(t);
b    = Z.Rinv*t;
if ~Z.trans
    s    = spqr_qmult(Z.Q,b,0);
    s    = [sparse(r,1); s(r+1:n)];
else
    b    = Z.P'*b;
    b1   = b(1:r);
    b2   = b(r+1:n);
    R1   = Z.R(1:r,1:r);
    R2   = Z.R(1:r,r+1:n);
    s    = -R2'*(R1'\b1) + b2; %[-R1\R2; I]'*b;
    s    = [sparse(r,1); s];
end
