From 2c886a86f1d020e927d64ab2c79b20437a6bd561 Mon Sep 17 00:00:00 2001 From: "Vladimir V. Kisil" Date: Thu, 1 Aug 2013 14:37:45 +0100 Subject: [PATCH] Improve abs_eval(): abs(conjugate(z)) => abs(z), ... ... abs(step(z)) => step(z) Signed-off-by: Vladimir V. Kisil --- check/exam_inifcns.cpp | 8 ++++++++ ginac/inifcns.cpp | 6 ++++++ 2 files changed, 14 insertions(+) diff --git a/check/exam_inifcns.cpp b/check/exam_inifcns.cpp index 994aa344..77a4b3b7 100644 --- a/check/exam_inifcns.cpp +++ b/check/exam_inifcns.cpp @@ -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() diff --git a/ginac/inifcns.cpp b/ginac/inifcns.cpp index 0cb2abbd..e8aacab8 100644 --- a/ginac/inifcns.cpp +++ b/ginac/inifcns.cpp @@ -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(); } -- 2.47.0