function [Xiter, RelErr, RelRes, Alpha, tot_it, cycle_it, stopC_it] = fcglsPoiss_rp_nn_ReSt (A, b, m_in, m_out, sigmaSq, beta, xex, x0, upD, stopC)
%
N = length(xex);
m_tot = m_in*m_out;
Xiter = zeros(N,m_tot);
RelErr = zeros(m_tot,1);
RelRes = zeros(m_tot,1);
Alpha = zeros(m_tot,1);
tot_it = 0;
cycle_it = zeros(m_out,1);
if nargin == 7
    x0 = zeros(N,1);
    upD = 'off';
    stopC = 'none';
elseif nargin == 8
    upD = 'off';
    stopC = 'none';
elseif nargin == 9
    stopC = 'none';
end
if ~ischar(stopC)
    stopC_it = zeros(m_out,1);
else
    stopC_it = [];
end
x0 (x0<0) = 0;
c = b + sigmaSq;
for i = 1:m_out
    display(i)
    [Xiter_in, RelErr_in, RelRes_in, Alpha_in, istop_in, ~, stopC_it_in] = fcglsPoiss_rp_nn(A, b, x0, m_in, sigmaSq, beta, xex, 1, c, stopC);
    if ~ischar(stopC) && ~isempty(stopC_it_in)
        stopC_it(i) = stopC_it_in;
    end
    new_tot_it = tot_it+istop_in;
    Xiter(:,tot_it+1:new_tot_it) = Xiter_in;
    RelErr(tot_it+1:new_tot_it) = RelErr_in;
    RelRes(tot_it+1:new_tot_it) = RelRes_in;
    Alpha(tot_it+1:new_tot_it) = Alpha_in;
    tot_it = new_tot_it;
    x0 = Xiter_in(:,end); x0(x0<0)=0;
    if strcmp(upD, 'on')
        c = A*x0 + beta + sigmaSq;
    end
    cycle_it(i) = istop_in;
end
Xiter = Xiter(:,1:tot_it);
RelErr = RelErr(1:tot_it);
RelRes = RelRes(1:tot_it);
Alpha = Alpha(1:tot_it);
