From ad926a85e9fccc6765b0891cbe15c09a48d4119c Mon Sep 17 00:00:00 2001 From: latot Date: Thu, 29 Sep 2016 21:08:42 -0300 Subject: [PATCH] add ainterval --- inst/@sym/ainterval.m | 65 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) create mode 100644 inst/@sym/ainterval.m diff --git a/inst/@sym/ainterval.m b/inst/@sym/ainterval.m new file mode 100644 index 000000000..a5bb11828 --- /dev/null +++ b/inst/@sym/ainterval.m @@ -0,0 +1,65 @@ +%% Copyright (C) 2016 Lagu +%% +%% This file is part of OctSymPy. +%% +%% OctSymPy is free software; you can redistribute it and/or modify +%% it under the terms of the GNU General Public License as published +%% by the Free Software Foundation; either version 3 of the License, +%% or (at your option) any later version. +%% +%% This software is distributed in the hope that it will be useful, +%% but WITHOUT ANY WARRANTY; without even the implied warranty +%% of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See +%% the GNU General Public License for more details. +%% +%% You should have received a copy of the GNU General Public +%% License along with this software; see the file COPYING. +%% If not, see . + +%% -*- texinfo -*- +%% @documentencoding UTF-8 +%% @defmethod @@sym ainterval (@var{x}) +%% Return the union of intervals of x when, @var{x} is in rectangular form +%% or the union of intervals of r when self is in polar form. +%% +%% Example: +%% @example +%% @group +%% a = interval (sym (2), 3); +%% b = interval (sym (4), 5); +%% ainterval (complexregion (a * b)) +%% @result{} ans = (sym) [2, 3] +%% @end group +%% @end example +%% +%% @example +%% @group +%% c = interval (sym (1), 7); +%% ainterval (complexregion (a * b + b * c)) +%% @result{} ans = (sym) [2, 3] ∪ [4, 5] +%% @end group +%% @end example +%% +%% @end defmethod + + +function y = ainterval(x) + if (nargin ~= 1) + print_usage (); + end + y = python_cmd ('return _ins[0].a_interval,', sym (x)); +end + + +%!test +%! a = interval (sym (1), 2); +%! b = interval (sym (4), 5); +%! k = ainterval (complexregion (a * b)); +%! assert (isequal (k, a)) + +%!test +%! a = interval (sym (1), 2); +%! b = interval (sym (4), 5); +%! c = interval (sym (-3), 2); +%! k = ainterval (complexregion (a * b + b * c)); +%! assert (isequal (k, a + b))