Skip to content

Commit 04812f8

Browse files
committed
add binterval
1 parent 8db86d8 commit 04812f8

File tree

1 file changed

+65
-0
lines changed

1 file changed

+65
-0
lines changed

inst/@sym/binterval.m

+65
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
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 binterval (@var{x})
22+
%% Return the union of intervals of y when, @var{x} is in rectangular form
23+
%% or the union of intervals of theta when self is in polar form.
24+
%%
25+
%% Example:
26+
%% @example
27+
%% @group
28+
%% a = interval (sym (2), 3);
29+
%% b = interval (sym (4), 5);
30+
%% binterval (complexregion (a * b))
31+
%% @result{} ans = (sym) [4, 5]
32+
%% @end group
33+
%% @end example
34+
%%
35+
%% @example
36+
%% @group
37+
%% c = interval (sym (1), 7);
38+
%% binterval (complexregion (a * b + b * c))
39+
%% @result{} ans = (sym) [1, 7]
40+
%% @end group
41+
%% @end example
42+
%%
43+
%% @end defmethod
44+
45+
46+
function y = binterval(x)
47+
if (nargin ~= 1)
48+
print_usage ();
49+
end
50+
y = python_cmd ('return _ins[0].b_interval,', sym (x));
51+
end
52+
53+
54+
%!test
55+
%! a = interval (sym (1), 2);
56+
%! b = interval (sym (4), 5);
57+
%! k = binterval (complexregion (a * b));
58+
%! assert (isequal (k, b))
59+
60+
%!test
61+
%! a = interval (sym (1), 2);
62+
%! b = interval (sym (4), 5);
63+
%! c = interval (sym (-3), 2);
64+
%! k = binterval (complexregion (a * b + b * c));
65+
%! assert (isequal (k, b + c))

0 commit comments

Comments
 (0)