Loading...
Searching...
No Matches
SymEngine::Expression Class Reference
+ Collaboration diagram for SymEngine::Expression:

Public Member Functions

 Expression ()
 Plain constructor of Expression.
 
template<class T >
 Expression (T n, typename std::enable_if< std::is_integral< T >::value >::type *=nullptr)
 Construct Expression from integral types.
 
template<class T >
 Expression (T n, typename std::enable_if< std::is_floating_point< T >::value >::type *=nullptr)
 Construct Expression from floating point types.
 
template<class T >
 Expression (std::complex< T > n, typename std::enable_if< std::is_floating_point< T >::value >::type *=nullptr)
 Construct Expression from std::complex<> types.
 
 Expression (const integer_class &n)
 
 Expression (const rational_class &n)
 
 Expression (RCP< const Basic > &&o)
 
 Expression (const RCP< const Basic > &o)
 
 Expression (const std::string &s)
 
 Expression (const Expression &)=default
 Construct Expression from Expression.
 
 Expression (Expression &&other) SYMENGINE_NOEXCEPT
 Construct Expression from reference to Expression.
 
Expressionoperator= (const Expression &)=default
 Overload assignment operator.
 
Expressionoperator= (Expression &&other) SYMENGINE_NOEXCEPT
 Overload assignment operator for reference.
 
virtual ~Expression () SYMENGINE_NOEXCEPT
 Destructor of Expression.
 
Expressionoperator+= (const Expression &other)
 Overload addition and assignment(+=)
 
Expressionoperator+= (const RCP< const Basic > &other)
 
 operator const RCP< const Basic > & () const
 
Expression diff (const RCP< const Symbol > &x, bool cache=true) const
 Differentiation.
 
Expression diff (const RCP< const Basic > &x, bool cache=true) const
 Differentiation.
 
Expression subs (const map_basic_basic &subs_map) const
 Substitution.
 
template<typename T , typename = typename std::enable_if<std::is_arithmetic<T>::value>::type>
 operator T () const
 Evaluation to a floating point type.
 
template<typename T , typename = typename std::enable_if<std::is_arithmetic<T>::value>::type>
 operator std::complex< T > () const
 Evaluation to a complex floating point type.
 
 operator const Basic & () const
 
Expression operator- () const
 Overload unary negative.
 
Expressionoperator-= (const Expression &other)
 Overload subtraction and assignment(-=)
 
Expressionoperator-= (const RCP< const Basic > &other)
 
Expressionoperator*= (const Expression &other)
 Overload multiplication and assignment (*=)
 
Expressionoperator*= (const RCP< const Basic > &other)
 
Expressionoperator/= (const Expression &other)
 Overload Division and assignment (/=)
 
Expressionoperator/= (const RCP< const Basic > &other)
 
bool operator== (const Expression &other) const
 Overload check equality (==)
 
bool operator== (const RCP< const Basic > &other) const
 
bool operator!= (const Expression &other) const
 Overload check not equal (!=)
 
bool operator!= (const RCP< const Basic > &other) const
 
const RCP< const Basic > & get_basic () const
 Method to get Basic from Expression.
 

Private Attributes

RCP< const Basicm_basic
 

Friends

std::ostreamoperator<< (std::ostream &os, const Expression &expr)
 Overload stream operator.
 
Expression operator+ (const Expression &a, const Expression &b)
 Overload addition.
 
Expression operator+ (const RCP< const Basic > &a, const Expression &b)
 
Expression operator+ (const Expression &a, const RCP< const Basic > &b)
 
Expression operator- (const Expression &a, const Expression &b)
 Overload subtraction.
 
Expression operator- (const RCP< const Basic > &a, const Expression &b)
 
Expression operator- (const Expression &a, const RCP< const Basic > &b)
 
Expression operator* (const Expression &a, const Expression &b)
 Overload multiplication.
 
Expression operator* (const RCP< const Basic > &a, const Expression &b)
 
Expression operator* (const Expression &a, const RCP< const Basic > &b)
 
Expression operator/ (const Expression &a, const Expression &b)
 Overload Division.
 
Expression operator/ (const RCP< const Basic > &a, const Expression &b)
 
Expression operator/ (const Expression &a, const RCP< const Basic > &b)
 

Detailed Description

Definition at line 28 of file expression.h.

Constructor & Destructor Documentation

◆ Expression() [1/10]

SymEngine::Expression::Expression ( )
inline

Plain constructor of Expression.

Definition at line 35 of file expression.h.

35: m_basic(integer(0)) {}
std::enable_if< std::is_integral< T >::value, RCP< constInteger > >::type integer(T i)
Definition: integer.h:197

◆ Expression() [2/10]

template<class T >
SymEngine::Expression::Expression ( n,
typename std::enable_if< std::is_integral< T >::value >::type *  = nullptr 
)
inline

Construct Expression from integral types.

Definition at line 38 of file expression.h.

41 : m_basic(integer(n))
42 {
43 }

◆ Expression() [3/10]

template<class T >
SymEngine::Expression::Expression ( n,
typename std::enable_if< std::is_floating_point< T >::value >::type *  = nullptr 
)
inline

Construct Expression from floating point types.

Definition at line 46 of file expression.h.

49 : m_basic(real_double(n))
50 {
51 }

◆ Expression() [4/10]

template<class T >
SymEngine::Expression::Expression ( std::complex< T >  n,
typename std::enable_if< std::is_floating_point< T >::value >::type *  = nullptr 
)
inline

Construct Expression from std::complex<> types.

Definition at line 54 of file expression.h.

57 : m_basic(complex_double(n))
58 {
59 }

◆ Expression() [5/10]

SymEngine::Expression::Expression ( const integer_class &  n)
inline

Definition at line 61 of file expression.h.

61: m_basic(integer(n)) {}

◆ Expression() [6/10]

SymEngine::Expression::Expression ( const rational_class &  n)
inline

Definition at line 63 of file expression.h.

63: m_basic(Rational::from_mpq(n)) {}
static RCP< const Number > from_mpq(const rational_class &i)
Definition: rational.cpp:23

◆ Expression() [7/10]

SymEngine::Expression::Expression ( RCP< const Basic > &&  o)
inline

Definition at line 65 of file expression.h.

65: m_basic(o) {}

◆ Expression() [8/10]

SymEngine::Expression::Expression ( const RCP< const Basic > &  o)
inline

Definition at line 67 of file expression.h.

67: m_basic(o) {}

◆ Expression() [9/10]

SymEngine::Expression::Expression ( const std::string s)

Definition at line 19 of file expression.cpp.

20{
21 m_basic = parse(s);
22}

◆ Expression() [10/10]

SymEngine::Expression::Expression ( Expression &&  other)
inline

Construct Expression from reference to Expression.

Definition at line 74 of file expression.h.

75 : m_basic(std::move(other.m_basic))
76 {
77 }
T move(T... args)

◆ ~Expression()

virtual SymEngine::Expression::~Expression ( )
inlinevirtual

Destructor of Expression.

Definition at line 89 of file expression.h.

89{}

Member Function Documentation

◆ diff() [1/2]

Expression SymEngine::Expression::diff ( const RCP< const Basic > &  x,
bool  cache = true 
) const
inline

Differentiation.

Definition at line 143 of file expression.h.

144 {
145 return Expression(sdiff(m_basic, x, cache));
146 }
Expression()
Plain constructor of Expression.
Definition: expression.h:35

◆ diff() [2/2]

Expression SymEngine::Expression::diff ( const RCP< const Symbol > &  x,
bool  cache = true 
) const
inline

Differentiation.

Definition at line 138 of file expression.h.

139 {
140 return Expression(SymEngine::diff(m_basic, x, cache));
141 }

◆ get_basic()

const RCP< const Basic > & SymEngine::Expression::get_basic ( ) const
inline

Method to get Basic from Expression.

Definition at line 259 of file expression.h.

260 {
261 return m_basic;
262 }

◆ operator const Basic &()

SymEngine::Expression::operator const Basic & ( ) const
inline

Definition at line 168 of file expression.h.

169 {
170 return *m_basic;
171 }

◆ operator const RCP< const Basic > &()

SymEngine::Expression::operator const RCP< const Basic > & ( ) const
inline

Definition at line 133 of file expression.h.

134 {
135 return m_basic;
136 }

◆ operator std::complex< T >()

template<typename T , typename = typename std::enable_if<std::is_arithmetic<T>::value>::type>
SymEngine::Expression::operator std::complex< T > ( ) const
inlineexplicit

Evaluation to a complex floating point type.

Definition at line 164 of file expression.h.

165 {
166 return std::complex<T>(eval_complex_double(*get_basic()));
167 }
const RCP< const Basic > & get_basic() const
Method to get Basic from Expression.
Definition: expression.h:259

◆ operator T()

template<typename T , typename = typename std::enable_if<std::is_arithmetic<T>::value>::type>
SymEngine::Expression::operator T ( ) const
inlineexplicit

Evaluation to a floating point type.

Definition at line 156 of file expression.h.

157 {
158 return T(eval_double(*get_basic()));
159 }

◆ operator!=() [1/2]

bool SymEngine::Expression::operator!= ( const Expression other) const
inline

Overload check not equal (!=)

Definition at line 249 of file expression.h.

250 {
251 return not(*this == other);
252 }

◆ operator!=() [2/2]

bool SymEngine::Expression::operator!= ( const RCP< const Basic > &  other) const
inline

Definition at line 253 of file expression.h.

254 {
255 return not(*this == other);
256 }

◆ operator*=() [1/2]

Expression & SymEngine::Expression::operator*= ( const Expression other)
inline

Overload multiplication and assignment (*=)

Definition at line 204 of file expression.h.

205 {
206 m_basic = mul(m_basic, other.m_basic);
207 return *this;
208 }
RCP< const Basic > mul(const RCP< const Basic > &a, const RCP< const Basic > &b)
Multiplication.
Definition: mul.cpp:352

◆ operator*=() [2/2]

Expression & SymEngine::Expression::operator*= ( const RCP< const Basic > &  other)
inline

Definition at line 209 of file expression.h.

210 {
211 m_basic = mul(m_basic, other);
212 return *this;
213 }

◆ operator+=() [1/2]

Expression & SymEngine::Expression::operator+= ( const Expression other)
inline

Overload addition and assignment(+=)

Definition at line 110 of file expression.h.

111 {
112 m_basic = add(m_basic, other.m_basic);
113 return *this;
114 }
RCP< const Basic > add(const RCP< const Basic > &a, const RCP< const Basic > &b)
Adds two objects (safely).
Definition: add.cpp:425

◆ operator+=() [2/2]

Expression & SymEngine::Expression::operator+= ( const RCP< const Basic > &  other)
inline

Definition at line 115 of file expression.h.

116 {
117 m_basic = add(m_basic, other);
118 return *this;
119 }

◆ operator-()

Expression SymEngine::Expression::operator- ( ) const
inline

Overload unary negative.

Definition at line 173 of file expression.h.

174 {
175 Expression retval(*this);
176 retval *= -1;
177 return retval;
178 }

◆ operator-=() [1/2]

Expression & SymEngine::Expression::operator-= ( const Expression other)
inline

Overload subtraction and assignment(-=)

Definition at line 180 of file expression.h.

181 {
182 m_basic = sub(m_basic, other.m_basic);
183 return *this;
184 }
RCP< const Basic > sub(const RCP< const Basic > &a, const RCP< const Basic > &b)
Substracts b from a.
Definition: add.cpp:495

◆ operator-=() [2/2]

Expression & SymEngine::Expression::operator-= ( const RCP< const Basic > &  other)
inline

Definition at line 185 of file expression.h.

186 {
187 m_basic = sub(m_basic, other);
188 return *this;
189 }

◆ operator/=() [1/2]

Expression & SymEngine::Expression::operator/= ( const Expression other)
inline

Overload Division and assignment (/=)

Definition at line 228 of file expression.h.

229 {
230 m_basic = div(m_basic, other.m_basic);
231 return *this;
232 }
RCP< const Basic > div(const RCP< const Basic > &a, const RCP< const Basic > &b)
Division.
Definition: mul.cpp:431

◆ operator/=() [2/2]

Expression & SymEngine::Expression::operator/= ( const RCP< const Basic > &  other)
inline

Definition at line 233 of file expression.h.

234 {
235 m_basic = div(m_basic, other);
236 return *this;
237 }

◆ operator=()

Expression & SymEngine::Expression::operator= ( Expression &&  other)
inline

Overload assignment operator for reference.

Definition at line 81 of file expression.h.

82 {
83 if (this != &other) {
84 this->m_basic = std::move(other.m_basic);
85 }
86 return *this;
87 }

◆ operator==() [1/2]

bool SymEngine::Expression::operator== ( const Expression other) const
inline

Overload check equality (==)

Definition at line 239 of file expression.h.

240 {
241 return eq(*m_basic, *other.m_basic);
242 }
bool eq(const Basic &a, const Basic &b)
Checks equality for a and b
Definition: basic-inl.h:21

◆ operator==() [2/2]

bool SymEngine::Expression::operator== ( const RCP< const Basic > &  other) const
inline

Definition at line 243 of file expression.h.

244 {
245 return eq(*m_basic, *other);
246 }

◆ subs()

Expression SymEngine::Expression::subs ( const map_basic_basic subs_map) const
inline

Substitution.

Definition at line 148 of file expression.h.

149 {
150 return Expression(m_basic->subs(subs_map));
151 }

Friends And Related Function Documentation

◆ operator* [1/3]

Expression operator* ( const Expression a,
const Expression b 
)
friend

Overload multiplication.

Definition at line 191 of file expression.h.

192 {
193 return Expression(mul(a.m_basic, b.m_basic));
194 }

◆ operator* [2/3]

Expression operator* ( const Expression a,
const RCP< const Basic > &  b 
)
friend

Definition at line 199 of file expression.h.

200 {
201 return Expression(mul(a.m_basic, b));
202 }

◆ operator* [3/3]

Expression operator* ( const RCP< const Basic > &  a,
const Expression b 
)
friend

Definition at line 195 of file expression.h.

196 {
197 return Expression(mul(a, b.m_basic));
198 }

◆ operator+ [1/3]

Expression operator+ ( const Expression a,
const Expression b 
)
friend

Overload addition.

Definition at line 97 of file expression.h.

98 {
99 return Expression(add(a.m_basic, b.m_basic));
100 }

◆ operator+ [2/3]

Expression operator+ ( const Expression a,
const RCP< const Basic > &  b 
)
friend

Definition at line 105 of file expression.h.

106 {
107 return Expression(add(a.m_basic, b));
108 }

◆ operator+ [3/3]

Expression operator+ ( const RCP< const Basic > &  a,
const Expression b 
)
friend

Definition at line 101 of file expression.h.

102 {
103 return Expression(add(a, b.m_basic));
104 }

◆ operator- [1/3]

Expression operator- ( const Expression a,
const Expression b 
)
friend

Overload subtraction.

Definition at line 121 of file expression.h.

122 {
123 return Expression(sub(a.m_basic, b.m_basic));
124 }

◆ operator- [2/3]

Expression operator- ( const Expression a,
const RCP< const Basic > &  b 
)
friend

Definition at line 129 of file expression.h.

130 {
131 return Expression(sub(a.m_basic, b));
132 }

◆ operator- [3/3]

Expression operator- ( const RCP< const Basic > &  a,
const Expression b 
)
friend

Definition at line 125 of file expression.h.

126 {
127 return Expression(sub(a, b.m_basic));
128 }

◆ operator/ [1/3]

Expression operator/ ( const Expression a,
const Expression b 
)
friend

Overload Division.

Definition at line 215 of file expression.h.

216 {
217 return Expression(div(a.m_basic, b.m_basic));
218 }

◆ operator/ [2/3]

Expression operator/ ( const Expression a,
const RCP< const Basic > &  b 
)
friend

Definition at line 223 of file expression.h.

224 {
225 return Expression(div(a.m_basic, b));
226 }

◆ operator/ [3/3]

Expression operator/ ( const RCP< const Basic > &  a,
const Expression b 
)
friend

Definition at line 219 of file expression.h.

220 {
221 return Expression(div(a, b.m_basic));
222 }

◆ operator<<

std::ostream & operator<< ( std::ostream os,
const Expression expr 
)
friend

Overload stream operator.

Definition at line 91 of file expression.h.

92 {
93 os << expr.m_basic->__str__();
94 return os;
95 }

Field Documentation

◆ m_basic

RCP<const Basic> SymEngine::Expression::m_basic
private

Definition at line 31 of file expression.h.


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