-
- // convergence transformation
- if (need_trafo) {
-
- // sort (|x|<->position) to determine indices
- std::multimap<ex,int> sortmap;
- int size = 0;
- for (int i=0; i<x.nops(); ++i) {
- if (!x[i].is_zero()) {
- sortmap.insert(std::pair<ex,int>(abs(x[i]), i));
- ++size;
- }
- }
- // include upper limit (scale)
- sortmap.insert(std::pair<ex,int>(abs(y), x.nops()));
-
- // generate missing dummy-symbols
- int i = 1;
- // holding dummy-symbols for the G/Li transformations
- exvector gsyms;
- gsyms.push_back(symbol("GSYMS_ERROR"));
- ex lastentry;
- for (std::multimap<ex,int>::const_iterator it = sortmap.begin(); it != sortmap.end(); ++it) {
- if (it != sortmap.begin()) {
- if (it->second < x.nops()) {
- if (x[it->second] == lastentry) {
- gsyms.push_back(gsyms.back());
- continue;
- }
- } else {
- if (y == lastentry) {
- gsyms.push_back(gsyms.back());
- continue;
- }
+ 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
+G_do_trafo(const std::vector<cln::cl_N>& x, const std::vector<int>& s,
+ const cln::cl_N& y, bool flag_trailing_zeros_only)
+{
+ // sort (|x|<->position) to determine indices
+ 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(x[i], i));
+ ++size;
+ }
+ }
+ // include upper limit (scale)
+ sortmap.insert(std::make_pair(y, x.size()));
+
+ // generate missing dummy-symbols
+ int i = 1;
+ // holding dummy-symbols for the G/Li transformations
+ exvector gsyms;
+ gsyms.push_back(symbol("GSYMS_ERROR"));
+ cln::cl_N lastentry(0);
+ for (sortmap_t::const_iterator it = sortmap.begin(); it != sortmap.end(); ++it) {
+ if (it != sortmap.begin()) {
+ if (it->second < x.size()) {
+ if (x[it->second] == lastentry) {
+ gsyms.push_back(gsyms.back());
+ continue;