[GiNaC-devel] [PATCH 2/3] collect_common_factors: improve handling of powers.

Alexei Sheplyakov varg at theor.jinr.ru
Fri Oct 6 13:39:56 CEST 2006


Now collect_common_factors((a*x+a*y)^(-2)) evaluates to
(x+y)^(-2)*a^(-2) as one might expect.

---
 ginac/normal.cpp |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/ginac/normal.cpp b/ginac/normal.cpp
index 49f0bd7..fc89710 100644
--- a/ginac/normal.cpp
+++ b/ginac/normal.cpp
@@ -2513,7 +2513,7 @@ static ex find_common_factor(const ex & 
 		for (size_t i=0; i<num; i++) {
 			ex x = e.op(i).to_polynomial(repl);
 
-			if (is_exactly_a<add>(x) || is_exactly_a<mul>(x)) {
+			if (is_exactly_a<add>(x) || is_exactly_a<mul>(x) || is_a<power>(x)) {
 				ex f = 1;
 				x = find_common_factor(x, f, repl);
 				x *= f;
@@ -2573,7 +2573,7 @@ term_done:	;
 
 	} else if (is_exactly_a<power>(e)) {
 		const ex e_exp(e.op(1));
-		if (e_exp.info(info_flags::posint)) {
+		if (e_exp.info(info_flags::integer)) {
 			ex eb = e.op(0).to_polynomial(repl);
 			ex factor_local(_ex1);
 			ex pre_res = find_common_factor(eb, factor_local, repl);
-- 
All science is either physics or stamp collecting.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 827 bytes
Desc: Digital signature
Url : http://www.cebix.net/pipermail/ginac-devel/attachments/20061006/02a80805/attachment.pgp


More information about the GiNaC-devel mailing list