1 #ifndef SYMENGINE_CANCEL_H
2 #define SYMENGINE_CANCEL_H
5 #include <symengine/polys/basic_conversions.h>
10 template <
typename Poly>
11 inline void cancel(
const RCP<const Basic> &numer,
const RCP<const Basic> &denom,
12 const Ptr<RCP<const Poly>> &result_numer,
13 const Ptr<RCP<const Poly>> &result_denom,
14 const Ptr<RCP<const Poly>> &common)
17 umap_basic_num numer_gens = _find_gens_poly(numer);
18 umap_basic_num denom_gens = _find_gens_poly(denom);
20 if (numer_gens.size() != 1 && denom_gens.size() != 1) {
24 RCP<const Basic> numer_var = numer_gens.begin()->first;
25 RCP<const Basic> denom_var = denom_gens.begin()->first;
27 RCP<const Poly> numer_poly = from_basic<Poly>(numer, numer_var);
28 RCP<const Poly> denom_poly = from_basic<Poly>(denom, denom_var);
31 RCP<const Poly> gcd_poly = gcd_upoly(*numer_poly, *denom_poly);
34 divides_upoly(*gcd_poly, *numer_poly, outArg(*result_numer));
35 divides_upoly(*gcd_poly, *denom_poly, outArg(*result_denom));
The base class for SymEngine.
Main namespace for SymEngine package.