/usr/share/octave/site/m/sundialsTB/cvodes/cvm/cvm_options.m is in octave-sundials 2.5.0-3+b1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 | function options = cvm_options(KeyNames, varargin)
m = length(KeyNames);
% Initialize the output options structure
options = [];
for i = 1:m
options.(KeyNames{i}) = [];
end
% If the first argument is an options structure, read its non-empty fields
% and update options. Store in j the start of key-value pairs.
arg = varargin{1};
if isa(arg,'struct')
for i = 1:m
if isfield(arg,KeyNames{i})
options.(KeyNames{i}) = arg.(KeyNames{i});
end
end
j = 2;
else
j = 1;
end
% The remaining input arguments must be key-value pairs
if rem(nargin-j,2) ~= 0
error('Arguments must be key-value pairs.');
end
% Process each key-value pair
np = (nargin-j)/2;
keynames = lower(KeyNames);
for i = 1:np
% Get the key
key = varargin{j};
% key must be a string
if ~isstr(key)
error(sprintf('Argument %d is not a string property name.', j));
end
% Get the index in keynames that exactly matches the current key
% (modulo the case)
ik = strmatch(lower(key), keynames, 'exact');
if isempty(ik)
error(sprintf('Unrecognized property "%s"', key));
end
% Get the value
val = varargin{j+1};
% Set the proper field in options
options.(KeyNames{ik}) = val;
% move to next pair
j = j+2;
end
|