@@ -212,6 +212,51 @@ isnan(x::Basic) = ( x == NAN )
212212isinf (x:: Basic ) = ! isnan (x) & ! isfinite (x)
213213isless (x:: Basic , y:: Basic ) = isless (N (x), N (y))
214214
215+ # is_a_functions
216+ # could use metaprogramming here
217+ is_a_Number (x:: Basic ) =
218+ Bool (convert (Int, ccall ((:is_a_Number , libsymengine),
219+ Cuint, (Ref{Basic},), x)))
220+ is_a_Integer (x:: Basic ) =
221+ Bool (convert (Int, ccall ((:is_a_Integer , libsymengine),
222+ Cuint, (Ref{Basic},), x)))
223+ is_a_Rational (x:: Basic ) =
224+ Bool (convert (Int, ccall ((:is_a_Rational , libsymengine),
225+ Cuint, (Ref{Basic},), x)))
226+ is_a_RealDouble (x:: Basic ) =
227+ Bool (convert (Int, ccall ((:is_a_RealDouble , libsymengine),
228+ Cuint, (Ref{Basic},), x)))
229+ is_a_RealMPFR (x:: Basic ) =
230+ Bool (convert (Int, ccall ((:is_a_RealMPFR , libsymengine),
231+ Cuint, (Ref{Basic},), x)))
232+ is_a_Complex (x:: Basic ) =
233+ Bool (convert (Int, ccall ((:is_a_Complex , libsymengine),
234+ Cuint, (Ref{Basic},), x)))
235+ is_a_ComplexDouble (x:: Basic ) =
236+ Bool (convert (Int, ccall ((:is_a_ComplexDouble , libsymengine),
237+ Cuint, (Ref{Basic},), x)))
238+ is_a_ComplexMPC (x:: Basic ) =
239+ Bool (convert (Int, ccall ((:is_a_ComplexMPC , libsymengine),
240+ Cuint, (Ref{Basic},), x)))
241+
242+ Base. isinteger (x:: Basic ) = is_a_Integer (x)
243+ function Base. isreal (x:: Basic )
244+ is_a_Number (x) || return false
245+ is_a_Integer (x) || is_a_Rational (x) || is_a_RealDouble (x) || is_a_RealMPFR (x)
246+ end
247+
248+ # may not allocate; seems more idiomatic than default x == zero(x)
249+ function Base. iszero (x:: Basic )
250+ is_a_Number (x) || return false
251+ x == zero (x)
252+ end
253+
254+ function Base. isone (x:: Basic )
255+ is_a_Number (x) || return false
256+ x == one (x)
257+ end
258+
259+
215260
216261# # These should have support in symengine-wrapper, but currently don't
217262trunc (x:: Basic , args... ) = Basic (trunc (N (x), args... ))
0 commit comments