* Implementation of GiNaC's initially known functions. */
/*
- * GiNaC Copyright (C) 1999-2011 Johannes Gutenberg University Mainz, Germany
+ * GiNaC Copyright (C) 1999-2014 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
static ex abs_power(const ex & arg, const ex & exp)
{
- if (arg.is_equal(arg.conjugate()) && ((is_a<numeric>(exp) && ex_to<numeric>(exp).is_even())
- || exp.info(info_flags::even)))
- return power(arg, exp);
- else
+ if ((is_a<numeric>(exp) && ex_to<numeric>(exp).is_even()) || exp.info(info_flags::even)) {
+ if (arg.info(info_flags::real) || arg.is_equal(arg.conjugate()))
+ return power(arg, exp);
+ else
+ return power(arg, exp/2)*power(arg.conjugate(), exp/2);
+ } else
return power(abs(arg), exp).hold();
}