-
Notifications
You must be signed in to change notification settings - Fork 37
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Do you like sets? I like sets! Full sets Module! #585
base: master
Are you sure you want to change the base?
Changes from all commits
bc8cb1a
8adba2e
1ca789d
0432c94
f7aaa18
ea687f7
48f1392
c4f5d14
bd7aa6f
21fba6e
6afe6ec
f4ea2ba
f9275ef
0bde17b
8211f68
8d2e67a
504e490
e88914c
4b79f56
0b33991
b3dc9ca
7c8e22e
b628130
a5678f5
187a14c
31d984c
4b4f6d1
02e356a
a40c5cd
3a0e1ef
4a7a4c4
ea86f00
38a19ad
14d4008
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
%% Copyright (C) 2017 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 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 = elementwise_op ('lambda x: x.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)) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
%% Copyright (C) 2017 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 = elementwise_op ('lambda x: x.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)) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
%% Copyright (C) 2017 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 boundary (@var{x}) | ||
%% The boundary or frontier of a set. | ||
%% | ||
%% Example: | ||
%% @example | ||
%% @group | ||
%% a = interval (sym (1), 2); | ||
%% b = interval (sym (5), 8); | ||
%% boundary (a + b) | ||
%% @result{} ans = (sym) @{1, 2, 5, 8@} | ||
%% @end group | ||
%% @end example | ||
%% | ||
%% @end defmethod | ||
|
||
|
||
function y = boundary(x) | ||
if (nargin ~= 1) | ||
print_usage (); | ||
end | ||
y = elementwise_op ('lambda x: x.boundary', sym (x)); | ||
end | ||
|
||
|
||
%!test | ||
%! a = interval (sym (0), 1); | ||
%! b = interval (sym (0), 1, true, false); | ||
%! assert( isequal( boundary (a), boundary (b))) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I know I've been very sloppy in the past, but for new code, let's try to use core Octave style (except for |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
%% Copyright (C) 2017 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 complement (@var{x}, @var{y}) | ||
%% The complement of @var{x} with @var{y} as Universe. | ||
%% | ||
%% Example: | ||
%% @example | ||
%% @group | ||
%% a = interval (sym (0), 10); | ||
%% b = interval (sym (4), 6); | ||
%% a - b | ||
%% @result{} ans = (sym) [0, 4) ∪ (6, 10] | ||
%% @end group | ||
%% @end example | ||
%% @example | ||
%% @group | ||
%% complement (b, a) | ||
%% @result{} ans = (sym) [0, 4) ∪ (6, 10] | ||
%% @end group | ||
%% @end example | ||
%% | ||
%% @end defmethod | ||
|
||
|
||
function y = complement(x, y) | ||
if (nargin ~= 2) | ||
print_usage (); | ||
end | ||
y = elementwise_op ('lambda x, y: x.complement(y)', sym (x), sym (y)); | ||
end | ||
|
||
|
||
%!test | ||
%! R = domain ('Reals'); | ||
%! a = interval (sym (-1), 1); | ||
%! b = interval (sym (-inf), -1, true, true) + interval (sym (1), inf, true, true); | ||
%! assert (isequal (complement (a, R), b)) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
%% Copyright (C) 2017 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 complexregion (@var{x}, @var{y}) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
%% Represents the Set of all Complex Numbers. | ||
%% It can represent a region of Complex Plane in | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. blank line between the "lookfor" and the rest of the body. But this looks wrong? Should it represent all complex numbers if no arguments are passed or what does the |
||
%% both the standard forms Polar and Rectangular coordinates. | ||
%% Where @var{x} are the interval and if @var{y} is true | ||
%% you will get the polar form, if is not specified or is false | ||
%% it will be constructed in rectangular form. | ||
%% | ||
%% Example for rectangular form: | ||
%% @example | ||
%% @group | ||
%% a = interval (sym (0), 2); | ||
%% b = interval (sym (5), 7); | ||
%% complexregion (a * b) | ||
%% @result{} ans = (sym) @{x + y⋅ⅈ | x, y ∊ [0, 2] × [5, 7]@} | ||
%% @end group | ||
%% @end example | ||
%% | ||
%% Example for polar form: | ||
%% @example | ||
%% @group | ||
%% a = interval (sym (1), 2); | ||
%% b = interval (sym (0), sym (pi) * 2); | ||
%% complexregion (a * b, true) | ||
%% @result{} ans = (sym) @{r⋅(ⅈ⋅sin(θ) + cos(θ)) | r, θ ∊ [1, 2] × [0, 2⋅π)@} | ||
%% @end group | ||
%% @end example | ||
%% | ||
%% @end defmethod | ||
|
||
|
||
function y = complexregion(x, y) | ||
if (nargin > 2) | ||
print_usage (); | ||
elseif nargin == 1 | ||
y = false; | ||
end | ||
y = elementwise_op ('lambda x, y: ComplexRegion(x, polar=y)', sym (x), logical (y)); | ||
end | ||
|
||
|
||
%% This function is tested in @sym/ainterval, @sym/binterval | ||
%% @sym/ispolar, @sym/psets, @sym/sets and @sym/normalizethetaset | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. add an |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
%% Copyright (C) 2017 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 contains (@var{x}, @var{y}) | ||
%% Returns True if @var{x} is contained in @var{y} as an element. | ||
%% | ||
%% Example: | ||
%% @example | ||
%% @group | ||
%% a = interval (sym (0), 10); | ||
%% contains (5, a) | ||
%% @result{} ans = (sym) True | ||
%% @end group | ||
%% @end example | ||
%% | ||
%% @end defmethod | ||
|
||
|
||
function y = contains(x, y) | ||
if (nargin ~= 2) | ||
print_usage (); | ||
end | ||
y = elementwise_op ('lambda x, y: x in y', sym (x), sym (y)); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is |
||
end | ||
|
||
|
||
%!test | ||
%! a = interval (sym (0), 10); | ||
%! assert (logical (~contains (-1, a))) | ||
|
||
%!test | ||
%! a = interval (sym (0), 10); | ||
%! assert (logical (contains (5, a))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
First line need to fit on one line (its used for
lookfor
).