You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: IRrestart.m
    path of file: ./repos/IRtools/IRcodes
    
    the code of the file until where you have to start completion: function [X, info] = IRrestart(A, b, varargin)
% IRrestart Restarted Krylov subspace methods
%
% options  = IRrestart('defaults')
% [X,info] = IRrestart(A,b)
% [X,info] = IRrestart(A,b,K)
% [X,info] = IRrestart(A,b,options)
% [X,info] = IRrestart(A,b,K,options)
%
% This function provides a general framework for a variety of methods
% (IRconstr_ls, IRirn, IRhtv), and implements an inner-outer (or restarted)
% iteration scheme.
%
% Semi-convergent or hybrid iterative solvers are used in the inner iterations, 
% using one of the iterative methods in IRtools (e.g., IRhybrid_gmres).
% Every outer iteration produces a new approximation that incorporates the 
% desired properties and/or constraints (see IRconstr_ls, IRirn, IRhtv
% for further details).
%
% The regularization parameter and number of inner iterations influence
% the behavior and convergence of the outer iterations.
%
% With 'defaults' as input returns the default options.  Otherwise outputs
% the iterates specified in K, using max(K) as MaxIter, and using all other
% default options.  With options as input: uses the user-specified options
% and all the other default options.
%
% Inputs:
%  A : either (a) a full or sparse matrix
%             (b) a matrix object that performs the matrix*vector operation
%             (c) user-defined function handle
%  b : rhs vector
%  K : (optional) integer vector that specifies which (total) iterates are 
%      returned in X; the maximum number of iterations is assumed to be max(K)
%      [ positive integer | vector of positive components ]
%  options : structure with the following fields (optional)
%             x0 - initial guess for the iterations; default = zero vector
%                        [ array | {'none'} ]
%             MaxIterIn - maximum number of inner iterations
%             MaxIterOut - maximum number of outer iterations
%             x_true - true solution; allows us to returns error norms
%                      with respect to x_true at each iteration
%                      [ array | {'none'} ]
%             RegParam - a value or a method to find the regularization
%                        used in the inner iterations: 
%                        [non-negative scalar | {'gcv'} | 'discrep' ]
%                    This also determines which stopping rule is used for
%                    the inner iterations.

    
function [X, info] = IRrestart(A, b, varargin)
% IRrestart Restarted Krylov subspace methods
%
% options  = IRrestart('defaults')
% [X,info] = IRrestart(A,b)
% [X,info] = IRrestart(A,b,K)
% [X,info] = IRrestart(A,b,options)
% [X,info] = IRrestart(A,b,K,options)
%
% This function provides a general framework for a variety of methods
% (IRconstr_ls, IRirn, IRhtv), and implements an inner-outer (or restarted)
% iteration scheme.
%
% Semi-convergent or hybrid iterative solvers are used in the inner iterations, 
% using one of the iterative methods in IRtools (e.g., IRhybrid_gmres).
% Every outer iteration produces a new approximation that incorporates the 
% desired properties and/or constraints (see IRconstr_ls, IRirn, IRhtv
% for further details).
%
% The regularization parameter and number of inner iterations influence
% the behavior and convergence of the outer iterations.
%
% With 'defaults' as input returns the default options.  Otherwise outputs
% the iterates specified in K, using max(K) as MaxIter, and using all other
% default options.  With options as input: uses the user-specified options
% and all the other default options.
%
% Inputs:
%  A : either (a) a full or sparse matrix
%             (b) a matrix object that performs the matrix*vector operation
%             (c) user-defined function handle
%  b : rhs vector
%  K : (optional) integer vector that specifies which (total) iterates are 
%      returned in X; the maximum number of iterations is assumed to be max(K)
%      [ positive integer | vector of positive components ]
%  options : structure with the following fields (optional)
%             x0 - initial guess for the iterations; default = zero vector
%                        [ array | {'none'} ]
%             MaxIterIn - maximum number of inner iterations
%             MaxIterOut - maximum number of outer iterations
%             x_true - true solution; allows us to returns error norms
%                      with respect to x_true at each iteration
%                      [ array | {'none'} ]
%             RegParam - a value or a method to find the regularization
%                        used in the inner iterations: 
%                        [non-negative scalar | {'gcv'} | 'discrep' ]
%                    This also determines which stopping rule is used for
%                    the inner iterations.
%                    If 'gcv' is chosen, the inner iteration is stopped when
%                    the GCV function minimum stabilizes or increases 
%                    within a certain window of iterations (see 'stopGCV',
%                    'FlatTol' and 'MinTol').
%                    If 'discrep' is chosen, and NoiseLevel is
%                    provided, then the discrepancy principle is used
%                    for a stopping criterion (see 'NoiseLevel' and 'eta').
%             stopGCV - stopping criterion for the inner iterations when
%                       GCV is used
%                       [ GCVvalues | {'resflat'} ]
%             FlatTol - tolerance for detecting flatness (stabilization)
%                       in the GCV function as a stopping criterion for the
%                       inner iterations
%                       [ non-negative scalar | {10^-6} ]
%             MinTol - window of iterations - if the GCV minimum continues
%                      to increase over this window, then the inner
%                      iterations are stopped:
%                      [ positive integer | {3}]
%             RegMatrix - priorconditioner for the inner iterations
%                         [ {'identity'} | square nonsingular matrix |
%                           function handle ]
%             NoiseLevel - norm of noise in rhs divided by norm of rhs
%                          (must be assigned in RegParam is 'discrep')
%                          [ {none} | nonnegative scalar ]
%             eta - safety factor for the discrepancy principle
%                   [ 1.01 | scalar greater than (and close to) 1 ]
%             RegParam0 - first regularization parameter, used only on the 
%                         very first iteration (needed if RegParam is 'discrep')
%                         [ {1} | positive scalar ]
%             stopOut - stopping criterion for the outer iterations;
%                       [ {'xstab'} | 'Lxstab' | 'regPstab' ]
%             inSolver - solver to be employed during the inner iterations
%                       [ 'gmres' | {'lsqr'} | 'fgmres' | 'rrgmres' | 'cgls' ]
%             adaptConstr - approximate constraint or regularization
%                           to be incorporated
%                           [ {'tv'} | 'nn' | 'tvnn' | 'sp' | 'spnn' |
%                             'box' | 'energy' | 'project' | 'none']
%               'box' requires upper and lower scalar bounds 'xMin' and 'xMax'
%               'energy' requires the positive scalar 'xEnergy'
%               'project' requires 'xMin', 'xMax' and 'xEnergy'
%             xMin - lower bound for the solution elements
%                    [ {0} | scalar value ]
%             xMax - upper bound for the solution elements
%                    [ {Inf} | scalar value]
%             xEnergy - value of the energy constraint
%                       [ {'none'} | positive scalar ]
%             IterBar - shows the progress of the outer iterations
%                       [ {'on'} | 'off' ]
%             NoStopIn - Specifies whether the inner iterations should proceed
%                        after a stopping criterion has been satisfied
%                        [ 'on' | {'off'} ]
%             NoStopOut - specifies whether the outer iterations should
%                         proceed after a stopping criterion has been satisfied
%                         [ 'on' | {'off'} ]
%             warmrestart - specifies wether an available approximation of
%                           the solution should be used as an initial guess.
%                           [ 'on' | {'off'} ]
%             verbosity - switch on or off the "verbosity" of the function
%                       [ {'on'} | 'off' ]
% Note: the options structure can be created using the function 'IRset'.
%
% Outputs:
%   X : computed solutions, stored column-wise (at the iterations listed in K)
%   info: structure with the following fields:
%          its - number of the last computed iteration
%          saved_iterations - iteration numbers of iterates stored in X 
%          StopFlag_in - string that describes the inner stopping condition:
%              * Stopping criterion of the inner iterations is never satisfied
%              * Stopping criterion is satisfied at least once during the
%                inner iterations
%          StopFlag_out - string that describes the outer stopping condition;
%                         depend