SymEngine::Infty Class Reference

#include <infinity.h>

+ Inheritance diagram for SymEngine::Infty:
+ Collaboration diagram for SymEngine::Infty:

Public Member Functions

void accept (Visitor &v) const override
 
void accept (EvalRealDoubleVisitorFinal &v) const override
 
 Infty (const RCP< const Number > &direction)
 Constructs Infty using the sign of _direction
 
 Infty (const Infty &inf)
 Copy Constructor.
 
bool is_canonical (const RCP< const Number > &num) const
 Canonical when the direction is -1, 0 or 1. More...
 
hash_t __hash__ () const override
 
bool __eq__ (const Basic &o) const override
 
int compare (const Basic &o) const override
 
vec_basic get_args () const override
 Returns the list of arguments.
 
bool is_zero () const override
 
bool is_one () const override
 
bool is_minus_one () const override
 
bool is_exact () const override
 
Evaluateget_eval () const override
 Get Evaluate singleton to evaluate numerically.
 
RCP< const Numberget_direction () const
 
bool is_unsigned_infinity () const
 
bool is_positive_infinity () const
 
bool is_negative_infinity () const
 
bool is_positive () const override
 
bool is_negative () const override
 
bool is_complex () const override
 
RCP< const Basicconjugate () const override
 
RCP< const Numberadd (const Number &other) const override
 Addition.
 
RCP< const Numbermul (const Number &other) const override
 Multiplication.
 
RCP< const Numberdiv (const Number &other) const override
 Division.
 
RCP< const Numberpow (const Number &other) const override
 Power.
 
RCP< const Numberrpow (const Number &other) const override
 
- Public Member Functions inherited from SymEngine::Number
bool is_exact_zero () const
 
virtual RCP< const Numbersub (const Number &other) const
 Subtraction.
 
virtual RCP< const Numberrsub (const Number &other) const
 
virtual RCP< const Numberrdiv (const Number &other) const
 
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 Member Functions

static RCP< const Inftyfrom_direction (const RCP< const Number > &direction)
 
static RCP< const Inftyfrom_int (const int val)
 Constructs Infty using sign of val
 
- Static Public Member Functions inherited from SymEngine::Basic
static RCP< const Basicloads (const std::string &)
 Creates an instance of a serialized string.
 

Static Public Attributes

static const TypeID type_code_id = SYMENGINE_INFTY
 

Private Attributes

RCP< const Number_direction
 

Additional Inherited Members

- Data Fields inherited from SymEngine::Basic
TypeID type_code_
 

Detailed Description

This class holds "infinity" It includes a direction (like -infinity).

Definition at line 20 of file infinity.h.

Member Function Documentation

◆ __eq__()

bool SymEngine::Infty::__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 58 of file infinity.cpp.

59 {
60  if (is_a<Infty>(o)) {
61  const Infty &s = down_cast<const Infty &>(o);
62  return eq(*_direction, *(s.get_direction()));
63  }
64 
65  return false;
66 }
Infty(const RCP< const Number > &direction)
Constructs Infty using the sign of _direction
Definition: infinity.cpp:14
bool eq(const Basic &a, const Basic &b)
Checks equality for a and b
Definition: basic-inl.h:21

◆ __hash__()

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

Implements SymEngine::Basic.

Definition at line 51 of file infinity.cpp.

52 {
53  hash_t seed = SYMENGINE_INFTY;
54  hash_combine<Basic>(seed, *_direction);
55  return seed;
56 }

◆ compare()

int SymEngine::Infty::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 68 of file infinity.cpp.

69 {
70  SYMENGINE_ASSERT(is_a<Infty>(o))
71  const Infty &s = down_cast<const Infty &>(o);
72  return _direction->compare(*(s.get_direction()));
73 }

◆ conjugate()

RCP< const Basic > SymEngine::Infty::conjugate ( ) const
overridevirtual
Returns
the conjugate if the class is complex

Reimplemented from SymEngine::Number.

Definition at line 90 of file infinity.cpp.

91 {
92  if (is_positive_infinity() or is_negative_infinity()) {
93  return infty(_direction);
94  }
95  return make_rcp<const Conjugate>(ComplexInf);
96 }

◆ is_canonical()

bool SymEngine::Infty::is_canonical ( const RCP< const Number > &  num) const

Canonical when the direction is -1, 0 or 1.

Returns
true if canonical

Definition at line 40 of file infinity.cpp.

41 {
42  if (is_a<Complex>(*num) || is_a<ComplexDouble>(*num))
43  throw NotImplementedError("Not implemented for all directions");
44 
45  if (num->is_one() || num->is_zero() || num->is_minus_one())
46  return true;
47 
48  return false;
49 }

◆ is_complex()

bool SymEngine::Infty::is_complex ( ) const
inlineoverridevirtual
Returns
true if a complex number

Implements SymEngine::Number.

Definition at line 95 of file infinity.h.

96  {
97  return is_unsigned_infinity();
98  }

◆ is_exact()

bool SymEngine::Infty::is_exact ( ) const
inlineoverridevirtual
Returns
true if this number is an exact number

Reimplemented from SymEngine::Number.

Definition at line 69 of file infinity.h.

70  {
71  return false;
72  }

◆ is_minus_one()

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

Implements SymEngine::Number.

Definition at line 63 of file infinity.h.

64  {
65  return false;
66  }

◆ is_negative()

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

Implements SymEngine::Number.

Definition at line 90 of file infinity.h.

91  {
92  return is_negative_infinity();
93  }

◆ is_one()

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

Implements SymEngine::Number.

Definition at line 58 of file infinity.h.

59  {
60  return false;
61  }

◆ is_positive()

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

Implements SymEngine::Number.

Definition at line 85 of file infinity.h.

86  {
87  return is_positive_infinity();
88  }

◆ is_zero()

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

Implements SymEngine::Number.

Definition at line 53 of file infinity.h.

54  {
55  return false;
56  }

Field Documentation

◆ type_code_id

const TypeID SymEngine::Infty::type_code_id = SYMENGINE_INFTY
static

Type_code_id shared by all instances

Definition at line 25 of file infinity.h.


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