Code covered by the BSD License

### Highlights fromChebfun

from Chebfun by Chebfun Team
Numerical computation with functions instead of numbers.

mappref(varargin)
function varargout = mappref(varargin)
% MAPPREF fun map preferences
%   MAPPREF by itself displays the current map preferences
%   'PARINF' returns the corresponding preference value.
%   MAPPREF(PREF,VAL) assigns the value to the specified preference.
%
%   Example:
%       mapname = mappref('name')
%       mappref

%   Copyright 2011 by The University of Oxford and The Chebfun Developers.
%   See http://www.maths.ox.ac.uk/chebfun/ for Chebfun information.

persistent prefmap

% Default value
if isempty(prefmap)
prefmap.name = 'linear';
prefmap.par = [];
prefmap.parinf = [1 0];
mlock
% Use munlock (with filename) if you edit this file (or restart matlab).
end

% Display current preferences if no input is given
if nargin == 0
varargout = {prefmap};
end

% Return current preference corresponding to input
if nargin == 1
switch lower(varargin{1})
case 'name'
varargout = {prefmap.name};
case 'par'
varargout = {prefmap.par};
case 'parinf'
varargout = {prefmap.parinf};
case 'factory'
prefmap.name = 'linear';
prefmap.par = [];
prefmap.parinf = [1 0];
end
end

% Assign preference
if nargin > 1
propertyArgIn = varargin;
while length(propertyArgIn) >= 2
prop = propertyArgIn{1};
val = propertyArgIn{2};
propertyArgIn = propertyArgIn(3:end);
switch lower(prop)
case 'name'
if ~isa(val,'char')
error('CHEBFUN:mappref:input','Map name must be a string');
end
prefmap.name = val;
case 'par'
prefmap.par = val;