Skip to content

Commit

Permalink
add binterval
Browse files Browse the repository at this point in the history
  • Loading branch information
latot committed Sep 30, 2016
1 parent e69a6a9 commit 3ca798a
Showing 1 changed file with 65 additions and 0 deletions.
65 changes: 65 additions & 0 deletions inst/@sym/binterval.m
Original file line number Diff line number Diff line change
@@ -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 <http://www.gnu.org/licenses/>.

%% -*- texinfo -*-
%% @documentencoding UTF-8
%% @defmethod @@sym binterval (@var{x})
%% Return the union of intervals of y when, @var{x} is in rectangular form
%% or the union of intervals of theta when self is in polar form.
%%
%% Example:
%% @example
%% @group
%% a = interval (sym (2), 3);
%% b = interval (sym (4), 5);
%% binterval (complexregion (a * b))
%% @result{} ans = (sym) [4, 5]
%% @end group
%% @end example
%%
%% @example
%% @group
%% c = interval (sym (1), 7);
%% binterval (complexregion (a * b + b * c))
%% @result{} ans = (sym) [1, 7]
%% @end group
%% @end example
%%
%% @end defmethod


function y = binterval(x)
if (nargin ~= 1)
print_usage ();
end
y = python_cmd ('return _ins[0].b_interval,', sym (x));
end


%!test
%! a = interval (sym (1), 2);
%! b = interval (sym (4), 5);
%! k = binterval (complexregion (a * b));
%! assert (isequal (k, b))

%!test
%! a = interval (sym (1), 2);
%! b = interval (sym (4), 5);
%! c = interval (sym (-3), 2);
%! k = binterval (complexregion (a * b + b * c));
%! assert (isequal (k, b + c))

0 comments on commit 3ca798a

Please sign in to comment.