Skip to content

Commit bc7af47

Browse files
authored
Adjust complex-valued functionality for DP changes (#300)
* Update for changes discussed in JuliaAlgebra/DynamicPolynomials.jl#121 - Macro for complex variables is now called `@complex_polyvar` - DP does not support partial substitutions, so disable the tests * Add explanation, format
1 parent 05574bb commit bc7af47

File tree

3 files changed

+13
-7
lines changed

3 files changed

+13
-7
lines changed

src/complex.jl

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,9 @@ for fun in [:real, :imag]
186186
iszero(x) &&
187187
return zero(polynomial_type(x, real(coefficient_type(x))))
188188
# We replace every complex variable by its decomposition into real and imaginary part
189-
subst_vars = filter(Base.:! isreal, variables(x))
189+
subst_vars = unique(
190+
ordinary_variable(v) for v in variables(x) if !isreal(v)
191+
)
190192
# To avoid a stack overflow on promote_type, we'll handle the empty case separately
191193
full_version =
192194
isempty(subst_vars) ? polynomial(x) :

test/commutativetests.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ include("polynomial.jl")
99
include("det.jl")
1010

1111
include("rational.jl")
12-
isdefined(Mod, Symbol("@polycvar")) && include("complex.jl")
12+
isdefined(Mod, Symbol("@complex_polyvar")) && include("complex.jl")
1313

1414
include("promote.jl")
1515
include("hash.jl")

test/complex.jl

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
@test isreal(a^3 + 5a^2 + 4a)
1111
@test !isreal(a^3 + 5im * a^2 + 4a)
1212

13-
Mod.@polycvar x y
13+
Mod.@complex_polyvar x y
1414
@test !isreal(x)
1515
@test !isrealpart(x) &&
1616
!isrealpart(conj(x)) &&
@@ -73,9 +73,13 @@
7373

7474
@test subs(4x + 8y^2 - 6x^3, [x, y] => [2 + 4im, 9 - im]) ==
7575
(1176 - 32im) * x^0
76-
@test subs(4x + 8y^2 - 6x^3, [x, conj(y)] => [2 + 4im, 9 - im]) ==
77-
(1176 + 256im) * x^0
76+
# the following are currently not supported by DP (substitution variables may
77+
# only be the ordinary_variable, not a conjugate or real/imaginary part)
78+
@test_broken subs(4x + 8y^2 - 6x^3, [x, conj(y)] => [2 + 4im, 9 - im]) ==
79+
(1176 + 256im) * x^0
7880
@test_broken subs(4x + 8y^2 - 6x^3, [x, real(y)] => [2 + 4im, 9])
79-
@test subs(4x + 8y^2 - 6x^3, [x, real(y)] => [2 + 4im, 9 + 0 * x^0]) ==
80-
1184 + 112im + 144im * imag(y) - 8imag(y)^2
81+
@test_broken subs(
82+
4x + 8y^2 - 6x^3,
83+
[x, real(y)] => [2 + 4im, 9 + 0 * x^0],
84+
) == 1184 + 112im + 144im * imag(y) - 8imag(y)^2
8185
end

0 commit comments

Comments
 (0)