#include <mul.h>
Public Member Functions | |
void | accept (Visitor &v) const override |
void | accept (EvalRealDoubleVisitorFinal &v) const override |
Mul (const RCP< const Number > &coef, map_basic_basic &&dict) | |
hash_t | __hash__ () const override |
bool | __eq__ (const Basic &o) const override |
int | compare (const Basic &o) const override |
void | as_two_terms (const Ptr< RCP< const Basic >> &a, const Ptr< RCP< const Basic >> &b) const |
Rewrite as 2 terms. More... | |
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 |
vec_basic | get_args () const override |
Returns the list of arguments. | |
const RCP< const Number > & | get_coef () const |
const map_basic_basic & | get_dict () const |
Public Member Functions inherited from SymEngine::Basic | |
TypeID | get_type_code () const |
Basic () | |
Constructor. | |
Basic (const Basic &)=delete | |
Delete the copy constructor and assignment. | |
Basic & | operator= (const Basic &)=delete |
Assignment operator in continuation with above. | |
Basic (Basic &&)=delete | |
Delete the move constructor and assignment. | |
Basic & | operator= (Basic &&)=delete |
Assignment operator in continuation with above. | |
hash_t | hash () const |
bool | __neq__ (const Basic &o) const |
true if this is not equal to o . More... | |
int | __cmp__ (const Basic &o) const |
Comparison operator. | |
std::string | __str__ () const |
std::string | dumps () const |
Returns a string of the instance serialized. | |
RCP< const Basic > | subs (const map_basic_basic &subs_dict) const |
Substitutes 'subs_dict' into 'self'. | |
RCP< const Basic > | xreplace (const map_basic_basic &subs_dict) const |
virtual RCP< const Basic > | expand_as_exp () const |
expands the special function in terms of exp function | |
RCP< const Basic > | diff (const RCP< const Symbol > &x, bool cache=true) const |
Public Member Functions inherited from SymEngine::EnableRCPFromThis< Basic > | |
RCP< Basic > | rcp_from_this () |
Get RCP<T> pointer to self (it will cast the pointer to T) | |
RCP< const Basic > | rcp_from_this () const |
Get RCP<const T> pointer to self (it will cast the pointer to const T) | |
RCP< const T2 > | rcp_from_this_cast () const |
Get RCP<T2> pointer to self (it will cast the pointer to T2) | |
unsigned int | use_count () const |
Static Public Member Functions | |
static RCP< const Basic > | from_dict (const RCP< const Number > &coef, map_basic_basic &&d) |
Create a Mul from a dict. | |
static void | dict_add_term (map_basic_basic &d, const RCP< const Basic > &exp, const RCP< const Basic > &t) |
Add terms to dict. | |
static 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) |
static void | as_base_exp (const RCP< const Basic > &self, const Ptr< RCP< const Basic >> &exp, const Ptr< RCP< const Basic >> &base) |
Convert to a base and exponent form. | |
Static Public Member Functions inherited from SymEngine::Basic | |
static RCP< const Basic > | loads (const std::string &) |
Creates an instance of a serialized string. | |
Static Public Attributes | |
static const TypeID | type_code_id = SYMENGINE_MUL |
the dictionary of the rest (e.g. x*y in 2*x*y ) More... | |
Private Attributes | |
RCP< const Number > | coef_ |
map_basic_basic | dict_ |
The coefficient (e.g. 2 in 2*x*y ) | |
Additional Inherited Members | |
Data Fields inherited from SymEngine::Basic | |
TypeID | type_code_ |
Mul class keeps a product of symbolic expressions. Internal representation of an Mul is a numeric coefficient coef_
and a dictionary dict_
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 1
Mul(1, {{x, 2}}) -> Pow(x, 2)
When coef_
is zero
Mul(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
SymEngine::Mul::Mul | ( | const RCP< const Number > & | coef, |
map_basic_basic && | dict | ||
) |
Constructs Mul from a dictionary by copying the contents of the dictionary:
Definition at line 10 of file mul.cpp.
|
overridevirtual |
Equality comparator
o | - Object to be compared with |
Implements SymEngine::Basic.
Definition at line 89 of file mul.cpp.
|
overridevirtual |
void SymEngine::Mul::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, then
a=x**2and
b=3*y**2*z**2`
Definition at line 309 of file mul.cpp.
|
overridevirtual |
Returns -1, 0, 1 for this < o, this == o, this > o
. This method is used when you want to sort things like x+y+z
into canonical order. This function assumes that o
is the same type as this
. Use __cmp__
if you want general comparison.
Implements SymEngine::Basic.
Definition at line 98 of file mul.cpp.
bool SymEngine::Mul::is_canonical | ( | const RCP< const Number > & | coef, |
const map_basic_basic & | dict | ||
) | const |
coef
and dict
are in canonical form Definition at line 17 of file mul.cpp.
|
static |