diff --git a/Polynomial/test/Polynomial/polynomial_functions.cpp b/Polynomial/test/Polynomial/polynomial_functions.cpp new file mode 100644 index 00000000000..bc9a32bbfc2 --- /dev/null +++ b/Polynomial/test/Polynomial/polynomial_functions.cpp @@ -0,0 +1,117 @@ +// ============================================================================ +// +// Copyright (c) 2001-2008 Max-Planck-Institut Saarbruecken (Germany). +// All rights reserved. +// +// This file is part of EXACUS (http://www.mpi-inf.mpg.de/projects/EXACUS/); +// you may redistribute it under the terms of the Q Public License version 1.0. +// See the file LICENSE.QPL distributed with EXACUS. +// +// Licensees holding a valid commercial license may use this file in +// accordance with the commercial license agreement provided with the software. +// +// This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE +// WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. +// +// ---------------------------------------------------------------------------- +// +// Library : CGAL +// File : test/Polynomial/polynomial_functions.C +// CGAL_release : $Name: $ +// Revision : $Revision$ +// Revision_date : $Date$ +// +// Author(s) : Eric Berberich +// Arno Eigenwillig +// +// ============================================================================ + +/*! \file polynomial_functions.C + test for functions related to polynomials +*/ + +#include +#include +#include +#include +#include +#include + +typedef int NT; +typedef CGAL::Polynomial UNPOLY; +typedef CGAL::Polynomial BIPOLY; +typedef CGAL::Polynomial TRIPOLY; + +template +void bivariate_polynomial_test() { + + BIPOLY f0; + + // f = xy^2 + 3x^2y + 2x - 1 + BIPOLY f = BIPOLY(UNPOLY(NT(-1), NT(2)), UNPOLY(NT(0), NT(0), NT(3)), + UNPOLY(NT(0), NT(1)) + ); + + // differentiation + // fx = y^2 + 6xy + 2 + BIPOLY fx = BIPOLY(UNPOLY(NT(2)), UNPOLY(NT(0), NT(6)), + UNPOLY(NT(1)) + ); + + // LCC + assert(CGAL::check_leadcoeff(f0) == true); + assert(CGAL::check_leadcoeff(f) == false); + assert(CGAL::check_leadcoeff(fx) == true); +} + + +template +void trivariate_polynomial_test() { + + + TRIPOLY f0; + assert(CGAL::check_leadcoeff(f0) == true); + + // f1 = xz^2 + 4yz - 2x^2z + 5x - 3y + 8z -6 + TRIPOLY f1 = TRIPOLY( + BIPOLY(UNPOLY(NT(-6), NT(5)), UNPOLY(NT(-3))), + BIPOLY(UNPOLY(NT(8), NT(0), NT(-2)), UNPOLY(NT(4))), + BIPOLY(UNPOLY(NT(0),NT(1))) + ); + + // f2 = 9z^3 + -5yz - 2x^2z + 5x + 8z -6 + TRIPOLY f2 = TRIPOLY( + BIPOLY(UNPOLY(NT(-6), NT(5))), + BIPOLY(UNPOLY(NT(8), NT(0), NT(-2)), UNPOLY(NT(-5))), + BIPOLY(UNPOLY(NT(0))), + BIPOLY(UNPOLY(NT(9))) + ); + + // LCC + assert(CGAL::check_leadcoeff(f1) == false); + assert(CGAL::check_leadcoeff(f2) == true); +} + + +template +void polynomial_functions_test() { + ::CGAL::set_pretty_mode(std::cout); + + //std::cout<<" univariate "<(); + std::cout<<" bivariate "<(); + std::cout<<" trivariate "<(); +} + + +int main(){ +#ifdef CGAL_USE_LEDA + polynomial_functions_test(); +#endif // CGAL_USE_LEDA +#ifdef CGAL_USE_CORE + polynomial_functions_test(); +#endif // CGAL_USE_CORE +} +// EOF