3 #include <symengine/symengine_exception.h>
4 #include <symengine/symengine_casts.h>
13 return ((hash_t)mp_get_ui(this->
i)) * (hash_t)(mp_sign(this->
i));
18 if (is_a<Integer>(o)) {
19 const Integer &s = down_cast<const Integer &>(o);
20 return this->
i == s.
i;
27 SYMENGINE_ASSERT(is_a<Integer>(o))
28 const Integer &s = down_cast<const Integer &>(o);
31 return i < s.
i ? -1 : 1;
39 if (not(mp_fits_slong_p(this->
i))) {
40 throw SymEngineException(
"as_int: Integer larger than int");
42 return mp_get_si(this->
i);
52 throw SymEngineException(
"as_uint: negative Integer");
54 if (not(mp_fits_ulong_p(this->
i))) {
55 throw SymEngineException(
"as_uint: Integer larger than uint");
57 return mp_get_ui(this->
i);
69 rational_class q(this->
i, other.
i);
78 RCP<const Number> Integer::rdiv(
const Number &other)
const
80 if (is_a<Integer>(other)) {
88 rational_class q((down_cast<const Integer &>(other)).
i, this->i);
96 throw NotImplementedError(
"Not Implemented");
102 RCP<const Number> tmp =
powint(*other.
neg());
103 if (is_a<Integer>(*tmp)) {
104 const integer_class &j = down_cast<const Integer &>(*tmp).i;
105 #
if SYMENGINE_INTEGER_CLASS == SYMENGINE_BOOSTMP
108 rational_class q(integer_class(mp_sign(j)), mp_abs(j));
110 rational_class q(mp_sign(j), mp_abs(j));
114 throw SymEngineException(
"powint returned non-integer");
132 throw SymEngineException(
"i_nth_root: Can not find Zeroth root");
The lowest unit of symbolic representation.
unsigned long int as_uint() const
Convert to uint, raise an exception if it does not fit.
const integer_class & as_integer_class() const
Convert to integer_class.
RCP< const Number > divint(const Integer &other) const
Integer Division.
bool __eq__(const Basic &o) const override
hash_t __hash__() const override
int compare(const Basic &o) const override
RCP< const Number > pow_negint(const Integer &other) const
Fast Negative Power Evaluation.
RCP< const Integer > neg() const
signed long int as_int() const
Convert to int, raise an exception if it does not fit.
RCP< const Number > powint(const Integer &other) const
Fast Power Evaluation.
integer_class i
i : object of integer_class
virtual bool is_zero() const =0
static RCP< const Number > from_mpq(const rational_class &i)
Main namespace for SymEngine package.
std::enable_if< std::is_integral< T >::value, RCP< const Integer > >::type integer(T i)
RCP< const Integer > isqrt(const Integer &n)
Integer Square root.
bool perfect_square(const Integer &n)
Perfect Square.
bool perfect_power(const Integer &n)
Perfect Square.
int i_nth_root(const Ptr< RCP< const Integer >> &r, const Integer &a, unsigned long int n)
Integer nth root.
RCP< const Integer > iabs(const Integer &n)
Integer Absolute value.