manpagez: man pages & more
info ginac
Home | html | info | man
[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

4.11 Relations

Sometimes, a relation holding between two expressions must be stored somehow. The class relational is a convenient container for such purposes. A relation is by definition a container for two ex and a relation between them that signals equality, inequality and so on. They are created by simply using the C++ operators ==, !=, <, <=, > and >= between two expressions.

See section Mathematical functions, for examples where various applications of the .subs() method show how objects of class relational are used as arguments. There they provide an intuitive syntax for substitutions. They are also used as arguments to the ex::series method, where the left hand side of the relation specifies the variable to expand in and the right hand side the expansion point. They can also be used for creating systems of equations that are to be solved for unknown variables. But the most common usage of objects of this class is rather inconspicuous in statements of the form if (expand(pow(a+b,2))==a*a+2*a*b+b*b) {...}. Here, an implicit conversion from relational to bool takes place. Note, however, that == here does not perform any simplifications, hence expand() must be called explicitly.


© manpagez.com 2000-2024
Individual documents may contain additional copyright information.