Skip to content

Commit

Permalink
make conj interface more flexible
Browse files Browse the repository at this point in the history
  • Loading branch information
GiggleLiu committed Sep 25, 2023
1 parent 71c1e71 commit 2b8f514
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/numerics.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import Base: convert, real, imag, float, eps
import Base: convert, real, imag, float, eps, conj
import Base: isfinite, isnan, isinf, isless
import Base: trunc, ceil, floor, round

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

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

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

0 comments on commit 2b8f514

Please sign in to comment.