X-Git-Url: https://www.ginac.de/ginac.git//ginac.git?a=blobdiff_plain;f=ginac%2Fpolynomial%2Fcra_garner.cpp;h=e82ed384e5112b67cc72bb8d2f0d7ac43db72cc0;hb=073bf40a73e419a3dbcb6dfa190947ce2cc3bdce;hp=b400adbe69fca8d9c278e3f370197faf112aa2e6;hpb=a377cee53b71348235ec36f83afeced7e10288a8;p=ginac.git diff --git a/ginac/polynomial/cra_garner.cpp b/ginac/polynomial/cra_garner.cpp index b400adbe..e82ed384 100644 --- a/ginac/polynomial/cra_garner.cpp +++ b/ginac/polynomial/cra_garner.cpp @@ -1,11 +1,35 @@ +/** @file cra_garner.cpp + * + * Garner's algorithm. */ + +/* + * GiNaC Copyright (C) 1999-2011 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 + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include "cra_garner.h" +#include "compiler.h" + #include #include -#include #include -#include "cra_garner.hpp" +#include + +namespace cln { -namespace cln -{ using std::vector; using std::size_t; @@ -73,6 +97,8 @@ mixed_radix_2_ordinary(const vector& mixed_radix_coeffs, cl_I integer_cra(const vector& residues, const vector& moduli) { + if (unlikely(moduli.size() < 2)) + throw std::invalid_argument("integer_cra: need at least 2 moduli"); vector recips(moduli.size() - 1); compute_recips(recips, moduli); @@ -85,4 +111,3 @@ cl_I integer_cra(const vector& residues, } } // namespace cln -