@@ -151,9 +151,9 @@ function N(b::BasicType)
151
151
out = evalf (b)
152
152
imag (out) == Basic (0.0 ) ? real (out) : out
153
153
end
154
-
155
154
156
- # # Conversions SymEngine -> Julia
155
+
156
+ # # Conversions SymEngine -> Julia
157
157
function as_numer_denom (x:: Basic )
158
158
a, b = Basic (), Basic ()
159
159
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)
175
175
imag (x:: BasicType{Val{:Rational}} ) = Basic (0 )
176
176
imag (x:: SymEngine.BasicType ) = throw (InexactError ())
177
177
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
+
178
183
# # define convert(T, x) methods leveraging N()
179
184
convert (:: Type{Float64} , x:: Basic ) = convert (Float64, N (evalf (x, 53 , true )))
180
185
convert (:: 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))
203
208
204
209
205
210
# # 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... ))
207
212
trunc (:: Type{T} ,x:: Basic , args... ) where {T <: Integer } = convert (T, trunc (x,args... ))
208
213
209
214
ceil (x:: Basic ) = Basic (ceil (N (x)))
0 commit comments