|
| 1 | +%% Copyright (C) 2016 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 complement (@var{x}, @var{y}) |
| 22 | +%% The complement of @var{x} with @var{y} as Universe. |
| 23 | +%% |
| 24 | +%% Example: |
| 25 | +%% @example |
| 26 | +%% @group |
| 27 | +%% a = interval (sym (0), 10); |
| 28 | +%% b = interval (sym (4), 6); |
| 29 | +%% a - b |
| 30 | +%% @result{} ans = (sym) [0, 4) ∪ (6, 10] |
| 31 | +%% @end group |
| 32 | +%% @end example |
| 33 | +%% @example |
| 34 | +%% @group |
| 35 | +%% complement (b, a) |
| 36 | +%% @result{} ans = (sym) [0, 4) ∪ (6, 10] |
| 37 | +%% @end group |
| 38 | +%% @end example |
| 39 | +%% |
| 40 | +%% @end defmethod |
| 41 | + |
| 42 | + |
| 43 | +function y = complement(x, y) |
| 44 | + if (nargin ~= 2) |
| 45 | + print_usage (); |
| 46 | + end |
| 47 | + y = python_cmd ('return _ins[0].complement(_ins[1]),', sym (x), sym (y)); |
| 48 | +end |
| 49 | + |
| 50 | + |
| 51 | +%!test |
| 52 | +%! R = domain ('Reals'); |
| 53 | +%! a = interval (sym (-1), 1); |
| 54 | +%! b = interval (sym (-inf), -1, true, true) + interval (sym (1), inf, true, true); |
| 55 | +%! assert (isequal (complement (a, R), b)) |
0 commit comments