[GiNaC-list] conjugates of power objects
Alexei Sheplyakov
alexei.sheplyakov at gmail.com
Thu May 6 07:10:42 CEST 2010
Hello,
On Thu, May 06, 2010 at 05:16:01AM +0200, Burcin Erocal wrote:
> I attached a patch with my attempts to solve this problem. It is based
> on the latest version of pynac. I hope it applies cleanly to GiNaC as
> well.
> Attached patch adds a rule to power::eval() to transform ^(-c1, c2) to
> *(^(-1, c2), (c1, c2)) when c1 and c2 are both rational. I got this
> idea from maxima.
No objections here.
> I also restrict the automatic conjugation unless the basis is real and
> the exponent is a rational, returning *this in this case.
Now conjugate() is unable to handle pow(complex-valued polynomial, integer).
I think this makes conjugate() practically useless. So, I'm afraid this change
is not acceptable.
> diff --git a/ginac/power.cpp b/ginac/power.cpp
> --- a/ginac/power.cpp
> +++ b/ginac/power.cpp
> @@ -567,6 +567,14 @@
> }
>
> if (exponent_is_rational) {
> + // ^(-c1, c2) -> ((-1)^c2)*(c1^c2)
> + // for example sqrt(-2) -> I*sqrt(2)
> + if (num_basis->is_negative() &&
> + !num_basis->is_equal(*_num_1_p))
> + return mul(power(_ex_1, *num_exponent),
> + power((*num_basis)*(*_num_1_p),
> + *num_exponent));
> +
A few minor corrections:
1) pow(_ex_1, *num_exponent)*pow((*num_basis)*(*num_1_p), *num_exponent)
would be easier to read
2) If you insist on constructing the mul object manually, do
return new mul(foo, bar)->setflags(status_flags::dynallocated);
Best regards,
Alexei
More information about the GiNaC-list
mailing list