algebramix_doc 0.3
|
/****************************************************************************** * MODULE : polynomial_test.cpp * DESCRIPTION: Test polynomials * COPYRIGHT : (C) 2004 Joris van der Hoeven and 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 <numerix/modular_integer.hpp> #include <numerix/modular_int.hpp> #include <algebramix/polynomial.hpp> #include <algebramix/modular_polynomial.hpp> #include <algebramix/polynomial_tft.hpp> #include <algebramix/polynomial_ring_dicho.hpp> #include <algebramix/polynomial_dicho.hpp> #include <algebramix/polynomial_int.hpp> #include <algebramix/polynomial_integer.hpp> #include <algebramix/polynomial_quotient.hpp> #include <algebramix/polynomial_polynomial.hpp> #include <algebramix/polynomial_modular_int.hpp> #include <algebramix/polynomial_modular_integer.hpp> using namespace mmx; #define TMPL template<typename C, typename V> #define Polynomial polynomial<C,V> #define TMPLW template<typename C, typename V, typename W> #define Polynomial_polynomial polynomial<Polynomial,W> /****************************************************************************** * Quick tests with printing ******************************************************************************/ TMPL void quick_test_over_field () { Polynomial P= seq (C (1), C (4), C (3)); Polynomial Q (7, 3); mmout << "P\t= " << P << "\n"; mmout << "degree(P)\t= " << deg(P) << "\n"; mmout << "Q\t= " << Q << "\n"; mmout << "P+Q\t= " << P+Q << "\n"; mmout << "P-Q\t= " << P-Q << "\n"; mmout << "Q-P\t= " << Q-P << "\n"; mmout << "P*Q\t= " << P*Q << "\n"; mmout << "2*P\t= " << 2*P << "\n"; mmout << "P*2\t= " << P*2 << "\n"; mmout << "P quo 3\t= " << quo (P, C (3)) << "\n"; mmout << "P rem 3\t= " << rem (P, C (3)) << "\n"; mmout << "P quo Q\t= " << quo (P, Q) << "\n"; mmout << "Q quo P\t= " << quo (Q, P) << "\n"; mmout << "P rem Q\t= " << rem (P, Q) << "\n"; mmout << "Q rem P\t= " << rem (Q, P) << "\n"; mmout << "Q2 quo P= " << quo (Q*Q, P) << "\n"; mmout << "Q2 rem P= " << rem (Q*Q, P) << "\n"; mmout << "P+=Q\t= " << (P+=Q) << "\n"; mmout << "P-=Q\t= " << (P-=Q) << "\n"; mmout << "P*=Q\t= " << (P*=Q) << "\n"; mmout << "P/=Q\t= " << (P/=Q) << "\n"; mmout << "P*=11\t= " << (P*=C(11)) << "\n"; mmout << "P/=11\t= " << (P/=11) << "\n"; mmout << "P=Q\t= " << (P==Q) << "\n"; mmout << "P!=Q\t= " << (P!=Q) << "\n"; // mmout << "P<Q\t= " << (P<Q) << "\n"; // mmout << "P<=Q\t= " << (P<=Q) << "\n"; // mmout << "P>Q\t= " << (P>Q) << "\n"; // mmout << "P>=Q\t= " << (P>=Q) << "\n"; mmout << "P'\t= " << derive (P) << "\n"; mmout << "`P\t= " << integrate (P) << "\n"; mmout << "P o P\t= " << compose (P, P) << "\n"; mmout << "Q o P\t= " << compose (Q, P) << "\n"; mmout << "P o Q\t= " << compose (P, Q) << "\n"; mmout << "Q o Q\t= " << compose (Q, Q) << "\n"; mmout << "P(x+1)\t= " << shift (P, 1) << "\n"; mmout << "P(3x)\t= " << q_difference (P, C (3)) << "\n"; mmout << "P(x^5)\t= " << dilate (P, 5) << "\n"; mmout << "sr(P)\t= " << graeffe (P) << "\n"; mmout << "P...\t= " << iterate (P) << "\n"; // mmout << "P\t= " << P << "\n"; // mmout << "1/P\t= " << invert_lo (P) << "\n"; // mmout << "P*(1/P)\t= " << P* invert_lo (P) << "\n"; // mmout << "1/P\t= " << invert_hi (P) << "\n"; // Vector v= seq (C (-1), C (4), C (3)); // mmout << "v\t= " << v << "\n"; // mmout << "P(v)\t= " << eval (P, v) << "\n"; // vector<nat> mu= seq ( nat (1), nat (2), nat (1)); // mmout << "v, mu\t= " << v << "," << mu << "\n"; // mmout << "P(v)\t= " << expand (P, v, mu) << "\n"; } int main () { try { quick_test_over_field<rational, polynomial_naive> (); } catch (exception& e) { mmout << e << "\n"; return -1; } return 0; }