From 3c8e884480d3e8d2929fbb889dcbe80d298c8015 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luis=20Pe=C3=B1aranda?= Date: Thu, 1 Apr 2010 11:26:15 +0000 Subject: [PATCH] updated test programs --- .gitattributes | 2 + .../Algebraic_kernel_rs_gmpq_1.cpp | 129 ++++++++++++++++++ .../Algebraic_kernel_rs_gmpz_1.cpp | 119 ++++++++++++++++ 3 files changed, 250 insertions(+) create mode 100644 Algebraic_kernel_d/test/Algebraic_kernel_d/Algebraic_kernel_rs_gmpq_1.cpp create mode 100644 Algebraic_kernel_d/test/Algebraic_kernel_d/Algebraic_kernel_rs_gmpz_1.cpp diff --git a/.gitattributes b/.gitattributes index e9826ccf3f0..75275a7bdab 100644 --- a/.gitattributes +++ b/.gitattributes @@ -160,6 +160,8 @@ Algebraic_kernel_d/package_info/Algebraic_kernel_RS/description.txt -text Algebraic_kernel_d/package_info/Algebraic_kernel_RS/maintainer -text Algebraic_kernel_d/test/Algebraic_kernel_d/Algebraic_kernel_d_1_RS_Gmpq.cpp -text Algebraic_kernel_d/test/Algebraic_kernel_d/Algebraic_kernel_d_1_RS_Gmpz.cpp -text +Algebraic_kernel_d/test/Algebraic_kernel_d/Algebraic_kernel_rs_gmpq_1.cpp -text +Algebraic_kernel_d/test/Algebraic_kernel_d/Algebraic_kernel_rs_gmpz_1.cpp -text Algebraic_kernel_d/test/Algebraic_kernel_d/CMakeLists.txt -text Algebraic_kernel_d/test/Algebraic_kernel_d/include/CGAL/_test_algebraic_kernel_1.h -text Algebraic_kernel_d/test/Algebraic_kernel_d/io_test.cpp -text diff --git a/Algebraic_kernel_d/test/Algebraic_kernel_d/Algebraic_kernel_rs_gmpq_1.cpp b/Algebraic_kernel_d/test/Algebraic_kernel_d/Algebraic_kernel_rs_gmpq_1.cpp new file mode 100644 index 00000000000..ec22d66f3cb --- /dev/null +++ b/Algebraic_kernel_d/test/Algebraic_kernel_d/Algebraic_kernel_rs_gmpq_1.cpp @@ -0,0 +1,129 @@ +// Copyright (c) 2009,2010 Inria Lorraine (France). All rights reserved. +// +// This file is part of CGAL (www.cgal.org); you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public License as +// published by the Free Software Foundation; version 2.1 of the License. +// See the file LICENSE.LGPL distributed with CGAL. +// +// 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. +// +// $URL$ +// $Id$ +// +// Author: Luis Peņaranda + +#include + +#if defined(CGAL_USE_GMP) && defined(CGAL_USE_MPFI) && defined(CGAL_USE_RS) + +#include +#include "include/CGAL/_test_algebraic_kernel_1.h" + +int main(){ + + typedef CGAL::Algebraic_kernel_rs_gmpq_1 AK; + typedef AK::Polynomial_1 Polynomial_1; + typedef AK::Coefficient Coefficient; + typedef AK::Bound Bound; + typedef AK::Algebraic_real_1 Algebraic_real_1; + typedef AK::Multiplicity_type Multiplicity_type; + + AK ak; + CGAL::test_algebraic_kernel_1(ak); + + AK::Solve_1 solve_1 = ak.solve_1_object(); + Polynomial_1 x = CGAL::shift(AK::Polynomial_1(1),1); + int returnvalue=0; + + // variant using a bool indicating a square free polynomial + // multiplicities are not computed + std::vector roots; + solve_1(CGAL::Gmpq(1,2)*x*x-1,true, std::back_inserter(roots)); + if(roots.size()!=2){ + returnvalue-=1; + std::cerr<<"error 1: the number of roots of"<< + " (1/2)x^2-1 must be 2"<=roots[0] || -1.41<=roots[0] || + 1.41>=roots[1] || 1.42<=roots[1]){ + returnvalue-=2; + std::cerr<<"error 2: the roots of (1/2)x^2-1 are wrong"<< + std::endl; + } + roots.clear(); + + // variant for roots in a given range of a square free polynomial + solve_1((CGAL::Gmpq(1,4)*x*x-CGAL::Gmpq(1,2))*(x*x-3), + true, + Bound(0), + Bound(10), + std::back_inserter(roots)); + if(roots.size()!=2){ + returnvalue-=4; + std::cerr<<"error 3: the number of roots of"<< + " ((1/4)x^2-(1/2))*(x^2-3) between 0 and 10 must be 2" + <=roots[0] || 1.42<=roots[0] || + 1.73>=roots[1] || 1.74<=roots[1]){ + returnvalue-=8; + std::cerr<<"error 4: the roots of ((1/4)x^2-(1/2))*(x^2-3)"<< + " between 0 and 10 are wrong"< > mroots; + solve_1(CGAL::Gmpq(1,4)*x*x-CGAL::Gmpq(1,2),std::back_inserter(mroots)); + if(mroots.size()!=2){ + returnvalue-=16; + std::cerr<<"error 5: the number of roots of"<< + " (1/4)x^2-(1/2) must be 2"<=mroots[0].first || -1.41<=mroots[0].first || + 1.41>=mroots[1].first || 1.42<=mroots[1].first){ + returnvalue-=32; + std::cerr<<"error 6: the roots of (1/4)x^2-(1/2) are wrong"<< + std::endl; + } + if(mroots[0].second!=1 && mroots[1].second!=1){ + returnvalue-=64; + std::cerr<<"error 7: the multiplicities of the"<< + " roots of (1/4)x^2-(1/2) are wrong"<=mroots[0].first || 1.42<=mroots[0].first || + 1.73>=mroots[1].first || 1.74<=mroots[1].first){ + returnvalue-=256; + std::cerr<<"error 9: the roots of (x^2-2)*((1/2)x^2-(3/2))"<< + " are wrong"< + +#include + +#if defined(CGAL_USE_GMP) && defined(CGAL_USE_MPFI) && defined(CGAL_USE_RS) + +#include +#include "include/CGAL/_test_algebraic_kernel_1.h" + + +int main(){ + typedef CGAL::Algebraic_kernel_rs_gmpz_1 AK; + typedef AK::Polynomial_1 Polynomial_1; + typedef AK::Coefficient Coefficient; + typedef AK::Bound Bound; + typedef AK::Algebraic_real_1 Algebraic_real_1; + typedef AK::Multiplicity_type Multiplicity_type; + + AK ak; // an object of Algebraic_kernel_rs_gmpz_1 + CGAL::test_algebraic_kernel_1(ak); + + AK::Solve_1 solve_1 = ak.solve_1_object(); + Polynomial_1 x = CGAL::shift(AK::Polynomial_1(1),1); + int returnvalue=0; + + // variant using a bool indicating a square free polynomial + // multiplicities are not computed + std::vector roots; + solve_1(x*x-2,true, std::back_inserter(roots)); + if(roots.size()!=2){ + returnvalue-=1; + std::cerr<<"error 1: the number of roots of x^2-2 must be 2"<< + std::endl; + } + if(-1.42>=roots[0] || -1.41<=roots[0] || + 1.41>=roots[1] || 1.42<=roots[1]){ + returnvalue-=2; + std::cerr<<"error 2: the roots of x^2-2 are wrong"<=roots[0] || 1.42<=roots[0] || + 1.73>=roots[1] || 1.74<=roots[1]){ + returnvalue-=8; + std::cerr<<"error 4: the roots of (x^2-2)*(x^2-3)"<< + " between 0 and 10 are wrong"< > mroots; + solve_1((x*x-2), std::back_inserter(mroots)); + if(mroots.size()!=2){ + returnvalue-=16; + std::cerr<<"error 5: the number of roots of x^2-2 must be 2"<< + std::endl; + } + if(-1.42>=mroots[0].first || -1.41<=mroots[0].first || + 1.41>=mroots[1].first || 1.42<=mroots[1].first){ + returnvalue-=32; + std::cerr<<"error 6: the roots of x^2-2 are wrong"<=mroots[0].first || 1.42<=mroots[0].first || + 1.73>=mroots[1].first || 1.74<=mroots[1].first){ + returnvalue-=256; + std::cerr<<"error 9: the roots of (x^2-2)*(x^2-3) are wrong"<< + std::endl; + } + if(mroots[0].second!=1 && mroots[1].second!=1){ + returnvalue-=512; + std::cerr<<"error 10: the multiplicities of the roots of"<< + " (x^2-2)*(x^2-3) are wrong"<