Class Add¶
Defined in File add.h
Inheritance Relationships¶
Base Type¶
public SymEngine::Basic
(Class Basic)
Class Documentation¶
-
class
SymEngine
::
Add
: public SymEngine::Basic¶ Add class keeps an addition of symbolic expressions. Internal representation of an Add is a numeric coefficient
coef_
and a dictionarydict_
of key-value pairs.Add(coef_, {{key1, value1}, {key2, value2}, ... })
This represents the following expression,
coef_ + key1*value1 + key2*value2 + ...
coef_
and the values of dictionary are numeric coefficients like Integer, RealDouble, Complexkey
s can be any symbolic expression except numeric coefficients andMul
objects with coefficient != 1.For example, the following are valid representations
Add(1, {{x, 2}, {y, 5}}) Add(0, {{x, 1}, {y, 4}, {z, 3}})
Following are invalid representations. (valid equivalent is shown next to them)
Add(1, {{x, 1}, {2*y, 3}) -> Add(1, {{x, 1}, {y, 6}}) Add(0, {{x, 2}}) -> Mul(2, {{x, 1}}) Add(1, {{x, 2}, {4, 6}}) -> Add(25, {{x, 2}})
Public Functions
-
Add
(const RCP<const Number> &coef, umap_basic_num &&dict)¶ The dictionary of the rest (e.g.
x+y
in2+x+y
)Constructs Add from a dictionary by copying the contents of the dictionary. Assumes that the input is in canonical form
-
hash_t
__hash__
() const¶ Calculates the hash of the given SymEngine class. Use Basic.hash() which gives a cached version of the hash.
- Return
64-bit integer value for the hash
-
bool
__eq__
(const Basic &o) const¶ true if
this
is equal too
. Deprecated: Use eq(const Basic &a, const Basic &b) non-member method
-
int
compare
(const Basic &o) const¶ Returns -1, 0, 1 for
this < o, this == o, this > o
. This method is used when you want to sort things likex+y+z
into canonical order. This function assumes thato
is the same type asthis
. Use__cmp__
if you want general comparison.
-
void
as_two_terms
(const Ptr<RCP<const Basic>> &a, const Ptr<RCP<const Basic>> &b) const¶ Converts the Add into a sum of two Basic objects and returns them.
-
bool
is_canonical
(const RCP<const Number> &coef, const umap_basic_num &dict) const¶ - Return
true
if a given dictionary and a coefficient is in canonical form
-
vec_basic
get_args
() const¶ Returns the arguments of the Add. For an Add of the form,
Add(coef_, {{key1, value1}, {key2, value2}, ... })
if coef_ is non-zero it returns,
{coef_, key1*value1, key2*value2, ... }
otherwise it returns,
{key1*value1, key2*value2, ... }
- Return
list of arguments
-
const umap_basic_num &
get_dict
() const¶ - Return
const reference to the dictionary of the Add
Public Static Functions
-
RCP<const Basic>
from_dict
(const RCP<const Number> &coef, umap_basic_num &&d)¶ Creates appropriate instance (i.e Add , Symbol, Integer, Mul) depending on the size of dictionary
d
.
-
void
dict_add_term
(umap_basic_num &d, const RCP<const Number> &coef, const RCP<const Basic> &t)¶ Adds
(coeff*t)
to the dictd
-