SymEngine::Integer Class Reference

Integer Class. More...

#include <integer.h>

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

Public Member Functions

virtual void accept (Visitor &v) const
 
virtual void accept (EvalRealDoubleVisitorFinal &v) const
 
 Integer (const integer_class &_i)
 Constructor of Integer using integer_class
 
 Integer (integer_class &&_i)
 
virtual hash_t __hash__ () const
 
virtual bool __eq__ (const Basic &o) const
 
virtual int compare (const Basic &o) const
 
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.
 
virtual bool is_zero () const
 
virtual bool is_one () const
 
virtual bool is_minus_one () const
 
virtual bool is_positive () const
 
virtual bool is_negative () const
 
virtual bool is_complex () const
 
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
 
virtual RCP< const Numberadd (const Number &other) const
 Slower Addition.
 
virtual RCP< const Numbersub (const Number &other) const
 Slower Subtraction.
 
virtual RCP< const Numberrsub (const Number &other) const
 
virtual RCP< const Numbermul (const Number &other) const
 Slower Multiplication.
 
virtual RCP< const Numberdiv (const Number &other) const
 Slower Division.
 
virtual RCP< const Numberrdiv (const Number &other) const
 
virtual RCP< const Numberpow (const Number &other) const
 Slower power evaluation.
 
virtual RCP< const Numberrpow (const Number &other) const
 
- 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.
 
virtual vec_basic get_args () const
 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
 
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

- 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
virtual

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
virtual
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
virtual

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()

virtual bool SymEngine::Integer::is_complex ( ) const
inlinevirtual
Returns
false

Implements SymEngine::Number.

Definition at line 79 of file integer.h.

80  {
81  return false;
82  }

◆ is_minus_one()

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

Implements SymEngine::Number.

Definition at line 63 of file integer.h.

64  {
65  return this->i == -1;
66  }

◆ is_negative()

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

Implements SymEngine::Number.

Definition at line 73 of file integer.h.

74  {
75  return this->i < 0u;
76  }

◆ is_one()

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

Implements SymEngine::Number.

Definition at line 58 of file integer.h.

59  {
60  return this->i == 1u;
61  }

◆ is_positive()

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

Implements SymEngine::Number.

Definition at line 68 of file integer.h.

69  {
70  return this->i > 0u;
71  }

◆ is_zero()

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

Implements SymEngine::Number.

Definition at line 53 of file integer.h.

54  {
55  return this->i == 0u;
56  }

◆ neg()

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

Definition at line 119 of file integer.h.

120  {
121  return make_rcp<const Integer>(-i);
122  }

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: