SymEngine::Integer Class Reference

Integer Class. More...

#include <integer.h>

+ Inheritance diagram for SymEngine::Integer:
+ Collaboration diagram for SymEngine::Integer:

Public Member Functions

void accept (Visitor &v) const override
 
void accept (EvalRealDoubleVisitorFinal &v) const override
 
 Integer (const integer_class &_i)
 Constructor of Integer using integer_class
 
 Integer (integer_class &&_i)
 
hash_t __hash__ () const override
 
bool __eq__ (const Basic &o) const override
 
int compare (const Basic &o) const override
 
signed long int as_int () const
 Convert to int, raise an exception if it does not fit.
 
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.
 
bool is_zero () const override
 
bool is_one () const override
 
bool is_minus_one () const override
 
bool is_positive () const override
 
bool is_negative () const override
 
bool is_complex () const override
 
RCP< const Integeraddint (const Integer &other) const
 Fast Integer Addition.
 
RCP< const Integersubint (const Integer &other) const
 Fast Integer Subtraction.
 
RCP< const Integermulint (const Integer &other) const
 Fast Integer Multiplication.
 
RCP< const Numberdivint (const Integer &other) const
 Integer Division.
 
RCP< const Numberpow_negint (const Integer &other) const
 Fast Negative Power Evaluation.
 
RCP< const Numberpowint (const Integer &other) const
 Fast Power Evaluation.
 
RCP< const Integerneg () const
 
RCP< const Numberadd (const Number &other) const override
 Slower Addition.
 
RCP< const Numbersub (const Number &other) const override
 Slower Subtraction.
 
RCP< const Numberrsub (const Number &other) const override
 
RCP< const Numbermul (const Number &other) const override
 Slower Multiplication.
 
RCP< const Numberdiv (const Number &other) const override
 Slower Division.
 
RCP< const Numberrdiv (const Number &other) const override
 
RCP< const Numberpow (const Number &other) const override
 Slower power evaluation.
 
RCP< const Numberrpow (const Number &other) const override
 
- Public Member Functions inherited from SymEngine::Number
virtual RCP< const Basicconjugate () const
 
virtual bool is_exact () const
 return true if the number is an exact representation
 
bool is_exact_zero () const
 
virtual Evaluateget_eval () const
 Get Evaluate singleton to evaluate numerically.
 
vec_basic get_args () const override
 Returns the list of arguments.
 
virtual bool is_perfect_power (bool is_expected=false) const
 
virtual bool nth_root (const Ptr< RCP< const Number >> &, unsigned long n) const
 
- Public Member Functions inherited from SymEngine::Basic
TypeID get_type_code () const
 
 Basic ()
 Constructor.
 
 Basic (const Basic &)=delete
 Delete the copy constructor and assignment.
 
Basicoperator= (const Basic &)=delete
 Assignment operator in continuation with above.
 
 Basic (Basic &&)=delete
 Delete the move constructor and assignment.
 
Basicoperator= (Basic &&)=delete
 Assignment operator in continuation with above.
 
hash_t hash () const
 
bool __neq__ (const Basic &o) const
 true if this is not equal to o. More...
 
int __cmp__ (const Basic &o) const
 Comparison operator.
 
std::string __str__ () const
 
std::string dumps () const
 Returns a string of the instance serialized.
 
RCP< const Basicsubs (const map_basic_basic &subs_dict) const
 Substitutes 'subs_dict' into 'self'.
 
RCP< const Basicxreplace (const map_basic_basic &subs_dict) const
 
virtual RCP< const Basicexpand_as_exp () const
 expands the special function in terms of exp function
 
RCP< const Basicdiff (const RCP< const Symbol > &x, bool cache=true) const
 
- Public Member Functions inherited from SymEngine::EnableRCPFromThis< Basic >
RCP< Basicrcp_from_this ()
 Get RCP<T> pointer to self (it will cast the pointer to T)
 
RCP< const Basicrcp_from_this () const
 Get RCP<const T> pointer to self (it will cast the pointer to const T)
 
RCP< const T2 > rcp_from_this_cast () const
 Get RCP<T2> pointer to self (it will cast the pointer to T2)
 
unsigned int use_count () const
 

Static Public Attributes

static const TypeID type_code_id = SYMENGINE_INTEGER
 

Private Attributes

integer_class i
 i : object of integer_class
 

Additional Inherited Members

- Static Public Member Functions inherited from SymEngine::Basic
static RCP< const Basicloads (const std::string &)
 Creates an instance of a serialized string.
 
- Data Fields inherited from SymEngine::Basic
TypeID type_code_
 

Detailed Description

Integer Class.

Definition at line 18 of file integer.h.

Member Function Documentation

◆ __eq__()

bool SymEngine::Integer::__eq__ ( const Basic o) const
overridevirtual

Equality comparator

Parameters
o- Object to be compared with
Returns
whether the 2 objects are equal

Implements SymEngine::Basic.

Definition at line 16 of file integer.cpp.

17 {
18  if (is_a<Integer>(o)) {
19  const Integer &s = down_cast<const Integer &>(o);
20  return this->i == s.i;
21  }
22  return false;
23 }
Integer(const integer_class &_i)
Constructor of Integer using integer_class
Definition: integer.h:28
integer_class i
i : object of integer_class
Definition: integer.h:22

◆ __hash__()

hash_t SymEngine::Integer::__hash__ ( ) const
overridevirtual
Returns
size of the hash

Implements SymEngine::Basic.

Definition at line 9 of file integer.cpp.

10 {
11  // only the least significant bits that fit into "long long int" are
12  // hashed:
13  return ((hash_t)mp_get_ui(this->i)) * (hash_t)(mp_sign(this->i));
14 }

◆ compare()

int SymEngine::Integer::compare ( const Basic o) const
overridevirtual

Returns -1, 0, 1 for this < o, this == o, this > o. This method is used when you want to sort things like x+y+z into canonical order. This function assumes that o is the same type as this. Use __cmp__ if you want general comparison.

Implements SymEngine::Basic.

Definition at line 25 of file integer.cpp.

26 {
27  SYMENGINE_ASSERT(is_a<Integer>(o))
28  const Integer &s = down_cast<const Integer &>(o);
29  if (i == s.i)
30  return 0;
31  return i < s.i ? -1 : 1;
32 }

◆ is_complex()

bool SymEngine::Integer::is_complex ( ) const
inlineoverridevirtual
Returns
false

Implements SymEngine::Number.

Definition at line 76 of file integer.h.

77  {
78  return false;
79  }

◆ is_minus_one()

bool SymEngine::Integer::is_minus_one ( ) const
inlineoverridevirtual
Returns
true if -1

Implements SymEngine::Number.

Definition at line 60 of file integer.h.

61  {
62  return this->i == -1;
63  }

◆ is_negative()

bool SymEngine::Integer::is_negative ( ) const
inlineoverridevirtual
Returns
true if negative

Implements SymEngine::Number.

Definition at line 70 of file integer.h.

71  {
72  return this->i < 0u;
73  }

◆ is_one()

bool SymEngine::Integer::is_one ( ) const
inlineoverridevirtual
Returns
true if 1

Implements SymEngine::Number.

Definition at line 55 of file integer.h.

56  {
57  return this->i == 1u;
58  }

◆ is_positive()

bool SymEngine::Integer::is_positive ( ) const
inlineoverridevirtual
Returns
true if positive

Implements SymEngine::Number.

Definition at line 65 of file integer.h.

66  {
67  return this->i > 0u;
68  }

◆ is_zero()

bool SymEngine::Integer::is_zero ( ) const
inlineoverridevirtual
Returns
true if 0

Implements SymEngine::Number.

Definition at line 50 of file integer.h.

51  {
52  return this->i == 0u;
53  }

◆ neg()

RCP<const Integer> SymEngine::Integer::neg ( ) const
inline
Returns
negative of self.

Definition at line 116 of file integer.h.

117  {
118  return make_rcp<const Integer>(-i);
119  }

Field Documentation

◆ type_code_id

const TypeID SymEngine::Integer::type_code_id = SYMENGINE_INTEGER
static

Type_code_id shared by all instances

Definition at line 25 of file integer.h.


The documentation for this class was generated from the following files: