- GINAC_ASSERT(bp!=0);
- return bp->expand(options);
-}
-
-bool ex::has(const ex & other) const
-{
- GINAC_ASSERT(bp!=0);
- return bp->has(other);
-}
-
-int ex::degree(const symbol & s) const
-{
- GINAC_ASSERT(bp!=0);
- return bp->degree(s);
-}
-
-int ex::ldegree(const symbol & s) const
-{
- GINAC_ASSERT(bp!=0);
- return bp->ldegree(s);
-}
-
-ex ex::coeff(const symbol & s, int n) const
-{
- GINAC_ASSERT(bp!=0);
- return bp->coeff(s,n);
-}
-
-ex ex::numer(bool normalize) const
-{
- ex n;
- if (normalize)
- n = normal();
- else
- n = *this;
-
- // number
- if (is_ex_exactly_of_type(n, numeric))
- return ex_to_numeric(n).numer();
-
- // polynomial
- if (n.info(info_flags::cinteger_polynomial))
- return n;
-
- // something^(-int)
- if (is_ex_exactly_of_type(n, power) && n.op(1).info(info_flags::negint))
- return _ex1();
-
- // something^(int) * something^(int) * ...
- if (!is_ex_exactly_of_type(n, mul))
- return n;
- ex res = _ex1();
- for (unsigned i=0; i<n.nops(); i++) {
- if (is_ex_exactly_of_type(n.op(i), power) && n.op(i).op(1).info(info_flags::negint)) {
- // something^(-int) belongs to the denominator
- } else if (is_ex_exactly_of_type(n.op(i), numeric)) {
- res *= ex_to_numeric(n.op(i)).numer();
- } else {
- res *= n.op(i);
- }
- }
- return res;
-}
-
-ex ex::denom(bool normalize) const
-{
- ex n;
- if (normalize)
- n = normal();
- else
- n = *this;
-
- // number
- if (is_ex_exactly_of_type(n, numeric))
- return ex_to_numeric(n).denom();
-
- // polynomial
- if (n.info(info_flags::cinteger_polynomial))
- return _ex1();
-
- // something^(-int)
- if (is_ex_exactly_of_type(n, power) && n.op(1).info(info_flags::negint))
- return power(n.op(0), -(n.op(1)));
-
- // something^(int) * something^(int) * ...
- if (!is_ex_exactly_of_type(n, mul))
- return _ex1();
- ex res = _ex1();
- for (unsigned i=0; i<n.nops(); i++) {
- if (is_ex_exactly_of_type(n.op(i), power) && n.op(i).op(1).info(info_flags::negint)) {
- res *= power(n.op(i), -1);
- } else if (is_ex_exactly_of_type(n.op(i), numeric)) {
- res *= ex_to_numeric(n.op(i)).denom();
- } else {
- // everything else belongs to the numerator
- }
- }
- return res;
-}
-
-ex ex::collect(const symbol & s) const
-{
- GINAC_ASSERT(bp!=0);
- return bp->collect(s);
-}
-
-ex ex::eval(int level) const
-{
- GINAC_ASSERT(bp!=0);
- return bp->eval(level);
-}
-
-ex ex::evalf(int level) const
-{
- GINAC_ASSERT(bp!=0);
- return bp->evalf(level);