[GiNaC-list] [patch] small improvement of collect_common_factors

Sheplyakov Alexei varg at theor.jinr.ru
Fri Mar 10 14:52:14 CET 2006


Hello!

This ginsh code snippet:

collect_common_factors(x/y + z/y^2);

returns the original expression unchanged:

z*y^(-2)+x*y^(-1)

The patch below makes it return

(x+z*y^(-1))*y^(-1)


Index: normal.cpp
===================================================================
RCS file: /home/cvs/GiNaC/ginac/normal.cpp,v
retrieving revision 1.94.2.8
diff -u -r1.94.2.8 normal.cpp
--- normal.cpp	30 Jun 2005 14:03:16 -0000	1.94.2.8
+++ normal.cpp	10 Mar 2006 13:40:26 -0000
@@ -2388,6 +2388,8 @@
 {
 	if (exponent.info(info_flags::posint))
 		return power(basis.to_rational(repl), exponent);
+	else if (exponent.info(info_flags::negint))
+		return power(replace_with_symbol(power(basis, _ex_1), repl), -exponent);
 	else
 		return replace_with_symbol(*this, repl);
 }


Best regards,
  Alexei.

-- 
All science is either physics or stamp collecting.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
Url : http://www.cebix.net/pipermail/ginac-list/attachments/20060310/191065b3/attachment.pgp


More information about the GiNaC-list mailing list