From 798d53ebb4da4e8e3865ed7bd7f31412fe2be3a7 Mon Sep 17 00:00:00 2001 From: "Vladimir V. Kisil" Date: Wed, 11 Sep 2013 09:26:30 +0100 Subject: [PATCH 1/1] Make it possible to override info() for functions. Signed-off-by: Vladimir V. Kisil --- check/exam_inifcns.cpp | 9 +++++++++ ginac/flags.h | 2 +- ginac/function.cppy | 27 +++++++++++++++++++++++++++ ginac/function.hppy | 6 ++++++ ginac/function.py | 2 +- 5 files changed, 44 insertions(+), 2 deletions(-) diff --git a/check/exam_inifcns.cpp b/check/exam_inifcns.cpp index 77a4b3b7..30d5b212 100644 --- a/check/exam_inifcns.cpp +++ b/check/exam_inifcns.cpp @@ -249,6 +249,15 @@ static unsigned inifcns_consist_abs() if (!abs(step(z)).eval().is_equal(step(z))) ++result; + if (!abs(p).info(info_flags::positive) || !abs(a).info(info_flags::real)) + ++result; + + if (abs(a).info(info_flags::positive) || !abs(a).info(info_flags::real)) + ++result; + + if (abs(z).info(info_flags::positive) || !abs(z).info(info_flags::real)) + ++result; + return result; } diff --git a/ginac/flags.h b/ginac/flags.h index e38d9c58..3d398cf1 100644 --- a/ginac/flags.h +++ b/ginac/flags.h @@ -207,7 +207,7 @@ public: class info_flags { public: enum { - // answered by class numeric, add, mul and symbols/constants in particular domains + // answered by class numeric, add, mul, function and symbols/constants in particular domains numeric, real, rational, diff --git a/ginac/function.cppy b/ginac/function.cppy index 2a9080cf..ce38045f 100644 --- a/ginac/function.cppy +++ b/ginac/function.cppy @@ -80,6 +80,7 @@ void function_options::initialize() nparams = 0; eval_f = evalf_f = real_part_f = imag_part_f = conjugate_f = expand_f = derivative_f = power_f = series_f = 0; + info_f = 0; evalf_params_first = true; use_return_type = false; eval_use_exvector_args = false; @@ -92,6 +93,7 @@ void function_options::initialize() power_use_exvector_args = false; series_use_exvector_args = false; print_use_exvector_args = false; + info_use_exvector_args = false; use_remember = false; functions_with_same_name = 1; symtree = 0; @@ -594,6 +596,31 @@ ex function::imag_part() const throw(std::logic_error("function::imag_part(): invalid nparams")); } +/** Implementation of ex::info for functions. */ +bool function::info(unsigned inf) const +{ + GINAC_ASSERT(serial print_dispatch_table; + info_funcp info_f; bool evalf_params_first; @@ -181,6 +185,7 @@ protected: bool power_use_exvector_args; bool series_use_exvector_args; bool print_use_exvector_args; + bool info_use_exvector_args; unsigned functions_with_same_name; @@ -232,6 +237,7 @@ public: ex imag_part() const; void archive(archive_node& n) const; void read_archive(const archive_node& n, lst& syms); + bool info(unsigned inf) const; protected: ex derivative(const symbol & s) const; bool is_equal_same_type(const basic & other) const; diff --git a/ginac/function.py b/ginac/function.py index 0ecb918c..3f5e54eb 100755 --- a/ginac/function.py +++ b/ginac/function.py @@ -2,7 +2,7 @@ # encoding: utf-8 maxargs = 14 -methods = "eval evalf conjugate real_part imag_part expand derivative power series print".split() +methods = "eval evalf conjugate real_part imag_part expand derivative power series info print".split() import sys, os, optparse sys.path.insert(0, os.path.join(os.path.dirname(__file__), '..', 'scripts')) -- 2.44.0