Skip to content

Commit 0ec5c9c

Browse files
authored
Merge pull request #267 from GiggleLiu/jg/fix-conj
Make conj interface more flexible
2 parents 90e42f3 + 2b8f514 commit 0ec5c9c

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/numerics.jl

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import Base: convert, real, imag, float, eps
1+
import Base: convert, real, imag, float, eps, conj
22
import Base: isfinite, isnan, isinf, isless
33
import Base: trunc, ceil, floor, round
44

@@ -177,8 +177,9 @@ imag(x::SymEngine.BasicType) = throw(InexactError())
177177

178178
# Because of the definitions above, `real(x) == x` for `x::Basic`
179179
# such as `x = symbols("x")`. Thus, it is consistent to define the
180-
# fallback
181-
Base.conj(x::Basic) = 2 * real(x) - x
180+
conj(x::Basic) = Basic(conj(SymEngine.BasicType(x)))
181+
# To allow future extension, we define the fallback on `BasicType``.
182+
conj(x::BasicType) = 2 * real(x.x) - x.x
182183

183184
## define convert(T, x) methods leveraging N()
184185
convert(::Type{Float64}, x::Basic) = convert(Float64, N(evalf(x, 53, true)))

0 commit comments

Comments
 (0)