From 31ccf278418368bcd2ab5ca8a50dc36e01a7e6bf Mon Sep 17 00:00:00 2001 From: Michael Hemmer Date: Sun, 28 Jun 2009 11:46:10 +0000 Subject: [PATCH] merged two versions for CORE/LEDA back into one file --- .../test/Number_types/Sqrt_extension.cpp | 4 + .../Sqrt_extension_CORE_arithmetic_kernel.cpp | 728 ------------------ 2 files changed, 4 insertions(+), 728 deletions(-) delete mode 100644 Number_types/test/Number_types/Sqrt_extension_CORE_arithmetic_kernel.cpp diff --git a/Number_types/test/Number_types/Sqrt_extension.cpp b/Number_types/test/Number_types/Sqrt_extension.cpp index ac4e193f15e..0ef5cf105b7 100644 --- a/Number_types/test/Number_types/Sqrt_extension.cpp +++ b/Number_types/test/Number_types/Sqrt_extension.cpp @@ -722,6 +722,10 @@ int main(){ #ifdef CGAL_USE_LEDA sqrt_extension_test(); #endif // CGAL_USE_LEDA + +#ifdef CGAL_USE_CORE + sqrt_extension_test(); +#endif // CGAL_USE_CORE return 0; } diff --git a/Number_types/test/Number_types/Sqrt_extension_CORE_arithmetic_kernel.cpp b/Number_types/test/Number_types/Sqrt_extension_CORE_arithmetic_kernel.cpp deleted file mode 100644 index 96a13cbbfe9..00000000000 --- a/Number_types/test/Number_types/Sqrt_extension_CORE_arithmetic_kernel.cpp +++ /dev/null @@ -1,728 +0,0 @@ -#include -#include -#include - -#include -#include -#include -#include -#include -#include - -#include -#include - -// TODO: Included from EXACUS/NumeriX/include/NiX/number_type_utils.h -CGAL_BEGIN_NAMESPACE -template -inline -void convert_to(const NT& x, RT& r){ - typedef CGAL::Coercion_traits CT; - typedef typename CT::Type Type; - BOOST_STATIC_ASSERT((::boost::is_same::value)); - r = typename CT::Cast()(x); -} -CGAL_END_NAMESPACE -// end included from number_type_utils.h - -template -void test_io(const NT& x){ - NT tmp; - std::ostringstream os; - os << x; - std::istringstream is(os.str()); - is >> tmp; - assert( x == tmp ); -} - -template -void constructor_test(){ - typedef typename EXT::NT NT; - typedef typename EXT::ROOT ROOT; - assert(EXT()==EXT((NT)0)); - assert(EXT()==EXT((NT)0,(NT)0,(ROOT)7)); - assert(EXT().is_extended()==false); - // from int - assert(EXT( 1)==EXT((NT) 1,(NT)0,(ROOT)7)); - assert(EXT(-1)==EXT((NT)-1,(NT)0,(ROOT)7)); - assert(EXT( 7)==EXT((NT) 7,(NT)0,(ROOT)7)); - assert(EXT(-7)==EXT((NT)-7,(NT)0,(ROOT)7)); - assert(EXT( 1)+EXT(-1)==EXT()); - assert(EXT(1).is_extended()==false); - // from NT - assert(EXT((NT) 1)==EXT((NT) 1,(NT)0,(ROOT)7)); - assert(EXT((NT)-1)==EXT((NT)-1,(NT)0,(ROOT)7)); - assert(EXT((NT) 7)==EXT((NT) 7,(NT)0,(ROOT)7)); - assert(EXT((NT)-7)==EXT((NT)-7,(NT)0,(ROOT)7)); - assert(EXT((NT) 1)+EXT((NT)-1)==EXT()); - assert(EXT((NT)1).is_extended()==false); - // general constructor - const EXT x(NT(3),NT(4),ROOT(17)); - assert(x.a0()==NT(3)); - assert(x.a1()==NT(4)); - assert(x.root()==ROOT(17)); - assert(x.is_extended()==true); -} - -template -void other_functions_test(){ - typedef typename EXT::NT NT; - typedef typename EXT::ROOT ROOT; - - // is_zero - assert( EXT(NT( 0),NT( 0),ROOT(17)).is_zero()); - assert(!EXT(NT( 3),NT( 0),ROOT(17)).is_zero()); - assert(!EXT(NT(-3),NT( 0),ROOT(17)).is_zero()); - assert(!EXT(NT( 0),NT( 3),ROOT(17)).is_zero()); - assert(!EXT(NT( 0),NT(-3),ROOT(17)).is_zero()); - assert(!EXT(NT(-3),NT(-3),ROOT(17)).is_zero()); - assert( EXT(NT( 0)).is_zero()); - assert(!EXT(NT(-5)).is_zero()); - assert(!EXT(NT( 5)).is_zero()); - assert( EXT(NT( 0),NT( 0),ROOT(4)).is_zero()); - assert(!EXT(NT( 6),NT( 3),ROOT(4)).is_zero()); - assert( EXT(NT( 6),NT(-3),ROOT(4)).is_zero()); - - // abs - { - EXT x = EXT(NT(-3),NT(-3),ROOT(17)); - EXT ax = EXT(NT( 3),NT( 3),ROOT(17)); - assert(x.abs() == ax); - }{ - EXT x = EXT(NT( 3),NT(-3),ROOT(17)); - EXT ax = EXT(NT(-3),NT( 3),ROOT(17)); - assert(x.abs() == ax); - }{ - EXT x = EXT(NT(-3),NT( 3),ROOT(17)); - EXT ax = EXT(NT(-3),NT( 3),ROOT(17)); - assert(x.abs() == ax); - }{ - EXT x = EXT(NT( 3),NT( 3),ROOT(17)); - EXT ax = EXT(NT( 3),NT( 3),ROOT(17)); - assert(x.abs() == ax); - } - // division / integral division in case root is a square - { - EXT x(4,6,4); - EXT y(2,1,4); - assert(x/y ==EXT(4)); - }{ - EXT x(4); - EXT y(2,1,4); - assert(x/y ==EXT(1)); - } -} - -// TODO: No Modular_traits available yet. -/*template - void modular_traits_test(){ - typedef typename EXT::NT NT; - typedef typename EXT::ROOT ROOT; - typedef NiX::Modular_traits MTraits; - typedef typename MTraits::Residue_type EXT_MOD; - - NiX::Residue::set_current_prime(7); - typename MTraits::Modular_image modular_image; - { - EXT a1(13,-10,4); - EXT_MOD a1_mod= modular_image(a1); - assert(a1_mod==EXT_MOD(6,4,4)); - assert(a1_mod.is_zero()); - }{ - EXT a1(13); - EXT_MOD a1_mod= modular_image(a1); - assert(a1_mod==EXT_MOD(6)); - assert(!a1_mod.is_extended()); - } - }*/ - -template -void io_test(){ - typedef typename EXT::NT NT; - typedef typename EXT::ROOT ROOT; - - test_io(EXT(0,0,5)); - test_io(EXT(0,2,5)); - test_io(EXT(4,0,5)); - test_io(EXT(-4,2,5)); - test_io(EXT(4,-2,5)); - test_io(EXT(-4,-2,5)); - test_io(EXT(5)); - - std::ostringstream os; - EXT(0).output_maple(os); // no real test just to instantiate code -} - -void is_exact_test(){ - - typedef CGAL::Tag_true T; - typedef CGAL::Tag_false F; - - { - typedef CGAL::Sqrt_extension NT; - - assert((boost::is_same< CGAL::Algebraic_structure_traits< NT >::Is_exact, - CGAL::Tag_true >::value)); - - } - { - typedef CGAL::Sqrt_extension NT; - - assert((boost::is_same< CGAL::Algebraic_structure_traits< NT >::Is_exact, - CGAL::Tag_false >::value)); - } - { - typedef CGAL::Sqrt_extension NT; - - assert((boost::is_same< CGAL::Algebraic_structure_traits< NT >::Is_exact, - CGAL::Tag_false >::value)); - } - { - typedef CGAL::Sqrt_extension NT; - - assert((boost::is_same< CGAL::Algebraic_structure_traits< NT >::Is_exact, - CGAL::Tag_false >::value)); - } -} - -template -void convert_to_real(){ - typedef CGAL::Sqrt_extension EXT1; - - { - EXT1 ext((NT)3 ,(NT)5 ,(ROOT)17); - REAL real= REAL(3)+REAL(5)*CGAL_NTS sqrt(REAL(17)); - REAL tmp; - CGAL::convert_to(ext,tmp); - assert(tmp==real); - }{ - EXT1 ext((NT)3); - REAL real= REAL(3); - REAL tmp; - CGAL::convert_to(ext,tmp); - assert(tmp==real); - } -} - -template -void convert_to_bfi(){ - typedef CGAL::Sqrt_extension EXT1; - typename CGAL::Bigfloat_interval_traits::Get_precision get_precision; - typename CGAL::Bigfloat_interval_traits::Set_precision set_precision; - long old_precision = get_precision(); - - for(int i = 0; i < 3; i++){ - long precision = old_precision; - for(int p = 0; p < 3; p++){ - set_precision(precision); - { - EXT1 ext((NT)3 ,(NT)5 ,(ROOT)17); - BFI interval= BFI(3)+BFI(5)*CGAL_NTS sqrt(BFI(17)); - BFI tmp = CGAL::convert_to_bfi(ext); - assert(CGAL::overlap(tmp,interval)); - }{ - EXT1 ext((NT)3); - BFI interval= BFI(3); - BFI tmp = CGAL::convert_to_bfi(ext); - assert(CGAL::overlap(tmp,interval)); - } - precision*=2; - } - } - set_precision(old_precision); -} - - -template < class AT> -void sqrt_ext_pretty_output_test(){ - typedef typename AT::Integer Integer; - typedef CGAL::Sqrt_extension EXT1; - typedef CGAL::Sqrt_extension EXT2; - // TEST without Parens_as_product_tag - { - std::stringstream ss; - CGAL::set_pretty_mode(ss); - ss << EXT1(-1,0,2); - assert( ss.str()=="-1"); - }{ - std::stringstream ss; - CGAL::set_pretty_mode(ss); - ss << EXT1(0,0,2); - assert( ss.str() == "0"); - }{ - std::stringstream ss; - CGAL::set_pretty_mode(ss); - ss << EXT1(1,0,2); - assert( ss.str() == "1"); - }{ - std::stringstream ss; - CGAL::set_pretty_mode(ss); - ss << EXT1(1,2,2); - assert( ss.str() == "1+2*sqrt(2)"); - }{ - std::stringstream ss; - CGAL::set_pretty_mode(ss); - ss << EXT1(1,-2,2); - assert( ss.str() == "1+(-2)*sqrt(2)"); - }{ - std::stringstream ss; - CGAL::set_pretty_mode(ss); - ss << EXT1(-1,2,2); - assert( ss.str() == "-1+2*sqrt(2)"); - }{ - std::stringstream ss; - CGAL::set_pretty_mode(ss); - ss << EXT1(-1,-2,2); - assert( ss.str() == "-1+(-2)*sqrt(2)"); - }{ - std::stringstream ss; - CGAL::set_pretty_mode(ss); - ss << EXT1(0,2,2); - assert( ss.str()=="2*sqrt(2)"); - }{ - std::stringstream ss; - CGAL::set_pretty_mode(ss); - ss << EXT1(0,-2,2); - assert( ss.str()=="(-2)*sqrt(2)"); - } -// TEST with Parens_as_product_tag - { - std::stringstream ss; - CGAL::set_pretty_mode(ss); - ss << oformat(EXT1(-1,0,2),CGAL::Parens_as_product_tag()); - assert( ss.str()=="(-1)"); - }{ - std::stringstream ss; - CGAL::set_pretty_mode(ss); - ss << oformat(EXT1(0,0,2),CGAL::Parens_as_product_tag()); - assert( ss.str() == "0"); - }{ - std::stringstream ss; - CGAL::set_pretty_mode(ss); - ss << oformat(EXT1(1,0,2),CGAL::Parens_as_product_tag()); - assert( ss.str() == "1"); - }{ - std::stringstream ss; - CGAL::set_pretty_mode(ss); - ss << oformat(EXT1(1,2,2),CGAL::Parens_as_product_tag()); - assert( ss.str() == "(1+2*sqrt(2))"); - }{ - std::stringstream ss; - CGAL::set_pretty_mode(ss); - ss << oformat(EXT1(1,-2,2),CGAL::Parens_as_product_tag()); - assert( ss.str() == "(1+(-2)*sqrt(2))"); - }{ - std::stringstream ss; - CGAL::set_pretty_mode(ss); - ss << oformat(EXT1(-1,2,2),CGAL::Parens_as_product_tag()); - assert( ss.str() == "(-1+2*sqrt(2))"); - }{ - std::stringstream ss; - CGAL::set_pretty_mode(ss); - ss << oformat(EXT1(-1,-2,2),CGAL::Parens_as_product_tag()); - assert( ss.str() == "(-1+(-2)*sqrt(2))"); - }{ - std::stringstream ss; - CGAL::set_pretty_mode(ss); - ss << oformat(EXT1(0,2,2),CGAL::Parens_as_product_tag()); - assert( ss.str()=="2*sqrt(2)"); - }{ - std::stringstream ss; - CGAL::set_pretty_mode(ss); - ss << oformat(EXT1(0,-2,2),CGAL::Parens_as_product_tag()); - assert( ss.str()=="(-2)*sqrt(2)"); - } -} - - -template -void to_double_test(){ - typedef typename EXT::NT NT; - typedef typename EXT::ROOT ROOT; - typedef CGAL::Real_embeddable_traits NTT; - - typename NTT::To_double to_double; - typename NTT::To_interval to_interval; - - { - NT a0(1); - NT a1(2); - ROOT root(4); - EXT ext(a0,a1,root); - - assert(to_double(ext)==5.0); - assert(to_interval(ext)==CGAL_NTS to_interval(5.0) ); - }{ - NT a0(1); - NT a1(-2); - ROOT root(4); - EXT ext(a0,a1,root); - - assert(to_double(ext)==-3.0); - assert(to_interval(ext)==CGAL_NTS to_interval(-3.0) ); - } -} -template -void general_test(){ - typedef typename CGAL::Algebraic_structure_traits::Is_exact Is_exact; - - typedef CGAL::Sqrt_extension EXT1; - EXT1 a1((NT)3 ,(NT)5 ,(ROOT)17); - EXT1 b1((NT)-2,(NT)3 ,(ROOT)17); - EXT1 c1((NT)7 ,(NT)-11,(ROOT)17); - CGAL::test_algebraic_structure(a1,b1,c1); - CGAL::test_real_embeddable(); - CGAL::test_implicit_interoperable(); - CGAL::test_implicit_interoperable(); - - typedef CGAL::Sqrt_extension EXT2; - EXT2 a2(b1 ,a1 ,(ROOT)19); - EXT2 b2(c1,(EXT1)0 ,(ROOT)19); - EXT2 c2((EXT1)0 ,(EXT1)-11,(ROOT)19); - CGAL::test_algebraic_structure(a2,b2,c2); - CGAL::test_real_embeddable(); - - typedef CGAL::Sqrt_extension EXT3; - EXT3 a3(b2 ,a2 ,(ROOT)23); - EXT3 b3(c2,(EXT2)0 ,(ROOT)23); - EXT3 c3((EXT2)0 ,(EXT2)-11,(ROOT)23); - CGAL::test_algebraic_structure(a3,b3,c3); - CGAL::test_real_embeddable(); - - constructor_test(); - constructor_test(); - constructor_test(); - - other_functions_test(); - other_functions_test(); - other_functions_test(); - - // TODO: No modular traits available -// modular_traits_test(); -// modular_traits_test(); -// modular_traits_test(); - - io_test(); - io_test(); - io_test(); - - to_double_test(); -} - - - -template -void fraction_traits_test(){ - //TEST Type traits ROOT of type INT - typedef typename AT::Integer INT; - typedef typename AT::Rational RAT; - - typedef CGAL::Sqrt_extension RAT1_EXT; - typedef CGAL::Sqrt_extension INT1_EXT; - typedef CGAL::Sqrt_extension RAT2_EXT; - typedef CGAL::Sqrt_extension INT2_EXT; - typedef CGAL::Sqrt_extension RAT3_EXT; - typedef CGAL::Sqrt_extension INT3_EXT; - - typedef CGAL::Fraction_traits RAT_FT1; - typedef CGAL::Fraction_traits RAT_FT2; - typedef CGAL::Fraction_traits RAT_FT3; - - typedef CGAL::Fraction_traits INT_FT1; - typedef CGAL::Fraction_traits INT_FT2; - typedef CGAL::Fraction_traits INT_FT3; - - // RAT_FTs decomposable - assert((boost::is_same< typename RAT_FT1::Is_fraction, - CGAL::Tag_true>::value)); - assert((boost::is_same< typename RAT_FT2::Is_fraction, - CGAL::Tag_true>::value)); - assert((boost::is_same< typename RAT_FT3::Is_fraction, - CGAL::Tag_true>::value)); - // RAT_FTi Numerator_type == INTi_EXT - assert((boost::is_same< typename RAT_FT1::Numerator_type, - INT1_EXT>::value)); - assert((boost::is_same< typename RAT_FT2::Numerator_type, - INT2_EXT>::value)); - assert((boost::is_same< typename RAT_FT3::Numerator_type, - INT3_EXT>::value)); - // RAT_FTi Denomiantor == INT - assert((boost::is_same< typename RAT_FT1::Denominator_type, - INT>::value)); - assert((boost::is_same< typename RAT_FT2::Denominator_type, - INT>::value)); - assert((boost::is_same< typename RAT_FT3::Denominator_type, - INT>::value)); - - // INT_FTs not decomposable - assert((boost::is_same< typename INT_FT1::Is_fraction, - CGAL::Tag_false>::value)); - assert((boost::is_same< typename INT_FT2::Is_fraction, - CGAL::Tag_false>::value)); - assert((boost::is_same< typename INT_FT2::Is_fraction, - CGAL::Tag_false>::value)); - { - typedef CGAL::Sqrt_extension RAT_RAT_EXT; - typedef CGAL::Fraction_traits RAT_RAT_FT; - assert((boost::is_same< typename RAT_RAT_FT::Is_fraction, - CGAL::Tag_false>::value)); - }{ - typedef CGAL::Sqrt_extension INT_nEXT; - typedef CGAL::Fraction_traits INT_nEXT_FT; - assert((boost::is_same< typename INT_nEXT_FT::Is_fraction, - CGAL::Tag_false>::value)); - } - - { - // Semantic for RAT1_EXT - RAT1_EXT a(RAT(3)/RAT(10),RAT(4)/RAT(15),INT(5)); - typename RAT_FT1::Decompose decompose; - typename RAT_FT1::Numerator_type num; - typename RAT_FT1::Denominator_type den; - decompose(a,num,den); - assert(num==typename RAT_FT1::Numerator_type(INT(9),INT(8),INT(5))); - assert(den==typename RAT_FT1::Denominator_type(INT(30))); - typename RAT_FT1::Compose compose; - assert(a==compose(num,den)); - { - RAT1_EXT a(RAT(3)/RAT(10)); - decompose(a,num,den); - assert(num==typename RAT_FT1::Numerator_type(INT(3))); - assert(den==typename RAT_FT1::Denominator_type(INT(10))); - assert(!num.is_extended()); - } - } - { - // Semantic RAT2_EXT - RAT1_EXT a0(RAT(3)/RAT(10),RAT(4)/RAT(15),INT(5)); - RAT1_EXT a1(RAT(7)/RAT(3),RAT(5)/RAT(7),INT(5)); - RAT2_EXT a(a0,a1,INT(7)); - typename RAT_FT2::Decompose decompose; - typename RAT_FT2::Numerator_type num; - typename RAT_FT2::Denominator_type den; - decompose(a,num,den); - assert(num==INT2_EXT(INT1_EXT(INT(63),INT(56),INT(5)), - INT1_EXT(INT(490),INT(150),INT(5)), - INT(7))); - assert(den==typename RAT_FT2::Denominator_type(INT(210))); - typename RAT_FT2::Compose compose; - assert(a==compose(num,den)); - } - - -} - -// this includes Scalar_factor_traits -// this includes Algebraic_extension_traits - -template -void scalar_factor_traits_test(){ - { - typedef typename AT::Integer Integer; - typedef CGAL::Sqrt_extension EXT1; - typedef CGAL::Sqrt_extension EXT2; - - { - typedef CGAL::Scalar_factor_traits SFT; - typedef typename SFT::Scalar Scalar; - typename SFT::Scalar_factor sfac; - typename SFT::Scalar_div sdiv; - - assert( (boost::is_same::value) ); - - assert((sfac(EXT1(0)))==Integer(0)); - assert((sfac(EXT1(3)))==Integer(3)); - assert((sfac(EXT1(0,3,2)))==Integer(3)); - assert((sfac(EXT1(6,9,2)))==Integer(3)); - EXT1 tmp; - tmp = EXT1(3); sdiv(tmp,sfac(tmp)); assert(tmp==EXT1(1)); - tmp = EXT1(0,3,2); sdiv(tmp,sfac(tmp)); assert(tmp==EXT1(0,1,2)); - tmp = EXT1(6,9,2); sdiv(tmp,sfac(tmp)); assert(tmp==EXT1(2,3,2)); - } - { - typedef CGAL::Scalar_factor_traits SFT; - typedef typename SFT::Scalar Scalar; - typename SFT::Scalar_factor sfac; - typename SFT::Scalar_div sdiv; - - assert( (boost::is_same::value) ); - - assert((sfac(EXT2(0)))==Integer(0)); - assert((sfac(EXT2(3)))==Integer(3)); - assert((sfac(EXT2(EXT1(0),EXT1(3),2)))==Integer(3)); - assert((sfac(EXT2(EXT1(6),EXT1(9),2)))==Integer(3)); - EXT2 tmp; - tmp = EXT2(3); sdiv(tmp,sfac(tmp)); assert(tmp==EXT2(1)); - tmp = EXT2(0,3,2); sdiv(tmp,sfac(tmp)); assert(tmp==EXT2(0,1,2)); - tmp = EXT2(6,9,2); sdiv(tmp,sfac(tmp)); assert(tmp==EXT2(2,3,2)); - } - { - typedef CGAL::Scalar_factor_traits SFT; - typedef typename SFT::Scalar Scalar; - typename SFT::Scalar_factor sfac; - - assert( (boost::is_same::value) ); - - assert((sfac(EXT1(0))) ==Integer(0)); - assert((sfac(EXT1(9),Integer(15))) ==Integer(3)); - assert((sfac(EXT1(0,9,2),Integer(15))) ==Integer(3)); - assert((sfac(EXT1(18,9,2),Integer(15)))==Integer(3)); - } - } -} - -template -void test_algebraic_extension_traits(){ - typedef typename AT::Integer INT; - typedef typename AT::Rational RAT; - - typedef CGAL::Sqrt_extension RAT1_EXT; - typedef CGAL::Sqrt_extension INT1_EXT; - typedef CGAL::Sqrt_extension RAT2_EXT; - typedef CGAL::Sqrt_extension INT2_EXT; - - // normalisation factor - typedef CGAL::Algebraic_extension_traits RAT1_EXT_ANT; - typedef CGAL::Algebraic_extension_traits INT1_EXT_ANT; - typedef CGAL::Algebraic_extension_traits RAT2_EXT_ANT; - typedef CGAL::Algebraic_extension_traits INT2_EXT_ANT; - - { - INT1_EXT a(INT(3),INT(5),INT(7)); - typename INT1_EXT_ANT::Normalization_factor normalization_factor; - INT1_EXT r=normalization_factor(a); - assert(r.a0() ==INT( 3)); - assert(r.a1() ==INT(-5)); - assert(r.root() ==INT( 7)); - assert((r*a).a1()==INT( 0)); - }{ - RAT1_EXT a(RAT(3)/RAT(5),RAT(5)/RAT(11),INT(7)); - typename RAT1_EXT_ANT::Normalization_factor normalization_factor; - RAT1_EXT r=normalization_factor(a); - assert((r*a).a1()==RAT( 0)); - }{ - INT1_EXT a0(4,3,7); - INT1_EXT a1(8,9,7); - INT root(5); - INT2_EXT a(a0,a1,root); - typename INT2_EXT_ANT::Normalization_factor normalization_factor; - INT2_EXT r=normalization_factor(a); - - assert((r*a).a1()==INT1_EXT(0)); - assert((r*a).a0().a1()==INT(0)); - }{ - RAT1_EXT a0(4,3,7); - RAT1_EXT a1(8,9,7); - INT root(5); - RAT2_EXT a(a0,a1,root); - typename RAT2_EXT_ANT::Normalization_factor normalization_factor; - RAT2_EXT r=normalization_factor(a); - assert((r*a).a1()== RAT1_EXT(0)); - assert((r*a).a0().a1()==RAT(0)); - }{ - INT1_EXT a(INT(3)); - typename INT1_EXT_ANT::Normalization_factor normalization_factor; - INT1_EXT r=normalization_factor(a); - assert(r.a0() ==INT(1)); - assert(r.a1() ==INT(0)); - assert(r.root() ==INT(0)); - assert(!(r*a).is_extended()); - } - - // denomiantor for algebraic integers - { - typedef typename AT::Integer Integer; - typedef CGAL::Sqrt_extension Extn_1; - typedef CGAL::Algebraic_extension_traits ANT; - typename ANT::Denominator_for_algebraic_integers dfai; - Extn_1 ext(1,2,5); - assert(dfai(ext)==Extn_1(20)); - }{ - typedef typename AT::Integer Integer; - typedef CGAL::Sqrt_extension Extn_1; - typedef CGAL::Sqrt_extension Extn_2; - typedef CGAL::Algebraic_extension_traits ANT; - typename ANT::Denominator_for_algebraic_integers dfai; - { - Extn_1 a0(1); - Extn_1 a1(2); - Integer root(5); - Extn_2 ext(a0,a1,root); - assert(dfai(ext)==Extn_2(20)); - - }{ - Extn_1 a0(1,2,5); - Extn_1 a1(2,3,5); - Integer root(7); - Extn_2 ext(a0,a1,root); - assert(dfai(ext)==Extn_2(20 *28)); - } - }{ - typedef typename AT::Integer Integer; - typedef CGAL::Sqrt_extension Extn_1; - typedef CGAL::Sqrt_extension Extn_2; - typedef CGAL::Algebraic_extension_traits ANT; - typename ANT::Denominator_for_algebraic_integers dfai; - { - Extn_1 a0(1); - Extn_1 a1(2); - Extn_1 root(5); - Extn_2 ext(a0,a1,root); - assert(dfai(ext)==Extn_2(20)); - - }{ - Extn_1 a0(1,2,5); - Extn_1 a1(2,3,5); - Extn_1 root(7); - Extn_2 ext(a0,a1,root); - assert(dfai(ext)==Extn_2(20 *28)); - }{ - Extn_1 a0(1,2,5); - Extn_1 a1(2,3,5); - Extn_1 root(4,5,5); - Extn_2 ext(a0,a1,root); - assert(dfai(ext)==Extn_2(20)*Extn_2(4)*Extn_2(Extn_1(4,5,5))); - } - { - - std::vector vec; - Extn_1 root(Extn_1(2,3,5)); - vec.push_back(Extn_2(0)); - assert(dfai(vec.begin(),vec.end())== Extn_2(1)); - vec.push_back(Extn_2(root)); - assert(dfai(vec.begin(),vec.end())== Extn_2(20)); - vec.push_back(Extn_2(Extn_1(1),Extn_1(3),root)); - assert(dfai(vec.begin(),vec.end())== Extn_2(20)*Extn_2(root)*Extn_2(4)); - } - - } -} - -template -void sqrt_extension_test(){ - CGAL_SNAP_ARITHMETIC_KERNEL_TYPEDEFS(AT); - - general_test(); - general_test(); - - is_exact_test(); - convert_to_real(); - - convert_to_bfi(); - - - sqrt_ext_pretty_output_test(); - fraction_traits_test(); - - scalar_factor_traits_test(); - test_algebraic_extension_traits(); -} - -int main(){ -#ifdef CGAL_USE_CORE - sqrt_extension_test(); -#endif // CGAL_USE_CORE - return 0; -} - -