]> www.ginac.de Git - ginac.git/blobdiff - check/exam_cra.cpp
[bugfix] integer_cra: check if arguments contain at least 2 moduli
[ginac.git] / check / exam_cra.cpp
index 11e1ab700405076a739944652b68063ae924fbf9..6e247704fac4e9a82ed6d9e2716771e8c0de63dd 100644 (file)
@@ -7,6 +7,7 @@
 #include <map>
 #include <vector>
 #include <stdexcept>
+#include <limits>
 using namespace cln;
 using namespace std;
 
@@ -101,12 +102,14 @@ make_random_moduli(const cln::cl_I& limit)
        std::vector<cln::cl_I> moduli;
        cln::cl_I prod(1);
        cln::cl_I next = random_I(std::min(limit >> 1, cln::cl_I(128)));
+       unsigned count = 0;
        do {
                cln::cl_I tmp = nextprobprime(next);
                next = tmp + random_I(cln::cl_I(10)) + 1;
                prod = prod*tmp;
                moduli.push_back(tmp);
-       } while (prod < limit);
+               ++count;
+       } while (prod < limit || (count < 2));
        return moduli;
 }