Skip to content

Commit d1e59d0

Browse files
committed
Merge remote-tracking branch 'upstream/master' into more_sets
2 parents 1c5be7d + 124de1e commit d1e59d0

34 files changed

+259
-85
lines changed

.mailmap

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Prevent git from showing duplicate names with commands like "git shortlog"
2+
# See the manpage of git-shortlog for details.
3+
# The syntax is:
4+
# Name that should be used <email that should be used> Bad name <bad email>
5+
#
6+
# You can skip Bad name if it is the same as the one that should be used, and is unique.
7+
#
8+
# This file is up-to-date if the command git log --format="%aN <%aE>" | sort -u
9+
# gives no duplicates.
10+
Colin B. Macdonald <[email protected]> Colin Macdonald <[email protected]>
11+
Colin B. Macdonald <[email protected]> Colin B. Macdonald <[email protected]>
12+
Colin B. Macdonald <[email protected]> Colin Macdonald <[email protected]>
13+
Abhinav Tripathi <[email protected]> Abhinav <[email protected]>
14+
15+
Carnë Draug <[email protected]> carandraug <devnull@localhost>
16+
17+
John W. Eaton <[email protected]> jwe <devnull@localhost>
18+
19+
Andrés Prieto <[email protected]> maprieto <[email protected]>
20+
21+

.travis.yml

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,25 +5,23 @@ language: generic
55

66
matrix:
77
include:
8-
- python: "2.7"
9-
env: PYTAVE=no SYMPY_VER=1.0 OCT_PPA=yes DOCTEST=yes COLUMNS=80
10-
- python: "3.5"
11-
env: PYTAVE=no SYMPY_VER=1.0 OCT_PPA=yes DOCTEST=yes COLUMNS=80
8+
- env: PYTHON=python2 PYTHON_VER="" PYTAVE=no SYMPY_VER=1.0 OCT_PPA=yes DOCTEST=yes COLUMNS=80
9+
- env: PYTHON=python3 PYTHON_VER="3" PYTAVE=no SYMPY_VER=1.0 OCT_PPA=yes DOCTEST=yes COLUMNS=80
1210

1311
# need octave devel pkgs for doctest (has compiled code as of July 2015)
14-
install:
12+
before_install:
1513
- if [ "x$OCT_PPA" = "xyes" ]; then
1614
sudo apt-add-repository -y ppa:octave/stable;
1715
fi
18-
- sudo apt-get update -qq -y;
19-
- sudo apt-get install -qq -y octave liboctave-dev;
20-
- sudo apt-get install -qq -y python;
21-
- "pip install --user sympy==$SYMPY_VER"
16+
- sudo apt-get update -y;
17+
- sudo apt-get install -y octave liboctave-dev;
18+
- sudo apt-get install -y python$PYTHON_VER-pip;
19+
- "pip$PYTHON_VER install --user sympy==$SYMPY_VER"
2220
- if [ "x$DOCTEST" = "xyes" ]; then
2321
octave -W --no-gui --eval "pkg install -forge doctest";
2422
fi
2523
- if [ "x$PYTAVE" = "xyes" ]; then
26-
sudo apt-get install -qq -y libboost-python-dev python-numpy;
24+
sudo apt-get install -qq -y libboost-python-dev python$PYTHON_VER-numpy;
2725
hg clone https://bitbucket.org/genuinelucifer/pytave_main;
2826
mv pytave_main pytave;
2927
pushd pytave;

CONTRIBUTORS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ Eric Chassande-Mottin
1515
Nicol N. Schraudolph
1616
Sylvain Pelissier
1717
Alex Vong
18+
Marco Falke
1819

1920
(Please contact the developers if your name should be here but isn't!)
2021

NEWS

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,13 @@ octsympy 2.5.0-dev
1515
cosd
1616
dawson
1717
divisors
18+
eye
1819
hilb
1920
invhilb
21+
ones
2022
sind
2123
tand
24+
zeros
2225

2326
* Add more `@double` numerical functions. For now these are simply
2427
wrappers around SymPy, so they are slower than native floating
@@ -33,6 +36,8 @@ octsympy 2.5.0-dev
3336
* The full set of assumptions implemented by Sympy can now be used.
3437
For example, `syms p prime` assumes `p` is prime.
3538

39+
* `solve` now works with inequalities.
40+
3641
* Update minimum versions of SymPy to 1.0 and Octave to 4.0.0, so
3742
we can remove some crufty workarounds.
3843

@@ -48,8 +53,10 @@ octsympy 2.5.0-dev
4853

4954
* `isfinite` behaves correctly for variables (and is documented).
5055

51-
* New experimental Python communication using Pytave, due to
52-
Abhinav Tripathi during Google Summer of Code 2016.
56+
* New experimental Python communication using the native Python/C
57+
interface, due to Abhinav Tripathi during Google Summer of Code 2016.
58+
59+
* Bug fix: assign `[]` to row/column removes that that row/column.
5360

5461

5562

inst/@sym/chebyshevT.m

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
%% Copyright (C) 2016 Abhinav Tripathi and Colin B. Macdonald
1+
%% Copyright (C) 2016 Abhinav Tripathi
2+
%% Copyright (C) 2016 Colin B. Macdonald
23
%%
34
%% This file is part of OctSymPy.
45
%%

inst/@sym/chebyshevU.m

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
%% Copyright (C) 2016 Abhinav Tripathi and Colin B. Macdonald
1+
%% Copyright (C) 2016 Abhinav Tripathi
2+
%% Copyright (C) 2016 Colin B. Macdonald
23
%%
34
%% This file is part of OctSymPy.
45
%%

inst/@sym/dot.m

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
%% Copyright (C) 2015 Colin B. Macdonald
2-
%% Copyright (C) 2016 Colin B. Macdonald, Alex Vong
1+
%% Copyright (C) 2015-2016 Colin B. Macdonald
2+
%% Copyright (C) 2016 Alex Vong
33
%%
44
%% This file is part of OctSymPy.
55
%%

inst/@sym/dsolve.m

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
%% Copyright (C) 2014, 2015 Colin B. Macdonald, Andrés Prieto
2-
%% Copyright (C) 2016 Colin B. Macdonald
1+
%% Copyright (C) 2014-2016 Colin B. Macdonald
2+
%% Copyright (C) 2014-2015 Andrés Prieto
33
%%
44
%% This file is part of OctSymPy.
55
%%

inst/@sym/fourier.m

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
%% Copyright (C) 2014 Colin B. Macdonald
2-
%% Copyright (C) 2015 Andrés Prieto, Alexander Misel, Colin B. Macdonald
3-
%% Copyright (C) 2016 Andrés Prieto, Colin B. Macdonald
1+
%% Copyright (C) 2014-2016 Colin B. Macdonald
2+
%% Copyright (C) 2015-2016 Andrés Prieto
3+
%% Copyright (C) 2015 Alexander Misel
44
%%
55
%% This file is part of OctSymPy.
66
%%

inst/@sym/frac.m

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
%% Copyright (C) 2016 Lagu and Colin B. Macdonald
1+
%% Copyright (C) 2016 Lagu
2+
%% Copyright (C) 2016 Colin B. Macdonald
23
%%
34
%% This file is part of OctSymPy.
45
%%

inst/@sym/heaviside.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@
9090

9191
%!test
9292
%! if (python_cmd ('return Version(spver) <= Version("1.0")'))
93-
%! print ('skipping test, sympy too old')
93+
%! disp ('skipping test, sympy too old')
9494
%! else
9595
%! H0 = sym([1 -2 0; 3 0 pi]);
9696
%! A = heaviside (sym(0), H0);

inst/@sym/ifourier.m

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
%% Copyright (C) 2014 Colin B. Macdonald
2-
%% Copyright (C) 2015 Andrés Prieto, Alexander Misel, Colin B. Macdonald
3-
%% Copyright (C) 2016 Andrés Prieto, Colin B. Macdonald
1+
%% Copyright (C) 2014-2016 Colin B. Macdonald
2+
%% Copyright (C) 2015-2016 Andrés Prieto
3+
%% Copyright (C) 2015 Alexander Misel
44
%%
55
%% This file is part of OctSymPy.
66
%%

inst/@sym/ilaplace.m

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
%% Copyright (C) 2014 Andrés Prieto
2-
%% Copyright (C) 2015-2016 Andrés Prieto, Colin Macdonald
1+
%% Copyright (C) 2014-2016 Andrés Prieto
2+
%% Copyright (C) 2015-2016 Colin Macdonald
33
%%
44
%% This file is part of OctSymPy.
55
%%

inst/@sym/intersect.m

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
%% Copyright (C) 2016 Colin B. Macdonald and Lagu
1+
%% Copyright (C) 2016 Colin B. Macdonald
2+
%% Copyright (C) 2016 Lagu
23
%%
34
%% This file is part of OctSymPy.
45
%%

inst/@sym/interval.m

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
%% Copyright (C) 2016 Colin B. Macdonald and Lagu
1+
%% Copyright (C) 2016 Colin B. Macdonald
2+
%% Copyright (C) 2016 Lagu
23
%%
34
%% This file is part of OctSymPy.
45
%%

inst/@sym/ismember.m

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
%% Copyright (C) 2016 Lagu, Colin B. Macdonald
1+
%% Copyright (C) 2016 Lagu
2+
%% Copyright (C) 2016 Colin B. Macdonald
23
%%
34
%% This file is part of OctSymPy.
45
%%

inst/@sym/kron.m

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
%% Copyright (C) 2016 Utkarsh Gautam and Colin B. Macdonald
1+
%% Copyright (C) 2016 Utkarsh Gautam
2+
%% Copyright (C) 2016 Colin B. Macdonald
23
%%
34
%% This file is part of OctSymPy.
45
%%

inst/@sym/laplace.m

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
%% Copyright (C) 2014 Andrés Prieto
2-
%% Copyright (C) 2015-2016 Andrés Prieto, Colin Macdonald
1+
%% Copyright (C) 2014-2016 Andrés Prieto
2+
%% Copyright (C) 2015-2016 Colin Macdonald
33
%%
44
%% This file is part of OctSymPy.
55
%%

inst/@sym/partfrac.m

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
%% Copyright (C) 2014, 2015 Colin B. Macdonald, Andrés Prieto
2-
%% Copyright (C) 2016 Colin B. Macdonald
1+
%% Copyright (C) 2014-2016 Colin B. Macdonald
2+
%% Copyright (C) 2014-2015 Andrés Prieto
33
%%
44
%% This file is part of OctSymPy.
55
%%

inst/@sym/private/mat_replace.m

Lines changed: 45 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
%% Copyright (C) 2014, 2015 Colin B. Macdonald
1+
%% Copyright (C) 2014-2016 Colin B. Macdonald
2+
%% Copyright (C) 2016 Lagu
23
%%
34
%% This file is part of OctSymPy.
45
%%
@@ -27,11 +28,53 @@
2728

2829
function z = mat_replace(A, subs, b)
2930

30-
if ( (length(subs) == 1) && (islogical(subs{1})) )
31+
%% Check when b is []
32+
if (isempty(b))
33+
switch length(subs)
34+
case 1
35+
if strcmp(subs{1}, ':')
36+
z = sym([]);
37+
return
38+
else
39+
if rows(A) == 1
40+
z = python_cmd('_ins[0].col_del(_ins[1] - 1); return _ins[0],', A, sym(subs{1}));
41+
return
42+
elseif columns(A) == 1
43+
z = python_cmd('_ins[0].row_del(_ins[1] - 1); return _ins[0],', A, sym(subs{1}));
44+
return
45+
else
46+
z = sym([]);
47+
for i=1:A.size(2)
48+
z = [z subsref(A, substruct ('()', {':', i})).'];
49+
end
50+
z = subsasgn (z, substruct ('()', {subs{1}}), []);
51+
return
52+
end
53+
end
54+
case 2
55+
if strcmp(subs{1}, ':')
56+
z = python_cmd('_ins[0].col_del(_ins[1] - 1); return _ins[0],', A, sym(subs{2}));
57+
return
58+
elseif strcmp(subs{2}, ':')
59+
z = python_cmd('_ins[0].row_del(_ins[1] - 1); return _ins[0],', A, sym(subs{1}));
60+
return
61+
else
62+
error('A null assignment can only have one non-colon index.'); % Standard octave error
63+
end
64+
otherwise
65+
error('Unexpected subs input')
66+
end
67+
end
68+
69+
if (length(subs) == 1 && islogical(subs{1}))
3170
%% A(logical) = B
3271
z = mat_mask_asgn(A, subs{1}, b);
3372
return
3473

74+
elseif (length(subs) == 1 && strcmp(subs{1}, ':') && length(b) == 1)
75+
z = python_cmd('return ones(_ins[0], _ins[1])*_ins[2],', A.size(1), A.size(2), sym(b));
76+
return
77+
3578
elseif (length(subs) == 1)
3679
% can use a single index to grow a vector, so we carefully deal with
3780
% vector vs linear index to matrix (not required for access)

inst/@sym/setdiff.m

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
%% Copyright (C) 2014 Colin B. Macdonald
2-
%% Copyright (C) 2016 Lagu and Colin B. Macdonald
1+
%% Copyright (C) 2014, 2016 Colin B. Macdonald
2+
%% Copyright (C) 2016 Lagu
33
%%
44
%% This file is part of OctSymPy.
55
%%

inst/@sym/setxor.m

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
%% Copyright (C) 2014 Colin B. Macdonald
2-
%% Copyright (C) 2016 Lagu and Colin B. Macdonald
1+
%% Copyright (C) 2014, 2016 Colin B. Macdonald
2+
%% Copyright (C) 2016 Lagu
33
%%
44
%% This file is part of OctSymPy.
55
%%

inst/@sym/solve.m

Lines changed: 33 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
%% Copyright (C) 2014, 2015 Colin B. Macdonald, Andrés Prieto
2-
%% Copyright (C) 2016 Colin B. Macdonald
1+
%% Copyright (C) 2014-2016 Colin B. Macdonald
2+
%% Copyright (C) 2014-2015 Andrés Prieto
3+
%% Copyright (C) 2016 Lagu
34
%%
45
%% This file is part of OctSymPy.
56
%%
@@ -23,7 +24,7 @@
2324
%% @deftypemethodx @@sym {@var{sol} =} solve (@var{eq1, eq2})
2425
%% @deftypemethodx @@sym {@var{sol} =} solve (@var{eq1, @dots{}, eqn, v1, @dots{}, vm})
2526
%% @deftypemethodx @@sym {[@var{s1, @dots{}, sn}] =} solve (@var{eq1, @dots{}, eqm, v1, @dots{}, vn})
26-
%% Symbolic solutions of equations and systems.
27+
%% Symbolic solutions of equations, inequalities and systems.
2728
%%
2829
%% Examples
2930
%% @example
@@ -83,11 +84,23 @@
8384
%% @end group
8485
%% @end example
8586
%%
87+
%% You can solve inequalities and systems involving mixed
88+
%% inequalities and equations. For example:
89+
%% @example
90+
%% @group
91+
%% solve(x^2 == 4, x > 0)
92+
%% @result{} ans = (sym) x = 2
93+
%% @end group
94+
%%
95+
%% @group
96+
%% solve(x^2 - 1 > 0, x < 10)
97+
%% @result{} ans = (sym) (-∞ < x ∧ x < -1) ∨ (1 < x ∧ x < 10)
98+
%% @end group
99+
%% @end example
100+
%%
86101
%% @seealso{@@sym/eq, @@sym/dsolve}
87102
%% @end deftypemethod
88103

89-
%% Author: Colin B. Macdonald, Andrés Prieto
90-
%% Keywords: symbolic
91104

92105
function varargout = solve(varargin)
93106

@@ -100,18 +113,14 @@
100113
' eqs.append(arg)'
101114
' else:'
102115
' symbols.append(arg)'
103-
'#'
104-
'if len(symbols) > 0:'
105-
' d = sp.solve(eqs, symbols, dict=True)'
106-
'else:'
107-
' d = sp.solve(eqs, dict=True)'
108-
'#'
116+
'd = sp.solve(eqs, *symbols, dict=True)'
117+
'if not isinstance(d, (list, tuple)):' % https://github.com/sympy/sympy/issues/11661
118+
' return d,'
109119
'if len(d) >= 1 and len(d[0].keys()) == 1:' % one variable...
110120
' if len(d) == 1:' % one variable, single solution
111121
' return d[0].popitem()[1],'
112122
' else:' % one variable, multiple solutions
113123
' return sp.Matrix([r.popitem()[1] for r in d]),'
114-
'#'
115124
'if len(d) == 1:'
116125
' d = d[0]'
117126
'return d,' };
@@ -127,16 +136,14 @@
127136
' eqs.append(arg)'
128137
' else:'
129138
' symbols.append(arg)'
130-
'#'
131-
'if len(symbols) > 0:'
132-
' (vars, solns) = sp.solve(eqs, symbols, set=True)'
133-
'else:'
134-
' (vars, solns) = sp.solve(eqs, set=True)'
135-
'#'
136-
'd = []'
139+
'd = sp.solve(eqs, *symbols, set=True)'
140+
'if not isinstance(d, (list, tuple)):' % https://github.com/sympy/sympy/issues/11661
141+
' return d,'
142+
'(vars, solns) = d'
143+
'q = []'
137144
'for (i, var) in enumerate(vars):'
138-
' d.append(sp.Matrix([t[i] for t in solns]))'
139-
'return d,' };
145+
' q.append(sp.Matrix([t[i] for t in solns]))'
146+
'return q,' };
140147

141148
out = python_cmd (cmd, varargin{:});
142149

@@ -230,6 +237,11 @@
230237
%! assert (isequal (X, [2; -2]))
231238
%! assert (isequal (Y, [1; -1]))
232239

240+
%!test
241+
%! syms x
242+
%! a = solve(2*x >= 10, 10*x <= 50);
243+
%! assert (isequal( a, x==sym(5)))
244+
233245
%!error
234246
%! syms a b
235247
%! solve(a==b, 1==1)

0 commit comments

Comments
 (0)