Improve abs_eval(): abs(conjugate(z)) => abs(z), ...
authorVladimir V. Kisil <kisilv@maths.leeds.ac.uk>
Thu, 1 Aug 2013 13:37:45 +0000 (14:37 +0100)
committerAlexei Sheplyakov <Alexei.Sheplyakov@gmail.com>
Wed, 16 Oct 2013 05:20:30 +0000 (08:20 +0300)
... abs(step(z)) => step(z)

Signed-off-by: Vladimir V. Kisil <kisilv@maths.leeds.ac.uk>
check/exam_inifcns.cpp
ginac/inifcns.cpp

index 994aa34..77a4b3b 100644 (file)
@@ -224,6 +224,7 @@ static unsigned inifcns_consist_abs()
        unsigned result = 0;
        realsymbol a("a"), b("b"), x("x"), y("y");
        possymbol p("p");
+       symbol z("z");
 
        if (!abs(exp(x+I*y)).eval().is_equal(exp(x)))
                ++result;
@@ -242,6 +243,13 @@ static unsigned inifcns_consist_abs()
        if (!abs(pow(x+I*y,a+I*b)).eval().is_equal(abs(pow(x+I*y,a+I*b))))
                ++result;
 
+       if (!abs(z.conjugate()).eval().is_equal(abs(z)))
+               ++result;
+
+       if (!abs(step(z)).eval().is_equal(step(z)))
+               ++result;
+
+       return result;
 }
 
 static unsigned inifcns_consist_various()
index 0cb2abb..e8aacab 100644 (file)
@@ -207,6 +207,12 @@ static ex abs_eval(const ex & arg)
                        return pow(abs(base), exponent.real_part());
        }
 
+       if (is_ex_the_function(arg, conjugate_function))
+               return abs(arg.op(0));
+
+       if (is_ex_the_function(arg, step))
+               return arg;
+
        return abs(arg).hold();
 }