cgal/Algebraic_kernel_d/test/Algebraic_kernel_d/Bitstream_descartes.cpp

92 lines
3.7 KiB
C++

// TODO: Add licence
//
// 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(s) :
//
// ============================================================================
// TODO: The comments are all original EXACUS comments and aren't adapted. So
// they may be wrong now.
/*! \file NiX/Bitstream_descartes.C
This is the test file for the class NiX::Bitstream_descartes.
*/
#include <CGAL/basic.h>
#include <cassert>
// include these traits here by 'hand', since not in release 3.3
#include <CGAL/Algebraic_extension_traits.h>
#include <CGAL/Scalar_factor_traits.h>
#include <CGAL/Polynomial.h>
#include <CGAL/_test_real_root_isolator.h>
#include <CGAL/Algebraic_kernel_d/Bitstream_descartes.h>
#include <CGAL/Algebraic_kernel_d/Algebraic_real_pure.h>
#include <CGAL/Arithmetic_kernel.h>
template <class AT>
void test_descartes(){
typedef typename AT::Integer Integer;
typedef typename AT::Rational Rational;
{
typedef ::CGAL::Polynomial<Integer> Polynomial;
typedef ::CGAL::CGALi::Bitstream_descartes<Polynomial,Rational> Isolator;
// general test of concept RealRootIsolator
CGAL::CGALi::test_real_root_isolator<Isolator>();
}{
typedef ::CGAL::Polynomial<Rational> Polynomial;
typedef ::CGAL::CGALi::Bitstream_descartes<Polynomial,Rational> Isolator;
// general test of concept RealRootIsolator
CGAL::CGALi::test_real_root_isolator<Isolator>();
}{
typedef CGAL::Sqrt_extension<Integer,Integer> EXT;
typedef CGAL::Polynomial<EXT> Polynomial;
typedef CGAL::CGALi::Bitstream_descartes<Polynomial,Rational> Isolator;
CGAL::CGALi::test_real_root_isolator<Isolator>();
std::istringstream is("P[8(0,EXT[1263296571491275162619395552058539312049753537208652637440,42968358109221573436642744060744334362576495937343892480,859])(1,EXT[2207556620237983039471566299950573667219187771717363990528,76852322515373647784745416857429135583058957867416403456,859])(2,EXT[1309275777321138279335848837056750819020098551750287419392,39195296448043974486512553808164864989806318662622537728,859])(3,EXT[86302507833822837152267458208050616275030717971310571520,10003400461933730535898849196215973480541410956350136320,859])(4,EXT[491437197926570070047913809040994179733862944058588160,-823318654055010400576035967724449228967294601081409536,859])(5,EXT[65617171248843379260568930361980285279772972904474353664,-2321236429038088490878641998530459657094667195101177856,859])(6,EXT[-31388640426864731218854617935763549592108582309411053568,1147925677098540153039869220704807888848997763457081344,859])(7,EXT[-9044080753104082029116583549917596926203452476780478464,319259245952387286523925425244746929470795371494383616,859])(8,EXT[7527302869236151900084946597004902733830052515530309632,-256375273905623226297550301204997314964265060295540736,859])]");
Polynomial P;
is >> P ;
Isolator isolator(P);
assert(isolator.number_of_real_roots() == 2 );
typedef CGAL::CGALi::Algebraic_real_pure<EXT,Rational> Alg_real;
Alg_real r0(P,isolator.left_boundary(0),isolator.right_boundary(0));
Alg_real r1(P,isolator.left_boundary(1),isolator.right_boundary(1));
assert(r0 < r1);
assert(r0 > isolator.left_boundary(0));
assert(r0 < isolator.right_boundary(0));
assert(r1 > isolator.left_boundary(1));
assert(r1 < isolator.right_boundary(1));
}
}
int main(){
#ifdef CGAL_USE_LEDA
test_descartes<CGAL::LEDA_arithmetic_kernel>();
#endif
#ifdef CGAL_USE_CORE
test_descartes<CGAL::CORE_arithmetic_kernel>();
#endif
return EXIT_SUCCESS;
}
// EOF