Skip to content

Commit

Permalink
Fixed bug with nargin affecting R2016b
Browse files Browse the repository at this point in the history
  • Loading branch information
stephenbeckr committed Nov 18, 2016
1 parent 98a031a commit bc1ab74
Show file tree
Hide file tree
Showing 8 changed files with 37 additions and 9 deletions.
18 changes: 9 additions & 9 deletions private/tfocs_initialize.m
Original file line number Diff line number Diff line change
Expand Up @@ -40,21 +40,21 @@
);

% Calling the solver with a no arguments returns the default options structure
if nargin < 1 || ( nargin ==1 && isstruct( smoothF ) )
if narginn < 1 || ( narginn ==1 && isstruct( smoothF ) )
opts = odef;
% remove the "CG" options for now, since they are undocumented
opts = rmfield(opts,'cg_restart');
opts = rmfield(opts,'cg_type');
% if any default options are passed in (e.g. by tfocs_SCD), add those now:
if ( nargin ==1 && isstruct( smoothF ) )
if ( narginn ==1 && isstruct( smoothF ) )
for f = fieldnames( smoothF )'
opts.( f{1} ) = smoothF.( f{1} );
end
end

out = [];
x = opts;
if nargout == 0,
if nargoutt == 0,
disp('====== TFOCS default options =======');
% disp('Format is fieldname: { [default] ''Usage type.
% Description''}');
Expand Down Expand Up @@ -110,11 +110,11 @@
assert( ismember(class(smoothF),F_types),'smoothF is of wrong type' );
assert( ismember(class(affineF),F_types),'affineF is of wrong type' );
assert( ismember(class(projectorF),F_types),'projectorF 3 is of wrong type' );
if nargin >= 4
if narginn >= 4
x0_types = {'cell','double','single','tfocs_tuple'};
assert( ismember(class(x0),x0_types),'x0 is of wrong type' );
end
if nargin >= 5 && ~isempty(opts)
if narginn >= 5 && ~isempty(opts)
assert( ismember(class(opts),{'struct'}),'opts is of wrong type' );
end

Expand All @@ -132,7 +132,7 @@
% Process the options structure, merging it with the default options
% (merge "opts" into "odef")
def_fields = fieldnames(odef)'; % default options
if nargin > 4 && ~isempty(opts),
if narginn > 4 && ~isempty(opts),
use_fields = zeros(size(def_fields));
opt_fields = fieldnames(opts)'; % user-supplied options
for k = opt_fields,
Expand Down Expand Up @@ -380,7 +380,7 @@
smoothF = tfunc_scale( smoothF, -1 );
end
if countOps,
apply_smooth = @(x)solver_apply( 1:(1+(nargout>1)), smoothF, x );
apply_smooth = @(x)solver_apply( 1:(1+(nargoutt>1)), smoothF, x );
else
apply_smooth = smoothF;
end
Expand All @@ -396,7 +396,7 @@
projectorF = prox_stack( projectorF );
end
if countOps,
apply_projector = @(varargin)solver_apply( 4:(4+(nargout>1)), projectorF, varargin{:} );
apply_projector = @(varargin)solver_apply( 4:(4+(nargoutt>1)), projectorF, varargin{:} );
else
apply_projector = projectorF;
end
Expand Down Expand Up @@ -560,7 +560,7 @@
stopFcn = { stopFcn };
end
errs = zeros(1,length(errFcn));
if nargout == 1,
if nargoutt == 1,
saveHist = false;
end
if saveHist,
Expand Down
4 changes: 4 additions & 0 deletions tfocs.m
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,10 @@
% out contains extra information collected during the run
% opts structure containing the options used

% Nov 17 2016, hack for Matlab R2016b not allowing nargin/nargout in
% tfocs_initialize:
narginn = nargin; nargoutt = nargout;

% User has requested viewing the default values of "opts"
if nargin == 0 || ( nargin==1 && isstruct(smoothF) )
if nargout == 0
Expand Down
4 changes: 4 additions & 0 deletions tfocs_AT.m
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@
% help tfocs_help
% for a full explanation.

% Nov 17 2016, hack for Matlab R2016b not allowing nargin/nargout in
% tfocs_initialize:
narginn = nargin; nargoutt = nargout;

% Initialization
alg = 'AT';
algorithm = 'Auslender & Teboulle''s single-projection method';
Expand Down
4 changes: 4 additions & 0 deletions tfocs_GRA.m
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@
% Implements a standard gradient method. A variety of calling sequences
% are supported; type 'help tfocs_help' for a full explanation.

% Nov 17 2016, hack for Matlab R2016b not allowing nargin/nargout in
% tfocs_initialize:
narginn = nargin; nargoutt = nargout;

% Initialization
alg = 'GRA';
algorithm = 'Proximal gradient descent';
Expand Down
4 changes: 4 additions & 0 deletions tfocs_LLM.m
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@
% help tfocs_help
% for a full explanation.

% Nov 17 2016, hack for Matlab R2016b not allowing nargin/nargout in
% tfocs_initialize:
narginn = nargin; nargoutt = nargout;

% Initialization
alg = 'LLM';
algorithm = 'Lan/Lu/Monteiro''s two-projection method';
Expand Down
4 changes: 4 additions & 0 deletions tfocs_N07.m
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@
% help tfocs_help
% for a full explanation.

% Nov 17 2016, hack for Matlab R2016b not allowing nargin/nargout in
% tfocs_initialize:
narginn = nargin; nargoutt = nargout;

% Initialization
alg = 'N07';
algorithm = 'Nesterov''s 2007 two-projection method';
Expand Down
4 changes: 4 additions & 0 deletions tfocs_N83.m
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@
% help tfocs_help
% for a full explanation.

% Nov 17 2016, hack for Matlab R2016b not allowing nargin/nargout in
% tfocs_initialize:
narginn = nargin; nargoutt = nargout;

% Initialization
alg = 'N83';
algorithm = 'Nesterov''s 1983 single-projection method';
Expand Down
4 changes: 4 additions & 0 deletions tfocs_TS.m
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@
% help tfocs_help
% for a full explanation.

% Nov 17 2016, hack for Matlab R2016b not allowing nargin/nargout in
% tfocs_initialize:
narginn = nargin; nargoutt = nargout;

% Initialization
alg = 'TS';
algorithm = 'Tseng''s single-projection modification of Nesterov''s 2007 method';
Expand Down

0 comments on commit bc1ab74

Please sign in to comment.