*/
/*
- * GiNaC Copyright (C) 1999-2017 Johannes Gutenberg University Mainz, Germany
+ * GiNaC Copyright (C) 1999-2020 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
#include "add.h"
#include <algorithm>
-#include <cmath>
#include <limits>
#include <list>
#include <vector>
{
vector<ex> a = a_;
- const cl_modint_ring R = find_modint_ring(expt_pos(cl_I(p),k));
+ const cl_I modulus = expt_pos(cl_I(p),k);
+ const cl_modint_ring R = find_modint_ring(modulus);
const size_t r = a.size();
const size_t nu = I.size() + 1;
cl_I cm = the<cl_I>(ex_to<numeric>(z.lcoeff(x)).to_cl_N());
upvec delta_s = univar_diophant(amod, x, m, p, k);
cl_MI modcm;
- cl_I poscm = cm;
- while ( poscm < 0 ) {
- poscm = poscm + expt_pos(cl_I(p),k);
- }
+ cl_I poscm = plusp(cm) ? cm : mod(cm, modulus);
modcm = cl_MI(R, poscm);
for ( size_t j=0; j<delta_s.size(); ++j ) {
delta_s[j] = delta_s[j] * modcm;
sigma[j] = sigma[j] + umodpoly_to_ex(delta_s[j], x);
}
- if ( nterms > 1 ) {
+ if ( nterms > 1 && i+1 != nterms ) {
z = c.op(i+1);
}
}