% Installer: "interval_install.m" % Created: 30-Jul-2002 15:05:38. function bund_driver % bund_driver -- Driver for "bund" bundles. % bund_driver (no arguments) contains Matlab commands % to inflate the instructions and files that are % encoded into the "bund_data" function of this package. % Copyright (C) 2001 Dr. Charles R. Denham, ZYDECO. % All Rights Reserved. % Disclosure without explicit written consent from the % copyright owner does not constitute publication. % Version of 14-Jun-2001 10:54:16. % Updated 03-Aug-2001 13:43:17. help(mfilename) BINARY_TAG = '?'; CR = char(13); LF = char(10); comp = upper(computer); if any(findstr(comp, 'PCWIN')) % Windows. NL = [CR LF]; elseif any(findstr(comp, 'MAC2')) % Macintosh. NL = CR; else % Unix. NL = LF; end c = zeros(1, 256); c(abs('0'):abs('9')) = 0:9; c(abs('a'):abs('f')) = 10:15; disp([' ']) disp([' ## This installer is ready to expand its contents,']) disp([' ## starting in the present directory: "' pwd '"']) disp([' ## To abort, execute an interruption now.']) disp([' ## Otherwise, to continue, press any key.']) disp([' ']) try pause catch disp([' ## Installation interrupted.']) disp([' ']) return end tic w = which(mfilename); fin = fopen(w, 'r'); if fin < 0, return, end found = ~~0; while ~found s = fgetl(fin); if isequal(s, -1) fclose(fin); return end s = strrep(s, LF, ''); % Not necessary? s = strrep(s, CR, ''); % Not necessary? if isequal(s, 'function bund_data') found = ~~1; end end fout = -1; done = ~~0; while ~done s = fgetl(fin); if isequal(s, -1) fclose(fin); return end if length(s) > 0 if s(1) ~= '%' f = findstr(s, 'bund_setdir'); if any(f) theDir = eval(strrep(s, 'bund_setdir', '')); status = mkdir(theDir); switch status case 1 disp([' ## Directory created: "' theDir '"']) case 2 disp([' ## Directory exists: "' theDir '"']) otherwise error([' ## Error while making new directory.']) end try cd(theDir) catch error([' ## Unable to go to directory: "' theDir '"']) end else try eval(s); catch error([' ## Unable to evaluate: "' s '"']) end end elseif length(s) > 1 & s(2) == BINARY_TAG hx = double(s(3:end)); % Assume hex data. bin = 16*c(hx(1:2:end)) + c(hx(2:2:end)); fwrite(fout, bin, 'uchar'); else fprintf(fout, '%s', s(2:end)); fprintf(fout, NL); end end end fclose(fin); disp([' ## Elapsed time: ' num2str(fix(10*toc)/10) ' s.']) function bund_data bund_setdir('interval') disp(' ## Installing: "fcopy.m" (text)') fout = fopen('fcopy.m', 'w'); %function theResult = fcopy(theSource, theDestination, maxCharacters) % %% fcopy -- Copy (duplicate) a file. %% fcopy(theSource, theDestination, maxCharacters) copies the %% contents of theSource file into theDestination file, %% in increments of maxCharacters (default = 16K). Each %% file can be specified by its name or by an existing %% file-pointer. %% fcopy (no arguments) demonstrates itself by copying %% "fcopy.m" to "junk.junk". % %% Copyright (C) 1997 Dr. Charles R. Denham, ZYDECO. %% All Rights Reserved. %% Disclosure without explicit written consent from the %% copyright owner does not constitute publication. % %if nargin < 1 % help fcopy % fcopy('fcopy.m', 'junk.junk'); % return %end %if nargin < 2, return, end %if nargin < 3, maxCharacters = 1024 .* 16; end % %if isstr(theSource) % src = fopen(theSource, 'r'); % if src < 0, error(' ## Source file not opened.'); end % else % src = theSource; %end % %if isstr(theDestination) % dst = fopen(theDestination, 'w'); % if dst < 0, error(' ## Destination file not opened.'); end % else % dst = theDestination; %end % %while (1) % [s, inputCount] = fread(src, [1 maxCharacters], 'char'); % if inputCount > 0, outputCount = fwrite(dst, s, 'char'); end % if inputCount < maxCharacters | outputCount < inputCount, break, end %end % %if isstr(theDestination), result = fclose(dst); end %if isstr(theSource), result = (fclose(src) | result); end % %if nargout > 0, theResult = result; end fclose(fout); disp(' ## Installing: "interval.doc" (text)') fout = fopen('interval.doc', 'w'); %Interval Class -- Notes % %% Copyright (C) 1998 Dr. Charles R. Denham, ZYDECO. %% All Rights Reserved. %% Disclosure without explicit written consent from the %% copyright owner does not constitute publication. % %% Version of 11-Nov-1998 19:25:17. %% Updated 13-Nov-1998 09:41:59. % %Purpose of the Interval Class % %This class provides Matlab arithmetic for "interval" objects, %which are characterized by two values each: a lower-bound %and an upper-bound. Each interval is closed, meaning that %the bounds themselves are part of the interval. All of the %standard Matlab arithmetic, logical, and indexing operators %are available to this class. The relational operators are %overloaded for the ad-hoc purposes of interval-arithmetic. % %Interval Arithmetic % %Floating-point operations suffer inherently from round-off errors. %With interval-arithmetic, one can estimate the uncertainty of a %computation, say a matrix product, by embedding the numbers in %an "interval" object, with a relative-accuracy of (perhaps) "eps" %(machine precision) in each element. % %Modern floating-point computer chips employ strategies for keeping %round-off errors small. For example, arithmetic on 64-bit numbers %is often performed in registers that are at least 80-bits wide. %The result is then rounded to the "nearest" bit, rather than %"up" or "down". This helps to cancel some of the intermediate %errors, assuming that the roundable parts of the numbers are %distributed more or less uniformly. % %Numerical analysts may be able to vary the rounding with a %low-level software instruction, so that the uncertainty in %a computation can be estimated from more than one rounding %strategy. This is the approach taken by the "INTLAB" toolbox %at URL %and the related C/C++ PROFIL/BIAS software package at URL %. %(The INTLAB package requires three Mex-files which have been %ported only to WinTel and some Unix platforms.) % %The Interval Class % %Constructors % % x = interval(lo, hi), both "double". % x = interval(a, b), both "interval" objects. % x = interval(a), an "interval object. % %Operators % %All of Matlab's arithmetic, logical, and indexing operators are %available to "interval" objects, thanks to the "generic" class %from which the "interval" class is derived. Combinations of %"interval" objects are handled in straightforward fashion. For %example, [1, 2] * [3, 4] yields a lower-bound of min(1*2, 1*3, %2*3, 2*4), where [lo, hi] here denotes an interval. % %With "interval" objects, the targetted function may have to be %performed as much as four times and then be followed by an %adjustment step. Rather than write such a procedure for each %possible operation, we allow the "generic" class to parse and %dispatch the commands to the "interval/feval" method. Besides %the constructor, only an "interval/value" and an "interval/feval" %method are needed to make the system work. Thus, the "interval" %class can be very simple, because it does not need to provide a %separate method for each operator. % %The Value and Feval Methods % %The "interval/value" method, called automatically by the "generic" %class, is simple: the object itself is returned intact. This %causes the "interval/feval" method to be invoked for the actual %arithmetic. Inside "interval/feval", the underlying Matlab %arrays of type "double" are extracted, and the "feval" method %is once more invoked. This time, it will be the "double/feval" %method, because that is what the arguments now are. Thus, the %inheritance sequence is: (op = an operator) % % interval/op is inherited by ==> % generic/op which calls ==> % interval/feval('op') which calls ==> % double/feval('op') two or four times % %Relational and Logical Operators % %In interval-arithmetic, we sometimes wish to know how two %intervals overlap each other, if at all. This means that %the relational operators for the "interval" class need to %behave differently from their regular Matlab counterparts. %The exact behaviors are not universally agreed upon, and %suggestions from users would be welcome. Here is how the %operators are handled at present: % % x < y and x > y are TRUE if x is everywhere less-than % or everywhere greater-than y, respectively. % % x <= y and x >= y are TRUE if there is some overlap % of x solely across the lower end or the upper end % of y, respectively. % % x == y is TRUE only if x coincides exactly with y. % % x ~= y is ~(x == y). % % x & y returns the intersection (overlap) of x and y. % % x | y returns the union (full span) of x and y. % % ~x returns two semi-infinite intervals abutting x. % %Note that Moore, LeClerc, and other practitioners use x < y %to test whether interval x lies completely within interval y. %Use inside(x, y), or ~(x < y | x > y) instead. % %Other Methods % %The "interval" class provides a few extra functions for examining %the contents of an "interval", including "center", "width", "thin", %"isthin" and "hull". The full list of methods can be seen by executing %"methods interval" at the Matlab prompt. "Help" is available %for each function, as in "help interval/width". % %Two additional routines are available for adjusting regular Matlab %"double" numbers: "pred(x)" sets each element of x to its nearest %more-negative neighbor (predecessor) on the floating-point number %line; "succ(x)" adjusts each element of x to its nearest more-positive %neighbor (successor). % %Non-Linear Expressions % %No naive linear implementation of interval-arithmetic can %guarantee a proper answer when evaluating a non-linear %expression. For example, using x = [-1, 1], compare x*x %with x^2. The first case returns [-1, 1], while the second %returns [1, 1]. The x*x expression is not aware that the two %x's are the same, whereas the x^2 expression ignores the fact %that zero is being straddled. (The correct answer is [0 1].) %On the other hand, if x were [-1, 1] and y were [-1, 1], then %x*y would yield [-1, 1], as expected. Consequently, users %may want to test for zero-crossings in situations such as %these, so that the arguments can be pre-conditioned. % %Testing % %The routine called "interval_test" exercizes the "interval" class %by evaluating an algebraic expression and inverting a matrix. The %matrix case is interesting, because it shows that the machine's %rounding errors are typically less than the estimates given when %the corresponding "interval" object is used with a relative width %of "eps" in each element. This demonstrates the utility of rounding %to the "nearest" value, as well as the importance of using extended %arithmetic registers. % %References % %Jeffrey Allen Tupper, Graphing Equations With Generalized %Interval Arithmetic, M.Sc. Thesis, Graduate Department of Computer %Science, University of Toronto, 1996. Available on WWW at URL %. % %Also, try URL . %Click on the "Interval Software" link. % %Much additional information can be obtained by searching the %World Wide Web for "interval+arithmetic". fclose(fout); disp(' ## Installing: "interval_bundle.m" (text)') fout = fopen('interval_bundle.m', 'w'); %function interval_bundle % %% interval_bundle -- Bundle the Interval Toolbox. % %% Copyright (C) 1999 Dr. Charles R. Denham, ZYDECO. %% All Rights Reserved. %% Disclosure without explicit written consent from the %% copyright owner does not constitute publication. % %% Version of 22-Apr-1999 09:11:21. %% Updated 30-Jul-2002 14:37:53. % %at(mfilename) % %thePackage = 'interval'; % %theClasses = { % thePackage %}; % %for i = 1:length(theClasses) % newversion(theClasses{i}) %end % %theMFiles = { % mfilename % 'fcopy' % 'interval_test' % 'interval.doc' % 'pred' % 'setdef' % 'succ' %}; % %theMFiles = sort(theMFiles); % %theMessage = { % ' ' % [' ## Place "' thePackage '" in your Matlab path,'] % ' ## then restart Matlab. Execute "interval_test"' % ' ## at the Matlab prompt.' % ' ' %}; % %bund('new', thePackage) %bund('setdir', thePackage) %bund('mfile', theMFiles) %bund('class', theClasses) %bund cd .. %bund('disp', theMessage) %bund close fclose(fout); disp(' ## Installing: "interval_test.m" (text)') fout = fopen('interval_test.m', 'w'); %function interval_test % %% interval_test -- Test "interval" class. %% interval_test (no argument) exercizes the %% "interval" class. % %% Copyright (C) 1998 Dr. Charles R. Denham, ZYDECO. %% All Rights Reserved. %% Disclosure without explicit written consent from the %% copyright owner does not constitute publication. % %% Version of 11-Nov-1998 19:12:12. % %help(mfilename) % %disp(' ') %disp(' ## Algebraic Expression Test') % %u = interval(0.1, 0.3) %t = interval(0.2, 0.6) % %statement = 'x = (u*u*t) / (u*u+t*t+1);'; % %disp([' ## Evaluate: ' statement]) % %eval(statement) % %x % %disp(' ') %disp(' ## Matrix Inverse Test') % %x = rand(10, 10) - 0.5; % %a = interval(x, succ(x)); % %b = feval('inv', a) * a; % %c = inv(x) * x; % %interval_error = feval('norm', b) - 1 % %direct_error = norm(c) - 1 fclose(fout); disp(' ## Installing: "pred.m" (text)') fout = fopen('pred.m', 'w'); %function theResult = pred(x) % %% pred -- Predecessor of a value. %% pred(x) returns the floating-point predecessors %% of the elements of x. % %% Copyright (C) 1998 Dr. Charles R. Denham, ZYDECO. %% All Rights Reserved. %% Disclosure without explicit written consent from the %% copyright owner does not constitute publication. % %% Version of 10-Nov-1998 09:55:57. % %if nargin < 1, help(mfilename), return, end % %result = x - abs(x)*eps; % %if nargout > 0 % theResult = result; %else % disp(result) %end fclose(fout); disp(' ## Installing: "setdef.m" (text)') fout = fopen('setdef.m', 'w'); %function setdef(theFunction) % %% setdef -- Switch to directory of a function. %% setdef(theFunction) switches to the directory %% that contains theFunction. %% setdef (no argument) displays pwd. % %% Copyright (C) 1996 Dr. Charles R. Denham, ZYDECO. %% All Rights Reserved. %% Disclosure without written consent from the %% copyright owner does not constitute publication. % %if nargin > 0 % w = which(theFunction); % f = findstr(w, filesep); % if any(f) % w = w(1:f(length(f))); % eval(['cd(''' w(1:f(length(f))) ''')']) % end %end %disp([' ## ' pwd]) fclose(fout); disp(' ## Installing: "succ.m" (text)') fout = fopen('succ.m', 'w'); %function theResult = succ(x) % %% succ -- Successor of a value. %% succ(x) returns the floating-point successors %% of the elements of x. % %% Copyright (C) 1998 Dr. Charles R. Denham, ZYDECO. %% All Rights Reserved. %% Disclosure without explicit written consent from the %% copyright owner does not constitute publication. % %% Version of 10-Nov-1998 09:55:57. % %if nargin < 1, help(mfilename), return, end % %result = x + abs(x)*eps; % %if nargout > 0 % theResult = result; %else % disp(result) %end fclose(fout); bund_setdir('@interval') disp(' ## Installing: "center.m" (text)') fout = fopen('center.m', 'w'); %function theResult = center(self, newCenter) % %% interval/center -- Central value of an "interval". %% center(self) returns the central value of self, %% an "interval" object. %% center(self, newCenter) sets the center of self %% to the newCenter, while maintaining the original %% width. % %% Copyright (C) 1998 Dr. Charles R. Denham, ZYDECO. %% All Rights Reserved. %% Disclosure without explicit written consent from the %% copyright owner does not constitute publication. % %% Version of 10-Nov-1998 23:05:47. % %self = interval(self); % %if nargin < 2 % result = 0.5 * (lower(self) + upper(self)); %else % w = width(self); % lo = newCenter - w/2; % hi = lo + w; % result = interval(lo, hi); %end % %if nargout > 0 % theResult = result; %else % disp(result) %end fclose(fout); disp(' ## Installing: "disp.m" (text)') fout = fopen('disp.m', 'w'); %function disp(self) % %% interval/disp -- Display an "interval" object. %% disp(self) displays the value of self, an %% "interval" object. % %% Copyright (C) 1998 Dr. Charles R. Denham, ZYDECO. %% All Rights Reserved. %% Disclosure without explicit written consent from the %% copyright owner does not constitute publication. % %% Version of 10-Nov-1998 10:34:33. % %if nargin < 1, help(mfilename), return, end % %s.lower = lower(self); %s.upper = upper(self); % %disp(s) fclose(fout); disp(' ## Installing: "display.m" (text)') fout = fopen('display.m', 'w'); %function display(self) % %% interval/display -- Display an "interval" object. %% display(self) displays the value of self, an %% "interval" object. % %% Copyright (C) 1998 Dr. Charles R. Denham, ZYDECO. %% All Rights Reserved. %% Disclosure without explicit written consent from the %% copyright owner does not constitute publication. % %% Version of 10-Nov-1998 10:34:33. % %if nargin < 1, help(mfilename), return, end % %disp(' ') %disp([inputname(1) ' =']) % %disp(' ') %disp(self) fclose(fout); disp(' ## Installing: "expand.m" (text)') fout = fopen('expand.m', 'w'); %function theResult = expand(self, theValue) % %% interval/expand -- Expand an "interval". %% expand(self, theValue) expands the bounds of self, %% an "interval" object, to incorporate theValue. % %% Copyright (C) 1998 Dr. Charles R. Denham, ZYDECO. %% All Rights Reserved. %% Disclosure without explicit written consent from the %% copyright owner does not constitute publication. % %% Version of 13-Nov-1998 11:08:07. % %if nargin < 1, help(mfilename), return, end % %lo = interval(lower(self), theValue); %hi = interval(theValue, upper(self)); % %result = interval(lo, hi); % %if nargout > 0 % theResult = result; %else % disp(result) %end fclose(fout); disp(' ## Installing: "feval.m" (text)') fout = fopen('feval.m', 'w'); %function [varargout] = feval(theFcn, varargin) % %% interval/feval -- FEVAL for "interval" objects. %% [...] = feval('theFcn', ...) executes 'theFcn' on the %% arguments, one of which must be an "interval" object. %% More than one output argument not allowed. % %% Copyright (C) 1998 Dr. Charles R. Denham, ZYDECO. %% All Rights Reserved. %% Disclosure without explicit written consent from the %% copyright owner does not constitute publication. % %% Version of 10-Nov-1998 10:46:02. %% Revised 11-Nov-1998 12:24:52. % %if nargin < 1, help(mfilename), return, end % %result = []; % %theWarning = [' ## Function or syntax not supported: ' theFcn]; % %% Trim the function name. % %f = find(theFcn == '/'); %if any(f), theFcn(1:f(end)) = ''; end % %% Validate the "interval" arguments. % %for i = 1:length(varargin) % if isa(varargin{i}, 'interval') % varargin{i} = interval(varargin{i}); % end %end % %% Execute. % %try % switch nargout % case {0, 1} % switch length(varargin) % case {0} % case {1} % self = varargin{1}; % switch theFcn % case {'subsindex'} % error(theWarning) % case {'size'} % result = max(size(lower(self)), size(upper(self))); % case {'length'} % result = max(size(self)); % case {'uplus'} % Bypass unary-plus bug in Matlab FEVAL. % result = self; % case {'not'} % Return two intervals. % lo = interval(inf, lower(self)); % hi = interval(upper(self), inf); % result = {lo, hi}; % otherwise % lo = feval(theFcn, lower(self)); % hi = feval(theFcn, upper(self)); % result = interval(lo, hi); % end % case {2} % self = interval(varargin{1}); % if ~isa(varargin{2}, 'struct') % other = interval(varargin{2}); % end % switch theFcn % case {'subsref'} % lo = feval(theFcn, lower(self), varargin{2:end}); % hi = feval(theFcn, upper(self), varargin{2:end}); % result = interval(hi, lo); % case {'lt'} % result = upper(self) < lower(other); % case {'le'} % result = (lower(self) < lower(other)) & ... % (upper(self) >= lower(other)) & ... % (upper(self) <= upper(other)); % case {'eq'} % result = (lower(self) == lower(other)) & ... % (upper(self) == upper(other)); % case {'ne'} % result = ~(self == other); % case {'ge'} % result = (other < self); % case {'gt'} % result = (other <= self); % case {'and'} % Intersection. % if upper(self) >= lower(other) % lo = max(lower(self), lower(other)); % hi = min(upper(self), upper(other)); % result = interval(lo, hi); % end % case {'or'} % Union. % lo = min(lower(self), lower(other)); % hi = max(upper(self), upper(other)); % result = interval(lo, hi); % otherwise % lolo = feval(theFcn, lower(self), lower(other)); % hihi = feval(theFcn, upper(self), upper(other)); % hilo = feval(theFcn, upper(self), lower(other)); % lohi = feval(theFcn, lower(self), upper(other)); % lo = interval(lolo, lohi); % hi = interval(hilo, hihi); % result = interval(lo, hi); % end % case 3 % switch theFcn % case {'subsasgn'} % self = interval(varargin{1}); % lo = feval(theFcn, lower(self), varargin{2:end}); % hi = feval(theFcn, upper(self), varargin{2:end}); % result = interval(hi, lo); % otherwise % end % otherwise % error(theWarning) % end % otherwise % error(theWarning) % end %catch % disp(theWarning) %end % %if nargout > 0 % varargout = cell(1, nargout); % varargout{1} = result; %else % disp(result) %end fclose(fout); disp(' ## Installing: "inside.m" (text)') fout = fopen('inside.m', 'w'); %function theResult = inside(self, other) % %% interval/inside -- Is one "interval" inside another. %% inside(self, other) returns TRUE for the elements %% of self that lie inclusively inside the elements %% of other, both "interval" objects. % %% Copyright (C) 1998 Dr. Charles R. Denham, ZYDECO. %% All Rights Reserved. %% Disclosure without explicit written consent from the %% copyright owner does not constitute publication. % %% Version of 10-Nov-1998 23:19:49. % %if nargin < 1, help(mfilename), return, end % %self = interval(self); %other = interval(other); % %result = (lower(self) >= lower(other)) & ... % (upper(self) <= upper(other)); % %if nargout > 0 % theResult = result; %else % disp(result) %end fclose(fout); disp(' ## Installing: "interval.m" (text)') fout = fopen('interval.m', 'w'); %function self = interval(theLowerBound, theUpperBound) % %% interval/interval -- Constructor for the "interval" class. %% interval(theLowerBound, theUpperBound) returns an "interval" %% object bounded by the given values. Scalars and/or arrays %% are permitted, so long as they are compatible in basic %% arithmetic. The "interval" class is derived from the %% "generic" class. %% interval(self) validates and returns self, an "interval" %% object. %% interval(self, other) returns an "interval" object that %% represents the union of self and other, both "interval" %% objects. %% %% ----- SYNTAX OF THE "INTERVAL" CLASS ----- %% %% Type "methods interval" for the list of methods. %% %% Constructor %% %% interval(lo, hi) lo and hi are "double". %% interval(a, b) a and b are "interval". %% interval(a) a is "interval". %% %% Methods that return "interval": %% %% interval (Constructor) %% thin %% hull %% arithmetic operators: +, -, etc. %% isinf, isnan, isreal, isfinite, isequal %% %% Methods that return "double": %% %% lower, upper, center, width, mag, mig %% %% Methods that return "logical": %% %% logical operators: <, <=, ==, etc. %% isthin %% %% ----- END OF SYNTAX OF THE "INTERVAL" CLASS ----- % %% Copyright (C) 1998 Dr. Charles R. Denham, ZYDECO. %% All Rights Reserved. %% Disclosure without explicit written consent from the %% copyright owner does not constitute publication. % %% Version of 10-Nov-1998 09:44:11. % %if nargin < 1, help(mfilename), return, end % %theClassName = 'interval'; % %if nargin == 1 & isa(theLowerBound, theClassName) % temp = theLowerBound; % theLowerBound = lower(temp); % theUpperBound = upper(temp); %elseif nargin == 2 & ... % (isa(theLowerBound, theClassName) | ... % isa(theUpperBound, theClassName)) % temp = interval(theLowerBound) | interval(theUpperBound); % theLowerBound = lower(temp); % theUpperBound = upper(temp); %else % if nargin < 2, theUpperBound = theLowerBound; end %end % %theStruct.itsLowerBound = []; %theStruct.itsUpperBound = []; % %result = class(theStruct, theClassName, generic([])); % %result.itsLowerBound = min(theLowerBound, theUpperBound); %result.itsUpperBound = max(theLowerBound, theUpperBound); % %if nargout > 0 % self = result; %else % disp(result) %end fclose(fout); disp(' ## Installing: "isthin.m" (text)') fout = fopen('isthin.m', 'w'); %function theResult = isthin(self) % %% interval/isthin -- Is the "interval" thin. %% isthin(self) returns TRUE for the elements of self, %% an "interval" object, whose widths are zero. % %% Copyright (C) 1998 Dr. Charles R. Denham, ZYDECO. %% All Rights Reserved. %% Disclosure without explicit written consent from the %% copyright owner does not constitute publication. % %% Version of 10-Nov-1998 22:59:13. % %if nargin < 1, help(mfilename), return, end % %self = interval(self); % %result = (width(self) == 0); % %if nargout > 0 % theResult = result; %else % disp(result) %end fclose(fout); disp(' ## Installing: "lower.m" (text)') fout = fopen('lower.m', 'w'); %function theResult = lower(self, newLowerBound) % %% interval/lower -- Lower-bound of an "interval". %% lower(self) returns the lower-bound of self, %% an "interval" object. %% lower(self, newLowerBound) establishes newLowerBound %% as the new lower-bound of self. % %% Copyright (C) 1998 Dr. Charles R. Denham, ZYDECO. %% All Rights Reserved. %% Disclosure without explicit written consent from the %% copyright owner does not constitute publication. % %% Version of 10-Nov-1998 09:51:53. % %if nargin < 1, help(mfilename), return, end % %if nargin < 2 % result = self.itsLowerBound; %else % result = self; % result = interval(newLowerBound, upper(self)); %end % %if nargout > 0 % theResult = result; %else % disp(result) %end fclose(fout); disp(' ## Installing: "mag.m" (text)') fout = fopen('mag.m', 'w'); %function theResult = mag(self) % %% interval/mag -- Magnitude of an "interval" object. %% mag(self) returns the magnitude of self, an "interval" %% object. % %% Copyright (C) 1998 Dr. Charles R. Denham, ZYDECO. %% All Rights Reserved. %% Disclosure without explicit written consent from the %% copyright owner does not constitute publication. % %% Version of 10-Nov-1998 23:10:31. % %self = interval(self); % %result = max(abs(lower(self)), abs(upper(self))); % %if nargout > 0 % theResult = result; %else % disp(result) %end fclose(fout); disp(' ## Installing: "mig.m" (text)') fout = fopen('mig.m', 'w'); %function theResult = mig(self) % %% interval/mig -- Mignitude of an "interval" object. %% mig(self) returns the mignitude of self, an "interval" %% object. *** UNDER CONSTRUCTION. % %% Copyright (C) 1998 Dr. Charles R. Denham, ZYDECO. %% All Rights Reserved. %% Disclosure without explicit written consent from the %% copyright owner does not constitute publication. % %% Version of 10-Nov-1998 23:10:31. % %self = interval(self); % %result = minx(abs(lower(self)), abs(upper(self))); % ?????. % %if nargout > 0 % theResult = result; %else % disp(result) %end fclose(fout); disp(' ## Installing: "outside.m" (text)') fout = fopen('outside.m', 'w'); %function theResult = outside(self, other) % %% interval/outside -- Is one "interval" outside another. %% outside(self, other) returns TRUE for the elements %% of self that lie exclusively outside the elements %% of other, both "interval" objects. % %% Copyright (C) 1998 Dr. Charles R. Denham, ZYDECO. %% All Rights Reserved. %% Disclosure without explicit written consent from the %% copyright owner does not constitute publication. % %% Version of 10-Nov-1998 23:19:49. % %if nargin < 1, help(mfilename), return, end % %self = interval(self); %other = interval(other); % %result = (lower(self) >= upper(other)) | ... % (upper(self) <= lower(other)); % %if nargout > 0 % theResult = result; %else % disp(result) %end fclose(fout); disp(' ## Installing: "thin.m" (text)') fout = fopen('thin.m', 'w'); %function theResult = thin(self) % %% interval/thin -- Convert "interval" to thin. %% thin(self) returns self with its central values %% and zero widths. % %% Copyright (C) 1998 Dr. Charles R. Denham, ZYDECO. %% All Rights Reserved. %% Disclosure without explicit written consent from the %% copyright owner does not constitute publication. % %% Version of 10-Nov-1998 22:59:13. % %if nargin < 1, help(mfilename), return, end % %self = interval(self); % %result = interval(center(self)); % %if nargout > 0 % theResult = result; %else % disp(result) %end fclose(fout); disp(' ## Installing: "upper.m" (text)') fout = fopen('upper.m', 'w'); %function theResult = upper(self, newUpperBound) % %% interval/upper -- Upper-bound of an "interval". %% upper(self) returns the upper-bound of self, %% an "interval" object. %% upper(self, newUpperBound) establishes newUpperBound %% as the upper-bound of self. % %% Copyright (C) 1998 Dr. Charles R. Denham, ZYDECO. %% All Rights Reserved. %% Disclosure without explicit written consent from the %% copyright owner does not constitute publication. % %% Version of 10-Nov-1998 09:51:53. % %if nargin < 1, help(mfilename), return, end % %if nargin < 2 % result = self.itsUpperBound; %else % result = interval(lower(self), newUpperBound); %end % %if nargout > 0 % theResult = result; %else % disp(result) %end fclose(fout); disp(' ## Installing: "value.m" (text)') fout = fopen('value.m', 'w'); %function theResult = value(self); % %% interval/value -- Return value of an "interval". %% value(self) returns self as-is. It is called %% by the "generic/feval" method, which forces %% inheritance by "interval/feval". % %% Copyright (C) 1998 Dr. Charles R. Denham, ZYDECO. %% All Rights Reserved. %% Disclosure without explicit written consent from the %% copyright owner does not constitute publication. % %% Version of 11-Nov-1998 10:36:19. % %if nargin < 1, help(mfilename), return, end % %result = self; % %if nargout > 0 % theResult = result; %else % disp(result) %end fclose(fout); disp(' ## Installing: "version.m" (text)') fout = fopen('version.m', 'w'); %function version(self) % %% Version of 30-Jul-2002 15:05:38. % %helpdlg(help(mfilename), 'interval') fclose(fout); disp(' ## Installing: "width.m" (text)') fout = fopen('width.m', 'w'); %function theResult = width(self, newWidth) % %% interval/width -- Width of an "interval". %% width(self) returns the width of self, %% an 'interval" object. %% width(self, newWidth) sets the width of self %% to the newWidth, while maintaining the original %% center. % %% Copyright (C) 1998 Dr. Charles R. Denham, ZYDECO. %% All Rights Reserved. %% Disclosure without explicit written consent from the %% copyright owner does not constitute publication. % %% Version of 10-Nov-1998 23:05:47. % %self = interval(self); % %if nargin < 2 % result = upper(self) - lower(self); %else % c = center(self); % lo = c - newWidth/2; % hi = lo + c; % result = interval(lo, hi); %end % %if nargout > 0 % theResult = result; %else % disp(result) %end fclose(fout); cd ('..') cd ('..') disp(' ') disp(' ## Place "interval" in your Matlab path,') disp(' ## then restart Matlab. Execute "interval_test"') disp(' ## at the Matlab prompt.') disp(' ')