@@ -151,9 +151,9 @@ function N(b::BasicType)
151151 out = evalf (b)
152152 imag (out) == Basic (0.0 ) ? real (out) : out
153153end
154-
155154
156- # # Conversions SymEngine -> Julia
155+
156+ # # Conversions SymEngine -> Julia
157157function as_numer_denom (x:: Basic )
158158 a, b = Basic (), Basic ()
159159 ccall ((:basic_as_numer_denom , libsymengine), Nothing, (Ref{Basic}, Ref{Basic}, Ref{Basic}), a, b, x)
@@ -175,6 +175,11 @@ imag(x::BasicType{Val{:RealMPFR}}) = Basic(0)
175175imag (x:: BasicType{Val{:Rational}} ) = Basic (0 )
176176imag (x:: SymEngine.BasicType ) = throw (InexactError ())
177177
178+ # Because of the definitions above, `real(x) == x` for `x::Basic`
179+ # such as `x = symbols("x")`. Thus, it is consistent to define the
180+ # fallback
181+ Base. conj (x:: Basic ) = 2 * real (x) - x
182+
178183# # define convert(T, x) methods leveraging N()
179184convert (:: Type{Float64} , x:: Basic ) = convert (Float64, N (evalf (x, 53 , true )))
180185convert (:: Type{BigFloat} , x:: Basic ) = convert (BigFloat, N (evalf (x, precision (BigFloat), true )))
@@ -203,7 +208,7 @@ isless(x::Basic, y::Basic) = isless(N(x), N(y))
203208
204209
205210# # These should have support in symengine-wrapper, but currently don't
206- trunc (x:: Basic , args... ) = Basic (trunc (N (x), args... ))
211+ trunc (x:: Basic , args... ) = Basic (trunc (N (x), args... ))
207212trunc (:: Type{T} ,x:: Basic , args... ) where {T <: Integer } = convert (T, trunc (x,args... ))
208213
209214ceil (x:: Basic ) = Basic (ceil (N (x)))
0 commit comments