- debugmsg("ex swap",LOGLEVEL_MEMBER_FUNCTION);
-
- ASSERT(bp!=0);
- ASSERT(bp->flags & status_flags::dynallocated);
- ASSERT(other.bp!=0);
- ASSERT(other.bp->flags & status_flags::dynallocated);
-
- basic * tmpbp=bp;
- bp=other.bp;
- other.bp=tmpbp;
-}
-
-bool ex::info(unsigned inf) const
-{
- if (inf == info_flags::normal_form) {
-
- // Polynomials are in normal form
- if (info(info_flags::polynomial))
- return true;
-
- // polynomial^(-int) is in normal form
- if (is_ex_exactly_of_type(*this, power))
- return op(1).info(info_flags::negint);
-
- // polynomial^(int) * polynomial^(int) * ... is in normal form
- if (!is_ex_exactly_of_type(*this, mul))
- return false;
- for (int i=0; i<nops(); i++) {
- if (is_ex_exactly_of_type(op(i), power)) {
- if (!op(i).op(1).info(info_flags::integer))
- return false;
- if (!op(i).op(0).info(info_flags::polynomial))
- return false;
- } else
- if (!op(i).info(info_flags::polynomial))
- return false;
- }
- return true;
- } else {
- return bp->info(inf);
- }
-}
-
-int ex::nops() const
-{
- ASSERT(bp!=0);
- return bp->nops();
-}
-
-ex ex::expand(unsigned options) const
-{
- ASSERT(bp!=0);
- return bp->expand(options);
-}
-
-bool ex::has(ex const & other) const
-{
- ASSERT(bp!=0);
- return bp->has(other);
-}
-
-int ex::degree(symbol const & s) const
-{
- ASSERT(bp!=0);
- return bp->degree(s);
-}
-
-int ex::ldegree(symbol const & s) const
-{
- ASSERT(bp!=0);
- return bp->ldegree(s);
-}
-
-ex ex::coeff(symbol const & s, int const n) const
-{
- ASSERT(bp!=0);
- return bp->coeff(s,n);
-}
-
-ex ex::numer(bool normalize) const
-{
- ex n;
- if (normalize && !info(info_flags::normal_form))
- n = normal();
- else
- n = *this;
-
- // polynomial
- if (n.info(info_flags::polynomial))
- return n;
-
- // something^(-int)
- if (is_ex_exactly_of_type(n, power) && n.op(1).info(info_flags::negint))
- return exONE();
-
- // something^(int) * something^(int) * ...
- if (!is_ex_exactly_of_type(n, mul))
- return n;
- ex res = exONE();
- for (int 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 *= n.op(i);
- }
- return res;
-}
-
-ex ex::denom(bool normalize) const
-{
- ex n;
- if (normalize && !info(info_flags::normal_form))
- n = normal();
- else
- n = *this;
-
- // polynomial
- if (n.info(info_flags::polynomial))
- return exONE();
-
- // 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 exONE();
- ex res = exONE();
- for (int 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);
- }
- return res;
-}
-
-ex ex::collect(symbol const & s) const
-{
- ASSERT(bp!=0);
- return bp->collect(s);
-}
-
-ex ex::eval(int level) const
-{
- ASSERT(bp!=0);
- return bp->eval(level);
-}
-
-ex ex::evalf(int level) const
-{
- ASSERT(bp!=0);
- return bp->evalf(level);
-}
-
-ex ex::subs(lst const & ls, lst const & lr) const
-{
- ASSERT(bp!=0);
- return bp->subs(ls,lr);
-}