|
| 1 | +%% Copyright (C) 2017 Lagu |
| 2 | +%% |
| 3 | +%% This file is part of OctSymPy. |
| 4 | +%% |
| 5 | +%% OctSymPy is free software; you can redistribute it and/or modify |
| 6 | +%% it under the terms of the GNU General Public License as published |
| 7 | +%% by the Free Software Foundation; either version 3 of the License, |
| 8 | +%% or (at your option) any later version. |
| 9 | +%% |
| 10 | +%% This software is distributed in the hope that it will be useful, |
| 11 | +%% but WITHOUT ANY WARRANTY; without even the implied warranty |
| 12 | +%% of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See |
| 13 | +%% the GNU General Public License for more details. |
| 14 | +%% |
| 15 | +%% You should have received a copy of the GNU General Public |
| 16 | +%% License along with this software; see the file COPYING. |
| 17 | +%% If not, see <http://www.gnu.org/licenses/>. |
| 18 | + |
| 19 | +%% -*- texinfo -*- |
| 20 | +%% @documentencoding UTF-8 |
| 21 | +%% @defmethod @@sym supremum (@var{x}) |
| 22 | +%% The supremum of @var{x}. |
| 23 | +%% |
| 24 | +%% Example: |
| 25 | +%% @example |
| 26 | +%% @group |
| 27 | +%% a = interval (sym (1), 2); |
| 28 | +%% supremum (a) |
| 29 | +%% @result{} ans = (sym) 2 |
| 30 | +%% @end group |
| 31 | +%% @end example |
| 32 | +%% |
| 33 | +%% @end defmethod |
| 34 | + |
| 35 | + |
| 36 | +function y = supremum(x) |
| 37 | + if (nargin ~= 1) |
| 38 | + print_usage (); |
| 39 | + end |
| 40 | + y = elementwise_op ('lambda x: x.sup', sym (x)); |
| 41 | +end |
| 42 | + |
| 43 | + |
| 44 | +%!test |
| 45 | +%! a = interval (sym (0), 1); |
| 46 | +%! assert( isequal( supremum (a), sym (1))) |
| 47 | + |
| 48 | +%!test |
| 49 | +%! a = interval (sym (0), 1); |
| 50 | +%! b = interval (sym (2), 3); |
| 51 | +%! assert (isequal (supremum (a + b), sym (3))) |
0 commit comments