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;
}
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,
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;
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;
throw(std::logic_error("function::imag_part(): invalid nparams"));
}
+/** Implementation of ex::info for functions. */
+bool function::info(unsigned inf) const
+{
+ GINAC_ASSERT(serial<registered_functions().size());
+ const function_options & opt = registered_functions()[serial];
+
+ if (opt.info_f==0) {
+ return basic::info(inf);
+ }
+
+ if (opt.info_use_exvector_args) {
+ return ((info_funcp_exvector)(opt.info_f))(seq, inf);
+ }
+
+ switch (opt.nparams) {
+ // the following lines have been generated for max. @maxargs@ parameters
++++ for N in range(1, maxargs + 1):
+ case @N@:
+ return ((info_funcp_@N@)(opt.info_f))(@seq('seq[%(n)d]', N, 0)@, inf);
+---
+ // end of generated lines
+ }
+ throw(std::logic_error("function::info(): invalid nparams"));
+}
+
// protected
/** Implementation of ex::diff() for functions. It applies the chain rule,
typedef ex (* power_funcp)();
typedef ex (* series_funcp)();
typedef void (* print_funcp)();
+typedef bool (* info_funcp)();
// the following lines have been generated for max. @maxargs@ parameters
+++ for N, args in [ ( N, seq('const ex &', N) ) for N in range(1, maxargs + 1) ]:
typedef ex (* power_funcp_@N@)( @args@, const ex & );
typedef ex (* series_funcp_@N@)( @args@, const relational &, int, unsigned );
typedef void (* print_funcp_@N@)( @args@, const print_context & );
+typedef bool (* info_funcp_@N@)( @args@, unsigned );
---
// end of generated lines
typedef ex (* power_funcp_exvector)(const exvector &, const ex &);
typedef ex (* series_funcp_exvector)(const exvector &, const relational &, int, unsigned);
typedef void (* print_funcp_exvector)(const exvector &, const print_context &);
+typedef bool (* info_funcp_exvector)(const exvector &, unsigned);
class function_options
power_funcp power_f;
series_funcp series_f;
std::vector<print_funcp> print_dispatch_table;
+ info_funcp info_f;
bool evalf_params_first;
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;
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;
# 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'))