Skip to content

Commit

Permalink
workaround for old sympy, new Python
Browse files Browse the repository at this point in the history
  • Loading branch information
cbm755 committed Nov 12, 2024
1 parent cf6a94e commit bc57c62
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion inst/@sym/expm.m
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
%% Copyright (C) 2014-2016, 2019 Colin B. Macdonald
%% Copyright (C) 2014-2016, 2019, 2024 Colin B. Macdonald
%%
%% This file is part of OctSymPy.
%%
Expand Down Expand Up @@ -61,27 +61,35 @@

%!test
%! % scalar
%! if (pycall_sympy__ ('return Version(spver) >= Version("1.9")'))
%! syms x
%! assert (isequal (expm(x), exp(x)))
%! end

%!test
%! % diagonal
%! if (pycall_sympy__ ('return Version(spver) >= Version("1.9")'))
%! A = [sym(1) 0; 0 sym(3)];
%! B = [exp(sym(1)) 0; 0 exp(sym(3))];
%! assert (isequal (expm(A), B))
%! end

%!test
%! % diagonal w/ x
%! if (pycall_sympy__ ('return Version(spver) >= Version("1.9")'))
%! syms x positive
%! A = [sym(1) 0; 0 x+2];
%! B = [exp(sym(1)) 0; 0 exp(x+2)];
%! assert (isequal (expm(A), B))
%! end

%!test
%! % non-diagonal
%! if (pycall_sympy__ ('return Version(spver) >= Version("1.9")'))
%! syms x positive
%! A = [sym(1) 2; 0 x+2];
%! B = expm(A);
%! C = double(subs(B, x, 4));
%! D = expm(double(subs(A, x, 4)));
%! assert (max (max (abs (C - D))) <= 1e-11)
%! end

0 comments on commit bc57c62

Please sign in to comment.