[GiNaC-devel] csgn patch
Vladimir Kisil
kisilv at maths.leeds.ac.uk
Mon Mar 13 16:59:20 CET 2006
Dear all,
Here is the full patch for the power property of csgn()
function. Its effect can be seen in the following ginsh output:
> csgn(x)^3;
csgn(x)
> csgn(x)^5;
csgn(x)
> csgn(x)^2;
csgn(x)^2
> csgn(x)^(2/5);
csgn(x)^(2/5)
> csgn(x)^(6/2);
csgn(x)
> csgn(x)^(-2);
csgn(x)^(-2)
> csgn(x)^(-3);
csgn(x)^(-3)
> csgn(x)^(-3/3);
csgn(x)^(-1)
> csgn(x)^(-3/2);
csgn(x)^(-3/2)
Best wishes,
Vladimir
--
Vladimir V. Kisil email: kisilv at maths.leeds.ac.uk
-- www: http://maths.leeds.ac.uk/~kisilv/
Index: ginac/inifcns.cpp
===================================================================
RCS file: /home/cvs/GiNaC/ginac/inifcns.cpp,v
retrieving revision 1.87
diff -u -r1.87 inifcns.cpp
--- ginac/inifcns.cpp 13 Mar 2006 14:21:47 -0000 1.87
+++ ginac/inifcns.cpp 13 Mar 2006 15:56:20 -0000
@@ -252,10 +252,23 @@
return csgn(arg);
}
+static ex csgn_power(const ex & arg, const ex & exp)
+{
+ if (is_a<numeric>(exp) && exp.info(info_flags::positive) && ex_to<numeric>(exp).is_integer()) {
+ if (ex_to<numeric>(exp).is_odd())
+ return csgn(arg);
+ else
+ return power(csgn(arg), _ex2).hold();
+ } else
+ return power(csgn(arg), exp).hold();
+}
+
+
REGISTER_FUNCTION(csgn, eval_func(csgn_eval).
evalf_func(csgn_evalf).
series_func(csgn_series).
- conjugate_func(csgn_conjugate));
+ conjugate_func(csgn_conjugate).
+ power_func(csgn_power));
//////////
More information about the GiNaC-devel
mailing list