[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
5.1.3 Comparing expressions
Expressions can be compared with the usual C++ relational operators like
==
, >
, and <
but if the expressions contain symbols,
the result is usually not determinable and the result will be false
,
except in the case of the !=
operator. You should also be aware that
GiNaC will only do the most trivial test for equality (subtracting both
expressions), so something like (pow(x,2)+x)/x==x+1
will return
false
.
Actually, if you construct an expression like a == b
, this will be
represented by an object of the relational
class (see section Relations)
which is not evaluated until (explicitly or implicitly) cast to a bool
.
There are also two methods
bool ex::is_equal(const ex & other); bool ex::is_zero(); |
for checking whether one expression is equal to another, or equal to zero,
respectively. See also the method ex::is_zero_matrix()
,
see section Matrices.