*/
/*
- * GiNaC Copyright (C) 1999-2011 Johannes Gutenberg University Mainz, Germany
+ * GiNaC Copyright (C) 1999-2015 Johannes Gutenberg University Mainz, Germany
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
return result;
}
+class less_object_for_cl_N
+{
+public:
+ bool operator() (const cln::cl_N & a, const cln::cl_N & b) const
+ {
+ // absolute value?
+ if (abs(a) != abs(b))
+ return (abs(a) < abs(b)) ? true : false;
+
+ // complex phase?
+ if (phase(a) != phase(b))
+ return (phase(a) < phase(b)) ? true : false;
+
+ // equal, therefore "less" is not true
+ return false;
+ }
+};
+
+
// convergence transformation, used for numerical evaluation of G function.
// the parameter x, s and y must only contain numerics
static cln::cl_N
const cln::cl_N& y, bool flag_trailing_zeros_only)
{
// sort (|x|<->position) to determine indices
- typedef std::multimap<cln::cl_R, std::size_t> sortmap_t;
+ typedef std::multimap<cln::cl_N, std::size_t, less_object_for_cl_N> sortmap_t;
sortmap_t sortmap;
std::size_t size = 0;
for (std::size_t i = 0; i < x.size(); ++i) {
if (!zerop(x[i])) {
- sortmap.insert(std::make_pair(abs(x[i]), i));
+ sortmap.insert(std::make_pair(x[i], i));
++size;
}
}
// include upper limit (scale)
- sortmap.insert(std::make_pair(abs(y), x.size()));
+ sortmap.insert(std::make_pair(y, x.size()));
// generate missing dummy-symbols
int i = 1;
static ex G2_evalf(const ex& x_, const ex& y)
{
- if (!y.info(info_flags::positive)) {
+ if ((!y.info(info_flags::numeric)) || (!y.info(info_flags::positive))) {
return G(x_, y).hold();
}
lst x = is_a<lst>(x_) ? ex_to<lst>(x_) : lst(x_);
{
//TODO eval to MZV or H or S or Lin
- if (!y.info(info_flags::positive)) {
+ if ((!y.info(info_flags::numeric)) || (!y.info(info_flags::positive))) {
return G(x_, y).hold();
}
lst x = is_a<lst>(x_) ? ex_to<lst>(x_) : lst(x_);
}
+// option do_not_evalf_params() removed.
unsigned G2_SERIAL::serial = function::register_new(function_options("G", 2).
evalf_func(G2_evalf).
eval_func(G2_eval).
- do_not_evalf_params().
overloaded(2));
//TODO
// derivative_func(G2_deriv).
static ex G3_evalf(const ex& x_, const ex& s_, const ex& y)
{
- if (!y.info(info_flags::positive)) {
+ if ((!y.info(info_flags::numeric)) || (!y.info(info_flags::positive))) {
return G(x_, s_, y).hold();
}
lst x = is_a<lst>(x_) ? ex_to<lst>(x_) : lst(x_);
{
//TODO eval to MZV or H or S or Lin
- if (!y.info(info_flags::positive)) {
+ if ((!y.info(info_flags::numeric)) || (!y.info(info_flags::positive))) {
return G(x_, s_, y).hold();
}
lst x = is_a<lst>(x_) ? ex_to<lst>(x_) : lst(x_);
}
+// option do_not_evalf_params() removed.
+// This is safe: in the code above it only matters if s_ > 0 or s_ < 0,
+// s_ is allowed to be of floating type.
unsigned G3_SERIAL::serial = function::register_new(function_options("G", 3).
evalf_func(G3_evalf).
eval_func(G3_eval).
- do_not_evalf_params().
overloaded(2));
//TODO
// derivative_func(G3_deriv).