infinity.h
Go to the documentation of this file.
1 
6 #ifndef SYMENGINE_INFINITY_H
7 #define SYMENGINE_INFINITY_H
8 
9 #include <symengine/basic.h>
10 #include <symengine/number.h>
11 #include <symengine/integer.h>
12 #include <symengine/mul.h>
13 
14 namespace SymEngine
15 {
16 
20 class Infty : public Number
21 {
22  RCP<const Number> _direction;
23 
24 public:
25  IMPLEMENT_TYPEID(SYMENGINE_INFTY)
27  Infty(const RCP<const Number> &direction);
29  Infty(const Infty &inf);
30  static RCP<const Infty> from_direction(const RCP<const Number> &direction);
32  static RCP<const Infty> from_int(const int val);
33 
35  bool is_canonical(const RCP<const Number> &num) const;
37  hash_t __hash__() const override;
38 
43  // Implement these
44  bool __eq__(const Basic &o) const override;
45  int compare(const Basic &o) const override;
46 
47  vec_basic get_args() const override
48  {
49  return {_direction};
50  }
51 
53  inline bool is_zero() const override
54  {
55  return false;
56  }
58  inline bool is_one() const override
59  {
60  return false;
61  }
63  inline bool is_minus_one() const override
64  {
65  return false;
66  }
67 
69  inline bool is_exact() const override
70  {
71  return false;
72  }
73  // //! Get `Evaluate` singleton to evaluate numerically
74  Evaluate &get_eval() const override;
75 
76  inline RCP<const Number> get_direction() const
77  {
78  return _direction;
79  }
80 
81  bool is_unsigned_infinity() const;
82  bool is_positive_infinity() const;
83  bool is_negative_infinity() const;
84 
85  inline bool is_positive() const override
86  {
87  return is_positive_infinity();
88  }
89 
90  inline bool is_negative() const override
91  {
92  return is_negative_infinity();
93  }
94 
95  inline bool is_complex() const override
96  {
97  return is_unsigned_infinity();
98  }
100  RCP<const Basic> conjugate() const override;
101 
102  // Think about it again
103  RCP<const Number> add(const Number &other) const override;
104  RCP<const Number> mul(const Number &other) const override;
105  RCP<const Number> div(const Number &other) const override;
106  RCP<const Number> pow(const Number &other) const override;
107  RCP<const Number> rpow(const Number &other) const override;
108 };
109 
110 inline RCP<const Infty> infty(int n = 1)
111 {
112  return make_rcp<Infty>(integer(n));
113 }
114 
115 RCP<const Infty> infty(const RCP<const Number> &direction);
116 
117 } // namespace SymEngine
118 #endif
The base class for SymEngine.
#define IMPLEMENT_TYPEID(SYMENGINE_ID)
Inline members and functions.
Definition: basic.h:340
The lowest unit of symbolic representation.
Definition: basic.h:97
A class that will evaluate functions numerically.
Definition: number.h:200
RCP< const Number > pow(const Number &other) const override
Power.
Definition: infinity.cpp:146
bool __eq__(const Basic &o) const override
Definition: infinity.cpp:58
RCP< const Number > div(const Number &other) const override
Division.
Definition: infinity.cpp:132
bool is_negative() const override
Definition: infinity.h:90
hash_t __hash__() const override
Definition: infinity.cpp:51
bool is_canonical(const RCP< const Number > &num) const
Canonical when the direction is -1, 0 or 1.
Definition: infinity.cpp:40
Evaluate & get_eval() const override
Get Evaluate singleton to evaluate numerically.
Definition: infinity.cpp:531
bool is_positive() const override
Definition: infinity.h:85
bool is_one() const override
Definition: infinity.h:58
static RCP< const Infty > from_int(const int val)
Constructs Infty using sign of val
Definition: infinity.cpp:33
bool is_minus_one() const override
Definition: infinity.h:63
RCP< const Number > mul(const Number &other) const override
Multiplication.
Definition: infinity.cpp:113
vec_basic get_args() const override
Returns the list of arguments.
Definition: infinity.h:47
RCP< const Basic > conjugate() const override
Definition: infinity.cpp:90
int compare(const Basic &o) const override
Definition: infinity.cpp:68
Infty(const RCP< const Number > &direction)
Constructs Infty using the sign of _direction
Definition: infinity.cpp:14
bool is_exact() const override
Definition: infinity.h:69
bool is_zero() const override
Definition: infinity.h:53
bool is_complex() const override
Definition: infinity.h:95
RCP< const Number > add(const Number &other) const override
Addition.
Definition: infinity.cpp:98
Main namespace for SymEngine package.
Definition: add.cpp:19
std::enable_if< std::is_integral< T >::value, RCP< const Integer > >::type integer(T i)
Definition: integer.h:197