algebramix_doc 0.3
|
/****************************************************************************** * MODULE : modular_polynomial_test.cpp * DESCRIPTION: Test modular computations with polynomials * COPYRIGHT : (C) 2008 Gregoire Lecerf ******************************************************************************* * This software falls under the GNU general public license and comes WITHOUT * ANY WARRANTY WHATSOEVER. See the file $TEXMACS_PATH/LICENSE for more details. * If you don't have this file, write to the Free Software Foundation, Inc., * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ******************************************************************************/ #include <numerix/rational.hpp> #include <algebramix/modular_polynomial.hpp> using namespace mmx; #define Scalar rational #define Polynomial polynomial<Scalar> #define Modular modular<modulus<Polynomial > > Modular sample0 (nat n, nat d) { Polynomial P (1, n); for (nat i=0; i<n; i++) P += Polynomial (1, i); return Modular (P); } Modular sample1 (nat n, nat d) { Polynomial P (1, n); for (nat i=0; i<n; i++) P += Polynomial (1, n - i); return Modular (P); } void quick_test () { Polynomial P= Polynomial (1,0) - Polynomial (1,2); Modular::set_modulus (P); Modular X= sample0 (2,3); Modular Y= sample1 (1,2); mmout << "X\t= " << X << "\n"; mmout << "Y\t= " << Y << "\n"; mmout << "X+Y\t= " << X+Y << "\n"; mmout << "X-Y\t= " << X-Y << "\n"; mmout << "X*Y\t= " << X*Y << "\n"; mmout << "X/Y\t= " << X/Y << "\n"; } int main () { quick_test (); return 0; }