@example
ex ex::to_polynomial(exmap & m);
-ex ex::to_polynomial(lst & l);
@end example
or
@example
ex ex::to_rational(exmap & m);
-ex ex::to_rational(lst & l);
@end example
-on the expression to be converted. The supplied @code{exmap} or @code{lst}
-will be filled with the generated temporary symbols and their replacement
-expressions in a format that can be used directly for the @code{subs()}
-method. It can also already contain a list of replacements from an earlier
-application of @code{.to_polynomial()} or @code{.to_rational()}, so it's
-possible to use it on multiple expressions and get consistent results.
+on the expression to be converted. The supplied @code{exmap} will be filled
+with the generated temporary symbols and their replacement expressions in a
+format that can be used directly for the @code{subs()} method. It can also
+already contain a list of replacements from an earlier application of
+@code{.to_polynomial()} or @code{.to_rational()}, so it's possible to use
+it on multiple expressions and get consistent results.
The difference between @code{.to_polynomial()} and @code{.to_rational()}
is probably best illustrated with an example:
ex a = 2*x/sin(x) - y/(3*sin(x));
cout << a << endl;
- lst lp;
- ex p = a.to_polynomial(lp);
- cout << " = " << p << "\n with " << lp << endl;
+ exmap mp;
+ ex p = a.to_polynomial(mp);
+ cout << " = " << p << "\n with " << mp << endl;
// = symbol3*symbol2*y+2*symbol2*x
// with @{symbol2==sin(x)^(-1),symbol3==-1/3@}
- lst lr;
- ex r = a.to_rational(lr);
- cout << " = " << r << "\n with " << lr << endl;
+ exmap mr;
+ ex r = a.to_rational(mr);
+ cout << " = " << r << "\n with " << mr << endl;
// = -1/3*symbol4^(-1)*y+2*symbol4^(-1)*x
// with @{symbol4==sin(x)@}
@}
// rational functions
ex normal() const;
ex to_rational(exmap & repl) const;
- ex to_rational(lst & repl_lst) const;
ex to_polynomial(exmap & repl) const;
- ex to_polynomial(lst & repl_lst) const;
ex numer() const;
ex denom() const;
ex numer_denom() const;
inline ex normal(const ex & thisex)
{ return thisex.normal(); }
-inline ex to_rational(const ex & thisex, lst & repl_lst)
-{ return thisex.to_rational(repl_lst); }
-
inline ex to_rational(const ex & thisex, exmap & repl)
{ return thisex.to_rational(repl); }
inline ex to_polynomial(const ex & thisex, exmap & repl)
{ return thisex.to_polynomial(repl); }
-inline ex to_polynomial(const ex & thisex, lst & repl_lst)
-{ return thisex.to_polynomial(repl_lst); }
-
inline ex collect(const ex & thisex, const ex & s, bool distributed = false)
{ return thisex.collect(s, distributed); }
return bp->to_rational(repl);
}
-// GiNaC 1.1 compatibility function
-ex ex::to_rational(lst & repl_lst) const
-{
- // Convert lst to exmap
- exmap m;
- for (auto & it : repl_lst)
- m.insert(std::make_pair(it.op(0), it.op(1)));
-
- ex ret = bp->to_rational(m);
-
- // Convert exmap back to lst
- repl_lst.remove_all();
- for (auto & it : m)
- repl_lst.append(it.first == it.second);
-
- return ret;
-}
-
ex ex::to_polynomial(exmap & repl) const
{
return bp->to_polynomial(repl);
}
-// GiNaC 1.1 compatibility function
-ex ex::to_polynomial(lst & repl_lst) const
-{
- // Convert lst to exmap
- exmap m;
- for (auto & it : repl_lst)
- m.insert(std::make_pair(it.op(0), it.op(1)));
-
- ex ret = bp->to_polynomial(m);
-
- // Convert exmap back to lst
- repl_lst.remove_all();
- for (auto & it : m)
- repl_lst.append(it.first == it.second);
-
- return ret;
-}
-
/** Default implementation of ex::to_rational(). This replaces the object with
* a temporary symbol. */
ex basic::to_rational(exmap & repl) const