algebramix_doc 0.3
quotient_test.cpp
/******************************************************************************
* MODULE     : quotient_test.cpp
* DESCRIPTION: Test quotients
* 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/polynomial.hpp>
#include <algebramix/quotient.hpp>

using namespace mmx;

#define Scalar rational
#define Polynomial polynomial<Scalar>
#define Quotient quotient<Polynomial, Polynomial>

Quotient
sample0 (nat n, nat d) {
  Polynomial P (1, n);
  for (nat i=0; i<n; i++)
    P += Polynomial (1, i);
  Polynomial Q (1, d);
  for (nat i=0; i<d; i++)
    P += Polynomial (1, i*i);
  return Quotient (P, Q, true);
}

Quotient
sample1 (nat n, nat d) {
  Polynomial P (1, n);
  for (nat i=0; i<n; i++)
    P += Polynomial (1, n - i);
  Polynomial Q (1, d);
  for (nat i=0; i<d; i++)
    P += Polynomial (1, d - i*i);
  return Quotient (P, Q, true);
}

void
quick_test () {
  Quotient X= sample0 (2,3);
  Quotient 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";
}

int
main () {
  quick_test ();
  return 0;
}
 All Classes Namespaces Files Functions Variables Typedefs Friends Defines