Struct RapidSimplifyVisitor¶
Defined in File expr_algorithms.cpp
Struct Documentation¶
-
struct RapidSimplifyVisitor¶
Public Functions
-
inline bool simplify_product(ExprPtr &expr)¶
simplifies a Product by:
fusing its rational Powers into one, and its Variable factors into one per Variable
flattening subproducts
factoring in constants
- Parameters:
expr – [inout] (shared_ptr to ) a Product
-
inline bool simplify_sum(ExprPtr &expr)¶
simplifies a Sum … generally Sum::{ap,pre}pend simplify automatically, but the user code may transform sums in a way that the same simplifications need to be applied here
Public Static Functions
-
static inline ExprPtr fuse_rational_powers(const Product &product)¶
fuses the Powers of
productwith positive real Constant bases into simplest radical form (see simplest_radical_form()): the rational part of their value is multiplied into the scalar, the rest becomes a single PowerR^(1/D). The scalar itself is never fused in, so the rational part of the value always sits in the scalar and the radicand depends only on the value; numerically equal Products thus hash and compare equal, and terms that differ by a rational factor merge when the Sum is next rebuilt, as by canonicalize() and hence simplify() (rapid_simplify() leaves summands it has just made identical side by side). Powers with negative, complex or Variable bases are left alone, and a Product whose form would exceed the size cap of simplest_radical_form() is left whole, none of its Powers fused.
-
static inline ExprPtr fuse_variable_powers(const Product &product)¶
fuses the factors of
productthat are a Variable or a Power of one into one factor per Variable: the exponents are summed, a bare Variable counting as 1, grouped by label and by the conjugation of the base combined with that of the Power (as in Power::operator*=). A sum of 0 drops the factor, 1 gives the bare Variable, anything else a Power of the Variable, with the conjugation on the Variable in either case, so(x^2)*becomes(x*)^2. Fused factors keep the position of their first occurrence.
-
inline bool simplify_product(ExprPtr &expr)¶