0001 function options = spgSetParms(varargin)
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019 if nargin == 0 && nargout == 0
0020 fprintf(' Default parameters for l1Set.m:\n');
0021 fprintf(' fid : [ positive integer | 1 ]\n');
0022 fprintf(' verbosity : [ integer: 1, 2, or 3 | 3 ]\n');
0023 fprintf(' iterations : [ positive integer | 10*m ]\n');
0024 fprintf(' nPrevVals : [ positive integer | 10 ]\n');
0025 fprintf(' bpTol : [ positive scalar | 1e-06 ]\n');
0026 fprintf(' optTol : [ positive scalar | 1e-04 ]\n');
0027 fprintf(' decTol : [ positive scalar | 1e-04 ]\n');
0028 fprintf(' stepMin : [ positive scalar | 1e-16 ]\n');
0029 fprintf(' stepMax : [ positive scalar | 1e+05 ]\n');
0030 fprintf(' rootMethod : [ 1=linear, 2=quadratic | 2 ]\n');
0031 fprintf('activeSetIt : [ positive integer | Inf ]\n');
0032 fprintf('subspaceMin : [ 0=no, 1=yes | 0 ]\n');
0033 fprintf(' iscomplex : [ 0=no, 1=yes, NaN=auto | NaN ]\n');
0034 fprintf(' maxMatvec : [ positive integer | Inf ]\n');
0035 fprintf(' weights : [ vector | 1 ]\n');
0036 fprintf(' project : [ projection function | @()]\n');
0037 fprintf('primal_norm : [ primal norm eval fun | @()]\n');
0038 fprintf(' dual_norm : [ dual norm eval fun | @()]\n');
0039 fprintf('\n');
0040 return;
0041 end
0042
0043 Names = [
0044 'fid '
0045 'verbosity '
0046 'iterations '
0047 'nPrevVals '
0048 'bpTol '
0049 'optTol '
0050 'decTol '
0051 'stepMin '
0052 'stepMax '
0053 'rootMethod '
0054 'activeSetIt '
0055 'subspaceMin '
0056 'iscomplex '
0057 'maxMatvec '
0058 'weights '
0059 'project '
0060 'primal_norm '
0061 'dual_norm '
0062 ];
0063 [m,n] = size(Names);
0064 names = lower(Names);
0065
0066
0067 options = [];
0068 for j = 1:m
0069 eval(['options.' Names(j,:) '= [];']);
0070 end
0071 i = 1;
0072 while i <= nargin
0073 arg = varargin{i};
0074 if ischar(arg), break; end
0075 if ~isempty(arg)
0076 if ~isa(arg,'struct')
0077 error(sprintf(['Expected argument %d to be a string parameter name ' ...
0078 'or an options structure\ncreated with OPTIMSET.'], i));
0079 end
0080 for j = 1:m
0081 if any(strcmp(fieldnames(arg),deblank(Names(j,:))))
0082 eval(['val = arg.' Names(j,:) ';']);
0083 else
0084 val = [];
0085 end
0086 if ~isempty(val)
0087 eval(['options.' Names(j,:) '= val;']);
0088 end
0089 end
0090 end
0091 i = i + 1;
0092 end
0093
0094
0095 if rem(nargin-i+1,2) ~= 0
0096 error('Arguments must occur in name-value pairs.');
0097 end
0098 expectval = 0;
0099 while i <= nargin
0100 arg = varargin{i};
0101
0102 if ~expectval
0103 if ~ischar(arg)
0104 error(sprintf('Expected argument %d to be a string parameter name.', i));
0105 end
0106
0107 lowArg = lower(arg);
0108 j = strmatch(lowArg,names);
0109 if isempty(j)
0110 error(sprintf('Unrecognized parameter name ''%s''.', arg));
0111 elseif length(j) > 1
0112
0113 k = strmatch(lowArg,names,'exact');
0114 if length(k) == 1
0115 j = k;
0116 else
0117 msg = sprintf('Ambiguous parameter name ''%s'' ', arg);
0118 msg = [msg '(' deblank(Names(j(1),:))];
0119 for k = j(2:length(j))'
0120 msg = [msg ', ' deblank(Names(k,:))];
0121 end
0122 msg = sprintf('%s).', msg);
0123 error(msg);
0124 end
0125 end
0126 expectval = 1;
0127
0128 else
0129 eval(['options.' Names(j,:) '= arg;']);
0130 expectval = 0;
0131
0132 end
0133 i = i + 1;
0134 end
0135
0136 if expectval
0137 error(sprintf('Expected value for parameter ''%s''.', arg));
0138 end
0139