Class Mul¶
Defined in File mul.h
Inheritance Relationships¶
Base Type¶
public SymEngine::Basic(Class Basic)
Class Documentation¶
-
class
SymEngine::Mul: public SymEngine::Basic¶ Mul class keeps a product of symbolic expressions. Internal representation of an Mul is a numeric coefficient
coef_and a dictionarydict_of key-value pairs.Mul(coef_, {{key1, value1}, {key2, value2}, ... })
This represents the following expression,
coef_ * key1^value1 * key2^value2 * ...
coef_is an objecct of type Number, i.e. a numeric coefficient like Integer, RealDouble, Complex.For example, the following are valid representations
Mul(2, {{x, 2}, {y, 5}}) Mul(3, {{x, 1}, {y, 4}, {z, 3}})
Following are invalid representations. (valid equivalent is shown next to them)
When key is a numeric and value is an integers,
Mul(2, {{3, 2}, {x, 2}}) -> Mul(18, {{x, 2}}) Mul(2, {{I, 3}, {x, 2}}) -> Mul(-2*I, {{x, 2}})
When key is an integer and value is a Rational not in the range (0, 1)
Mul(2, {{3, 3/2}, {x, 2}}) -> Mul(6, {{3, 1/2}, {x, 2}}) Mul(2, {{3, -1/2}, {x, 2}}) -> Mul(2/3, {{3, 1/2}, {x, 2}})
When the value is zero
Mul(3, {{x, 0}, {y, 2}}) -> Mul(3, {{y, 2}})
When key and value are numeric and one of them is inexact
Mul(2, {{3, 0.5}, {x, 2}}) -> Mul(3.464…, {x, 2}})
When
coef_is one and the dictionary is of size 1Mul(1, {{x, 2}}) -> Pow(x, 2)
When
coef_is zeroMul(0, {{x, 2}}) -> Integer(0) Mul(0.0, {{x, 2}}) -> RealDouble(0.0)
When key is 1
Mul(2, {{1, x}, {x, 2}}) -> Mul(2, {{x, 2}})
When value is zero
Mul(2, {{1, x}, {x, 2}}) -> Mul(2, {{x, 2}})
Public Functions
-
Mul(const RCP<const Number> &coef, map_basic_basic &&dict)¶ the dictionary of the rest (e.g.
x*yin2*x*y)Constructs Mul from a dictionary by copying the contents of the dictionary:
-
bool
__eq__(const Basic &o) const¶ Equality comparator
- Return
whether the 2 objects are equal
- Parameters
o: - Object to be compared with
-
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+zinto canonical order. This function assumes thatois 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¶ Rewrite as 2 terms.
Example: if this=3*x**2*y**2*z**2
, thena=x**2andb=3*y**2*z**2`
-
void
power_num(const Ptr<RCP<const Number>> &coef, map_basic_basic &d, const RCP<const Number> &exp) const¶ Power all terms with the exponent
exp
-
bool
is_canonical(const RCP<const Number> &coef, const map_basic_basic &dict) const¶ - Return
true if both
coefanddictare in canonical form
-
const map_basic_basic &
get_dict() const¶
Public Static Functions
-
RCP<const Basic>
from_dict(const RCP<const Number> &coef, map_basic_basic &&d)¶ Create a Mul from a dict.
-
void
dict_add_term(map_basic_basic &d, const RCP<const Basic> &exp, const RCP<const Basic> &t)¶ Add terms to dict.
-
void
dict_add_term_new(const Ptr<RCP<const Number>> &coef, map_basic_basic &d, const RCP<const Basic> &exp, const RCP<const Basic> &t)¶
-