* Implementation of GiNaC's symbolic exponentiation (basis^exponent). */
/*
- * GiNaC Copyright (C) 1999-2005 Johannes Gutenberg University Mainz, Germany
+ * GiNaC Copyright (C) 1999-2006 Johannes Gutenberg University Mainz, Germany
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
// default constructor
//////////
-power::power() : inherited(TINFO_power) { }
+power::power() : inherited(&power::tinfo_static) { }
//////////
// other constructors
return (new power(ebasis, eexponent))->setflag(status_flags::dynallocated);
}
+bool power::has(const ex & other, unsigned options) const
+{
+ if (!(options & has_options::algebraic))
+ return basic::has(other, options);
+ if (!is_a<power>(other))
+ return basic::has(other, options);
+ if (!exponent.info(info_flags::integer)
+ || !other.op(1).info(info_flags::integer))
+ return basic::has(other, options);
+ if (exponent.info(info_flags::posint)
+ && other.op(1).info(info_flags::posint)
+ && ex_to<numeric>(exponent).to_int()
+ > ex_to<numeric>(other.op(1)).to_int()
+ && basis.match(other.op(0)))
+ return true;
+ if (exponent.info(info_flags::negint)
+ && other.op(1).info(info_flags::negint)
+ && ex_to<numeric>(exponent).to_int()
+ < ex_to<numeric>(other.op(1)).to_int()
+ && basis.match(other.op(0)))
+ return true;
+ return basic::has(other, options);
+}
+
// from mul.cpp
extern bool tryfactsubs(const ex &, const ex &, int &, lst &);
return basis.return_type();
}
-unsigned power::return_type_tinfo() const
+const basic* power::return_type_tinfo() const
{
return basis.return_type_tinfo();
}