- Sign_at/Sign_at_homogeneous/Compare are Null_functor if

ICoeff is not RealEmbeddable
- simplified layout for tests
This commit is contained in:
Michael Hemmer 2008-07-22 08:25:53 +00:00
parent 92a0d3cc1d
commit b67232dc3d
2 changed files with 1268 additions and 1289 deletions

View File

@ -135,10 +135,8 @@ public:
// Multivariate_content; // Multivariate_content;
struct Multivariate_content struct Multivariate_content
: public Unary_function< Polynomial_d , Innermost_coefficient >{ : public Unary_function< Polynomial_d , Innermost_coefficient >{
Innermost_coefficient Innermost_coefficient operator()(const Polynomial_d& p) const {
operator()(const Polynomial_d& p) const { if( CGAL::is_zero(p) )
typename PT::Compare compare;
if( compare( p, Polynomial_d(0) ) == EQUAL )
return Innermost_coefficient(0); return Innermost_coefficient(0);
else else
return Innermost_coefficient(1); return Innermost_coefficient(1);
@ -933,15 +931,18 @@ public:
} }
}; };
// Sign_at; // Sign_at, Sign_at_homogeneous, Compare
struct Sign_at { // define XXX_ even though ICoeff may not be Real_embeddable
// select propoer XXX among XXX_ or Null_functor using ::boost::mpl::if_
private:
struct Sign_at_ {
private: private:
typedef Real_embeddable_traits<Innermost_coefficient> RT; typedef Real_embeddable_traits<Innermost_coefficient> RT;
typedef typename RT::Sign::result_type SIGN; typedef typename RT::Sign::result_type SIGN;
public: public:
typedef SIGN result_type; typedef SIGN result_type;
template< class Input_iterator >
template< class Input_iterator >
SIGN operator()( SIGN operator()(
const Polynomial_d& p, const Polynomial_d& p,
Input_iterator begin, Input_iterator begin,
@ -952,7 +953,7 @@ public:
} }
}; };
struct Sign_at_homogeneous { struct Sign_at_homogeneous_ {
typedef Real_embeddable_traits<Innermost_coefficient> RT; typedef Real_embeddable_traits<Innermost_coefficient> RT;
typedef typename RT::Sign::result_type SIGN; typedef typename RT::Sign::result_type SIGN;
public: public:
@ -969,7 +970,7 @@ public:
}; };
// Compare; // Compare;
struct Compare struct Compare_
: public Binary_function< Comparison_result, Polynomial_d, Polynomial_d > { : public Binary_function< Comparison_result, Polynomial_d, Polynomial_d > {
Comparison_result operator() Comparison_result operator()
( const Polynomial_d& p1, const Polynomial_d& p2 ) const { ( const Polynomial_d& p1, const Polynomial_d& p2 ) const {
@ -977,6 +978,15 @@ public:
} }
}; };
typedef Real_embeddable_traits<Innermost_coefficient> RET_IC;
typedef typename RET_IC::Is_real_embeddable IC_is_real_embeddable;
public:
typedef typename ::boost::mpl::if_<IC_is_real_embeddable,Sign_at_,Null_functor>::type Sign_at;
typedef typename ::boost::mpl::if_<IC_is_real_embeddable,Sign_at_homogeneous_,Null_functor>::type Sign_at_homogeneous;
typedef typename ::boost::mpl::if_<IC_is_real_embeddable,Compare_,Null_functor>::type Compare;
// This is going to be in PolynomialToolBox // This is going to be in PolynomialToolBox
struct Coefficient_begin struct Coefficient_begin
: public Unary_function< Polynomial_d, Coefficient_iterator > { : public Unary_function< Polynomial_d, Coefficient_iterator > {

View File

@ -1,3 +1,17 @@
// 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) : Michael Hemmer <hemmer@informatik.uni-mainz.de>
// Sebastian Limbach <slimbach@mpi-inf.mpg.de>
//
// ============================================================================
#include <iostream> #include <iostream>
#include <CGAL/basic.h> #include <CGAL/basic.h>
@ -27,6 +41,9 @@ static CGAL::Random my_rnd(346); // some seed
typedef std::pair< CGAL::Exponent_vector , ICoeff > Monom; \ typedef std::pair< CGAL::Exponent_vector , ICoeff > Monom; \
typedef std::vector< Monom > Monom_rep; typedef std::vector< Monom > Monom_rep;
#define ASSERT_IS_NULL_FUNCTOR(T) \
BOOST_STATIC_ASSERT((boost::is_same<T,CGAL::Null_functor >::value))
template <class Polynomial_d_> template <class Polynomial_d_>
Polynomial_d_ Polynomial_d_
generate_sparse_random_polynomial(int max_degree = 10){ generate_sparse_random_polynomial(int max_degree = 10){
@ -61,7 +78,7 @@ generate_sparse_random_polynomial(int max_degree = 10){
template <class Polynomial_traits_d> template <class Polynomial_traits_d>
void test_construct_polynomial(){ void test_construct_polynomial(const Polynomial_traits_d&){
std::cerr << "start test_construct_polynomial "; std::cerr << "start test_construct_polynomial ";
std::cerr.flush(); std::cerr.flush();
CGAL_SNAP_CGALi_TRAITS_D(Polynomial_traits_d); CGAL_SNAP_CGALi_TRAITS_D(Polynomial_traits_d);
@ -130,7 +147,7 @@ void test_construct_polynomial(){
} }
template< class Polynomial_traits_d > template< class Polynomial_traits_d >
void test_get_coefficient() { void test_get_coefficient(const Polynomial_traits_d&) {
std::cerr << "start test_get_coefficient "; std::cerr << "start test_get_coefficient ";
std::cerr.flush(); std::cerr.flush();
CGAL_SNAP_CGALi_TRAITS_D(Polynomial_traits_d); CGAL_SNAP_CGALi_TRAITS_D(Polynomial_traits_d);
@ -148,7 +165,7 @@ void test_get_coefficient() {
} }
template< class Polynomial_traits_d > template< class Polynomial_traits_d >
void test_get_innermost_coefficient() { void test_get_innermost_coefficient(const Polynomial_traits_d&) {
std::cerr << "start test_get_innermost_coefficient "; std::cerr << "start test_get_innermost_coefficient ";
std::cerr.flush(); std::cerr.flush();
CGAL_SNAP_CGALi_TRAITS_D(Polynomial_traits_d); CGAL_SNAP_CGALi_TRAITS_D(Polynomial_traits_d);
@ -183,7 +200,7 @@ void test_get_innermost_coefficient() {
} }
template <class Polynomial_traits_d> template <class Polynomial_traits_d>
void test_get_monom_representation(){ void test_get_monom_representation(const Polynomial_traits_d&){
std::cerr << "start test_get_monom_representation "; std::cerr << "start test_get_monom_representation ";
std::cerr.flush(); std::cerr.flush();
CGAL_SNAP_CGALi_TRAITS_D(Polynomial_traits_d); CGAL_SNAP_CGALi_TRAITS_D(Polynomial_traits_d);
@ -209,7 +226,7 @@ void test_get_monom_representation(){
template <class Polynomial_traits_d> template <class Polynomial_traits_d>
void test_swap(){ void test_swap(const Polynomial_traits_d&){
std::cerr << "start test_swap "; std::cerr.flush(); std::cerr << "start test_swap "; std::cerr.flush();
CGAL_SNAP_CGALi_TRAITS_D(Polynomial_traits_d); CGAL_SNAP_CGALi_TRAITS_D(Polynomial_traits_d);
int d = PT::d; int d = PT::d;
@ -256,7 +273,7 @@ void test_swap(){
template <class Polynomial_traits_d> template <class Polynomial_traits_d>
void test_move(){ void test_move(const Polynomial_traits_d&){
std::cerr << "start test_move "; std::cerr.flush(); std::cerr << "start test_move "; std::cerr.flush();
CGAL_SNAP_CGALi_TRAITS_D(Polynomial_traits_d); CGAL_SNAP_CGALi_TRAITS_D(Polynomial_traits_d);
typename Polynomial_traits_d::Move move; typename Polynomial_traits_d::Move move;
@ -285,7 +302,7 @@ void test_move(){
} }
template <class Polynomial_traits_d> template <class Polynomial_traits_d>
void test_degree(){ void test_degree(const Polynomial_traits_d&){
std::cerr << "start test_degree "; std::cerr.flush(); std::cerr << "start test_degree "; std::cerr.flush();
CGAL_SNAP_CGALi_TRAITS_D(Polynomial_traits_d); CGAL_SNAP_CGALi_TRAITS_D(Polynomial_traits_d);
@ -315,7 +332,7 @@ void test_degree(){
// Total_degree; // Total_degree;
template <class Polynomial_traits_d> template <class Polynomial_traits_d>
void test_total_degree(){ void test_total_degree(const Polynomial_traits_d&){
std::cerr << "start test_total_degree "; std::cerr.flush(); std::cerr << "start test_total_degree "; std::cerr.flush();
CGAL_SNAP_CGALi_TRAITS_D(Polynomial_traits_d); CGAL_SNAP_CGALi_TRAITS_D(Polynomial_traits_d);
@ -331,7 +348,7 @@ void test_total_degree(){
} }
// // Leading_coefficient; // // Leading_coefficient;
template <class Polynomial_traits_d> template <class Polynomial_traits_d>
void test_leading_coefficient(){ void test_leading_coefficient(const Polynomial_traits_d&){
std::cerr << "start test_leading_coefficient "; std::cerr.flush(); std::cerr << "start test_leading_coefficient "; std::cerr.flush();
CGAL_SNAP_CGALi_TRAITS_D(Polynomial_traits_d); CGAL_SNAP_CGALi_TRAITS_D(Polynomial_traits_d);
@ -347,7 +364,7 @@ void test_leading_coefficient(){
} }
template< class Polynomial_traits_d > template< class Polynomial_traits_d >
void test_innermost_leading_coefficient() { void test_innermost_leading_coefficient(const Polynomial_traits_d&) {
std::cerr << "start test_innermost_leading_coefficient "; std::cerr.flush(); std::cerr << "start test_innermost_leading_coefficient "; std::cerr.flush();
CGAL_SNAP_CGALi_TRAITS_D(Polynomial_traits_d); CGAL_SNAP_CGALi_TRAITS_D(Polynomial_traits_d);
@ -361,7 +378,7 @@ void test_innermost_leading_coefficient() {
// // Univariate_content; // // Univariate_content;
template <class Polynomial_traits_d> template <class Polynomial_traits_d>
void test_univariate_content(){ void test_univariate_content(const Polynomial_traits_d&){
std::cerr << "start test_univariate_content "; std::cerr.flush(); std::cerr << "start test_univariate_content "; std::cerr.flush();
CGAL_SNAP_CGALi_TRAITS_D(Polynomial_traits_d); CGAL_SNAP_CGALi_TRAITS_D(Polynomial_traits_d);
@ -393,7 +410,7 @@ void test_univariate_content(){
} }
// // Multivariate_content; // // Multivariate_content;
template <class Polynomial_traits_d> template <class Polynomial_traits_d>
void test_multivariate_content(){ void test_multivariate_content(const Polynomial_traits_d&){
std::cerr << "start test_multivariate_content "; std::cerr << "start test_multivariate_content ";
std::cerr.flush(); std::cerr.flush();
CGAL_SNAP_CGALi_TRAITS_D(Polynomial_traits_d); CGAL_SNAP_CGALi_TRAITS_D(Polynomial_traits_d);
@ -430,7 +447,7 @@ void test_multivariate_content(){
// // Multivariate_content; // // Multivariate_content;
template <class Polynomial_traits_d> template <class Polynomial_traits_d>
void test_interpolate(){ void test_interpolate(const Polynomial_traits_d&){
std::cerr << "start test_interpolate "; std::cerr.flush(); std::cerr << "start test_interpolate "; std::cerr.flush();
typedef Polynomial_traits_d PT_d; typedef Polynomial_traits_d PT_d;
typedef typename PT_d::Innermost_coefficient ICoeff; typedef typename PT_d::Innermost_coefficient ICoeff;
@ -475,7 +492,7 @@ void test_interpolate(){
// // Shift; // // Shift;
template <class Polynomial_traits_d> template <class Polynomial_traits_d>
void test_shift(){ void test_shift(const Polynomial_traits_d&){
std::cerr << "start test_shift "; std::cerr.flush(); std::cerr << "start test_shift "; std::cerr.flush();
CGAL_SNAP_CGALi_TRAITS_D(Polynomial_traits_d); CGAL_SNAP_CGALi_TRAITS_D(Polynomial_traits_d);
@ -490,7 +507,7 @@ void test_shift(){
} }
// // Negate; // // Negate;
template <class Polynomial_traits_d> template <class Polynomial_traits_d>
void test_negate(){ void test_negate(const Polynomial_traits_d&){
std::cerr << "start test_negate "; std::cerr.flush(); std::cerr << "start test_negate "; std::cerr.flush();
CGAL_SNAP_CGALi_TRAITS_D(Polynomial_traits_d); CGAL_SNAP_CGALi_TRAITS_D(Polynomial_traits_d);
typename PT::Construct_polynomial construct; typename PT::Construct_polynomial construct;
@ -514,7 +531,7 @@ void test_negate(){
} }
// Invert; // Invert;
template <class Polynomial_traits_d> template <class Polynomial_traits_d>
void test_invert(){ void test_invert(const Polynomial_traits_d&){
std::cerr << "start test_invert "; std::cerr.flush(); std::cerr << "start test_invert "; std::cerr.flush();
CGAL_SNAP_CGALi_TRAITS_D(Polynomial_traits_d); CGAL_SNAP_CGALi_TRAITS_D(Polynomial_traits_d);
typename PT::Invert invert; typename PT::Invert invert;
@ -537,7 +554,7 @@ void test_invert(){
} }
// // Translate; // // Translate;
template <class Polynomial_traits_d> template <class Polynomial_traits_d>
void test_translate(){ void test_translate(const Polynomial_traits_d&){
std::cerr << "start test_translate "; std::cerr.flush(); std::cerr << "start test_translate "; std::cerr.flush();
CGAL_SNAP_CGALi_TRAITS_D(Polynomial_traits_d); CGAL_SNAP_CGALi_TRAITS_D(Polynomial_traits_d);
typename PT::Translate translate; typename PT::Translate translate;
@ -555,7 +572,7 @@ void test_translate(){
// // Translate_homogeneous; // // Translate_homogeneous;
template <class Polynomial_traits_d> template <class Polynomial_traits_d>
void test_translate_homongenous(){ void test_translate_homongenous(const Polynomial_traits_d&){
std::cerr << "start test_translate_homongenous "; std::cerr.flush(); std::cerr << "start test_translate_homongenous "; std::cerr.flush();
CGAL_SNAP_CGALi_TRAITS_D(Polynomial_traits_d); CGAL_SNAP_CGALi_TRAITS_D(Polynomial_traits_d);
typename PT::Translate_homogeneous transh; typename PT::Translate_homogeneous transh;
@ -585,7 +602,7 @@ void test_translate_homongenous(){
} }
template< class Polynomial_traits_d> template< class Polynomial_traits_d>
void test_scale() { void test_scale(const Polynomial_traits_d&) {
(std::cerr << "start test_scale ").flush(); (std::cerr << "start test_scale ").flush();
CGAL_SNAP_CGALi_TRAITS_D(Polynomial_traits_d); CGAL_SNAP_CGALi_TRAITS_D(Polynomial_traits_d);
@ -601,7 +618,7 @@ void test_scale() {
// // Scale_homogeneous; // // Scale_homogeneous;
template <class Polynomial_traits_d> template <class Polynomial_traits_d>
void test_scale_homogeneous(){ void test_scale_homogeneous(const Polynomial_traits_d&){
std::cerr << "start test_scale_homogeneous "; std::cerr.flush(); std::cerr << "start test_scale_homogeneous "; std::cerr.flush();
CGAL_SNAP_CGALi_TRAITS_D(Polynomial_traits_d); CGAL_SNAP_CGALi_TRAITS_D(Polynomial_traits_d);
typename PT::Scale_homogeneous scaleh; typename PT::Scale_homogeneous scaleh;
@ -628,7 +645,7 @@ void test_scale_homogeneous(){
// // Derivative; // // Derivative;
template <class Polynomial_traits_d> template <class Polynomial_traits_d>
void test_derivative(){ void test_derivative(const Polynomial_traits_d&){
std::cerr << "start test_derivative "; std::cerr.flush(); std::cerr << "start test_derivative "; std::cerr.flush();
CGAL_SNAP_CGALi_TRAITS_D(Polynomial_traits_d); CGAL_SNAP_CGALi_TRAITS_D(Polynomial_traits_d);
@ -651,7 +668,7 @@ void test_derivative(){
// // Make_square_free; // // Make_square_free;
template <class Polynomial_traits_d> template <class Polynomial_traits_d>
void test_make_square_free(){ void test_make_square_free(const Polynomial_traits_d&){
std::cerr << "start test_make_square_free "; std::cerr.flush(); std::cerr << "start test_make_square_free "; std::cerr.flush();
CGAL_SNAP_CGALi_TRAITS_D(Polynomial_traits_d); CGAL_SNAP_CGALi_TRAITS_D(Polynomial_traits_d);
typename PT::Make_square_free make_square_free; typename PT::Make_square_free make_square_free;
@ -685,7 +702,7 @@ void test_make_square_free(){
// // Square_free_factorization; // // Square_free_factorization;
template <class Polynomial_traits_d> template <class Polynomial_traits_d>
void test_square_free_factorization(){ void test_square_free_factorization(const Polynomial_traits_d&){
std::cerr << "start test_square_free_factorization "; std::cerr.flush(); std::cerr << "start test_square_free_factorization "; std::cerr.flush();
CGAL_SNAP_CGALi_TRAITS_D(Polynomial_traits_d); CGAL_SNAP_CGALi_TRAITS_D(Polynomial_traits_d);
typedef CGAL::Algebraic_structure_traits<Polynomial_d> AST; typedef CGAL::Algebraic_structure_traits<Polynomial_d> AST;
@ -749,7 +766,7 @@ void test_square_free_factorization(){
} }
// // Pseudo_division; // // Pseudo_division;
template <class Polynomial_traits_d> template <class Polynomial_traits_d>
void test_pseudo_division(){ void test_pseudo_division(const Polynomial_traits_d&){
std::cerr << "start test_pseudo_division "; std::cerr.flush(); std::cerr << "start test_pseudo_division "; std::cerr.flush();
CGAL_SNAP_CGALi_TRAITS_D(Polynomial_traits_d); CGAL_SNAP_CGALi_TRAITS_D(Polynomial_traits_d);
typename PT::Pseudo_division pdiv; typename PT::Pseudo_division pdiv;
@ -766,7 +783,7 @@ void test_pseudo_division(){
// // Pseudo_division_remainder; // // Pseudo_division_remainder;
template <class Polynomial_traits_d> template <class Polynomial_traits_d>
void test_pseudo_division_remainder(){ void test_pseudo_division_remainder(const Polynomial_traits_d&){
std::cerr << "start test_pseudo_division_remainder "; std::cerr.flush(); std::cerr << "start test_pseudo_division_remainder "; std::cerr.flush();
CGAL_SNAP_CGALi_TRAITS_D(Polynomial_traits_d); CGAL_SNAP_CGALi_TRAITS_D(Polynomial_traits_d);
typename PT::Pseudo_division pdiv; typename PT::Pseudo_division pdiv;
@ -784,7 +801,7 @@ void test_pseudo_division_remainder(){
// // Pseudo_division_quotient; // // Pseudo_division_quotient;
template <class Polynomial_traits_d> template <class Polynomial_traits_d>
void test_pseudo_division_quotient(){ void test_pseudo_division_quotient(const Polynomial_traits_d&){
std::cerr << "start test_pseudo_division_quotient "; std::cerr.flush(); std::cerr << "start test_pseudo_division_quotient "; std::cerr.flush();
CGAL_SNAP_CGALi_TRAITS_D(Polynomial_traits_d); CGAL_SNAP_CGALi_TRAITS_D(Polynomial_traits_d);
typename PT::Pseudo_division pdiv; typename PT::Pseudo_division pdiv;
@ -802,7 +819,7 @@ void test_pseudo_division_quotient(){
// // Gcd_up_to_constant_factor; // // Gcd_up_to_constant_factor;
template <class Polynomial_traits_d> template <class Polynomial_traits_d>
void test_gcd_up_to_constant_factor(){ void test_gcd_up_to_constant_factor(const Polynomial_traits_d&){
std::cerr << "start test_gcd_up_to_constant_factor "; std::cerr.flush(); std::cerr << "start test_gcd_up_to_constant_factor "; std::cerr.flush();
CGAL_SNAP_CGALi_TRAITS_D(Polynomial_traits_d); CGAL_SNAP_CGALi_TRAITS_D(Polynomial_traits_d);
typename PT::Gcd_up_to_constant_factor gcd_utcf; typename PT::Gcd_up_to_constant_factor gcd_utcf;
@ -825,7 +842,7 @@ void test_gcd_up_to_constant_factor(){
// // Integral_division_up_to_constant_factor; // // Integral_division_up_to_constant_factor;
template <class Polynomial_traits_d> template <class Polynomial_traits_d>
void test_integral_division_up_to_constant_factor(){ void test_integral_division_up_to_constant_factor(const Polynomial_traits_d&){
std::cerr << "start test_integral_division_up_to_constant_factor "; std::cerr << "start test_integral_division_up_to_constant_factor ";
std::cerr.flush(); std::cerr.flush();
CGAL_SNAP_CGALi_TRAITS_D(Polynomial_traits_d); CGAL_SNAP_CGALi_TRAITS_D(Polynomial_traits_d);
@ -849,7 +866,7 @@ void test_integral_division_up_to_constant_factor(){
// // Content_up_to_constant_factor; // // Content_up_to_constant_factor;
template <class Polynomial_traits_d> template <class Polynomial_traits_d>
void test_univariate_content_up_to_constant_factor(){ void test_univariate_content_up_to_constant_factor(const Polynomial_traits_d&){
std::cerr << "start test_univariate_content_up_to_constant_factor "; std::cerr << "start test_univariate_content_up_to_constant_factor ";
std::cerr.flush(); std::cerr.flush();
CGAL_SNAP_CGALi_TRAITS_D(Polynomial_traits_d); CGAL_SNAP_CGALi_TRAITS_D(Polynomial_traits_d);
@ -882,7 +899,7 @@ void test_univariate_content_up_to_constant_factor(){
// // Square_free_factorization_up_to_constant_factor; // // Square_free_factorization_up_to_constant_factor;
template <class Polynomial_traits_d> template <class Polynomial_traits_d>
void test_square_free_factorization_up_to_constant_factor(){ void test_square_free_factorization_up_to_constant_factor(const Polynomial_traits_d&){
std::cerr << "start test_square_free_factorization_up_to_constant_factor "; std::cerr << "start test_square_free_factorization_up_to_constant_factor ";
std::cerr.flush(); std::cerr.flush();
CGAL_SNAP_CGALi_TRAITS_D(Polynomial_traits_d); CGAL_SNAP_CGALi_TRAITS_D(Polynomial_traits_d);
@ -917,7 +934,7 @@ void test_square_free_factorization_up_to_constant_factor(){
// // Evaluate; // // Evaluate;
template <class Polynomial_traits_d> template <class Polynomial_traits_d>
void test_evaluate(){ void test_evaluate(const Polynomial_traits_d&){
std::cerr << "start test_evaluate "; std::cerr.flush(); std::cerr << "start test_evaluate "; std::cerr.flush();
CGAL_SNAP_CGALi_TRAITS_D(Polynomial_traits_d); CGAL_SNAP_CGALi_TRAITS_D(Polynomial_traits_d);
typename PT::Evaluate evaluate; typename PT::Evaluate evaluate;
@ -943,7 +960,7 @@ void test_evaluate(){
// // Evaluate_homogeneous; // // Evaluate_homogeneous;
template <class Polynomial_traits_d> template <class Polynomial_traits_d>
void test_evaluate_homogeneous(){ void test_evaluate_homogeneous(const Polynomial_traits_d&){
std::cerr << "start test_evaluate_homogeneous "; std::cerr.flush(); std::cerr << "start test_evaluate_homogeneous "; std::cerr.flush();
CGAL_SNAP_CGALi_TRAITS_D(Polynomial_traits_d); CGAL_SNAP_CGALi_TRAITS_D(Polynomial_traits_d);
typename PT::Evaluate_homogeneous evh; typename PT::Evaluate_homogeneous evh;
@ -963,7 +980,7 @@ void test_evaluate_homogeneous(){
} }
template< class Polynomial_traits_d > template< class Polynomial_traits_d >
void test_is_zero_at() { void test_is_zero_at(const Polynomial_traits_d&) {
std::cerr << "start test_is_zero_at "; std::cerr << "start test_is_zero_at ";
std::cerr.flush(); std::cerr.flush();
@ -992,7 +1009,7 @@ void test_is_zero_at() {
} }
template< class Polynomial_traits_d > template< class Polynomial_traits_d >
void test_is_zero_at_homogeneous() { void test_is_zero_at_homogeneous(const Polynomial_traits_d&) {
std::cerr << "start test_is_zero_at_homogeneous "; std::cerr << "start test_is_zero_at_homogeneous ";
std::cerr.flush(); std::cerr.flush();
@ -1025,7 +1042,7 @@ void test_is_zero_at_homogeneous() {
} }
template< class Polynomial_traits_d > template< class Polynomial_traits_d >
void test_sign_at() { void test_sign_at(const Polynomial_traits_d&) {
std::cerr << "start test_sign_at "; std::cerr << "start test_sign_at ";
std::cerr.flush(); std::cerr.flush();
@ -1058,7 +1075,7 @@ void test_sign_at() {
} }
template< class Polynomial_traits_d > template< class Polynomial_traits_d >
void test_sign_at_homogeneous() { void test_sign_at_homogeneous(const Polynomial_traits_d&) {
std::cerr << "start test_sign_at_homogeneous "; std::cerr << "start test_sign_at_homogeneous ";
std::cerr.flush(); std::cerr.flush();
@ -1107,7 +1124,7 @@ void test_sign_at_homogeneous() {
} }
template< class Polynomial_traits_d> template< class Polynomial_traits_d>
void test_compare() { void test_compare(const Polynomial_traits_d&) {
(std::cerr << "start test compare ").flush(); (std::cerr << "start test compare ").flush();
CGAL_SNAP_CGALi_TRAITS_D(Polynomial_traits_d); CGAL_SNAP_CGALi_TRAITS_D(Polynomial_traits_d);
@ -1142,7 +1159,7 @@ void test_compare() {
// // Resultant; // // Resultant;
template <class Polynomial_traits_d> template <class Polynomial_traits_d>
void test_resultant(){ void test_resultant(const Polynomial_traits_d&){
std::cerr << "start test_resultant "; std::cerr.flush(); std::cerr << "start test_resultant "; std::cerr.flush();
CGAL_SNAP_CGALi_TRAITS_D(Polynomial_traits_d); CGAL_SNAP_CGALi_TRAITS_D(Polynomial_traits_d);
typename PT::Resultant resultant; typename PT::Resultant resultant;
@ -1179,7 +1196,7 @@ void test_resultant(){
// // Canonicalize; // // Canonicalize;
template <class Polynomial_traits_d> template <class Polynomial_traits_d>
void test_canonicalize(){ void test_canonicalize(const Polynomial_traits_d&){
std::cerr << "start test_canonicalize "; std::cerr.flush(); std::cerr << "start test_canonicalize "; std::cerr.flush();
CGAL_SNAP_CGALi_TRAITS_D(Polynomial_traits_d); CGAL_SNAP_CGALi_TRAITS_D(Polynomial_traits_d);
typename PT::Canonicalize canonicalize; typename PT::Canonicalize canonicalize;
@ -1198,7 +1215,7 @@ void test_canonicalize(){
} }
// // Substitute; // // Substitute;
template <class Polynomial_traits_d> template <class Polynomial_traits_d>
void test_substitute(){ void test_substitute(const Polynomial_traits_d&){
std::cerr << "start test_substitute "; std::cerr.flush(); std::cerr << "start test_substitute "; std::cerr.flush();
CGAL_SNAP_CGALi_TRAITS_D(Polynomial_traits_d); CGAL_SNAP_CGALi_TRAITS_D(Polynomial_traits_d);
typename PT::Substitute substitute; typename PT::Substitute substitute;
@ -1241,7 +1258,7 @@ void test_substitute(){
// // Substitute; // // Substitute;
template <class Polynomial_traits_d> template <class Polynomial_traits_d>
void test_substitute_homogeneous(){ void test_substitute_homogeneous(const Polynomial_traits_d&){
std::cerr << "start test_substitute_homogeneous "; std::cerr.flush(); std::cerr << "start test_substitute_homogeneous "; std::cerr.flush();
CGAL_SNAP_CGALi_TRAITS_D(Polynomial_traits_d); CGAL_SNAP_CGALi_TRAITS_D(Polynomial_traits_d);
typename PT::Substitute_homogeneous substitute_homogeneous; typename PT::Substitute_homogeneous substitute_homogeneous;
@ -1284,165 +1301,139 @@ void test_substitute_homogeneous(){
} }
// #############
template< class PT >
template< class Polynomial_traits_d, class AlgebraicCategory > void test_fundamental_functors(const PT& traits){
struct Test_polynomial_traits_d;
template <class Polynomial_traits_d>
struct Test_polynomial_traits_d<Polynomial_traits_d, CGAL::Null_tag > {
void operator()() {
std::cout << "\n start test for dimension: " std::cout << "\n start test for dimension: "
<< Polynomial_traits_d::d << std::endl; << PT::d << std::endl;
// Construct_polynomial; // Construction
test_construct_polynomial<Polynomial_traits_d>(); test_construct_polynomial(traits);
// Get_coefficient;
test_get_coefficient<Polynomial_traits_d>();
// Get_innermost_coefficient;
test_get_innermost_coefficient<Polynomial_traits_d>();
// Get_monom_representation;
test_get_monom_representation<Polynomial_traits_d>();
// Swap;
test_swap<Polynomial_traits_d>();
// Move;
test_move<Polynomial_traits_d>();
// Degree;
test_degree<Polynomial_traits_d>();
// Total_degree;
test_total_degree<Polynomial_traits_d>();
// Leading_coefficient;
test_leading_coefficient<Polynomial_traits_d>();
// Innermost_leading_coefficient;
test_innermost_leading_coefficient<Polynomial_traits_d>();
// Is_zero_at;
test_is_zero_at<Polynomial_traits_d>();
// Is_zero_at_homogeneous;
test_is_zero_at_homogeneous<Polynomial_traits_d>();
// Sign_at;
test_sign_at<Polynomial_traits_d>();
// Sign_at_homogeneous;
test_sign_at_homogeneous<Polynomial_traits_d>();
// Compare;
test_compare<Polynomial_traits_d>();
// Shift;
test_shift<Polynomial_traits_d>();
// Negate;
test_negate<Polynomial_traits_d>();
// Invert;
test_invert<Polynomial_traits_d>();
// Translate;
test_translate<Polynomial_traits_d>();
// Translate_homogeneous;
test_translate_homongenous<Polynomial_traits_d>();
// Scale;
test_scale<Polynomial_traits_d>();
// Scale_homogeneous;
test_scale_homogeneous<Polynomial_traits_d>();
// Derivative;
test_derivative<Polynomial_traits_d>();
// Make_square_free;
test_make_square_free<Polynomial_traits_d>();
// Pseudo_division;
test_pseudo_division<Polynomial_traits_d>();
// Pseudo_division_remainder;
test_pseudo_division_remainder<Polynomial_traits_d>();
// Pseudo_division_quotient;
test_pseudo_division_quotient<Polynomial_traits_d>();
// Gcd_up_to_constant_factor;
test_gcd_up_to_constant_factor<Polynomial_traits_d>();
// Integral_division_up_to_constant_factor;
test_integral_division_up_to_constant_factor<Polynomial_traits_d>();
// Content_up_to_constant_factor;
test_univariate_content_up_to_constant_factor<Polynomial_traits_d>();
// Square_free_factorization_up_to_constant_factor;
test_square_free_factorization_up_to_constant_factor<Polynomial_traits_d>();
// Evaluate;
test_evaluate<Polynomial_traits_d>();
// Evaluate_homogeneous;
test_evaluate_homogeneous<Polynomial_traits_d>();
// Resultant;
test_resultant<Polynomial_traits_d>();
// Canonicalize;
test_canonicalize<Polynomial_traits_d>();
// Substitute;
test_substitute<Polynomial_traits_d>();
// Substitute_homogeneous;
test_substitute_homogeneous<Polynomial_traits_d>();
// private:
// Innermost_leading_coefficient;
}
};
template< class Polynomial_traits_d > // Gets
struct Test_polynomial_traits_d< test_get_coefficient(traits);
Polynomial_traits_d, CGAL::Integral_domain_without_division_tag > test_get_innermost_coefficient(traits);
: public Test_polynomial_traits_d< Polynomial_traits_d, CGAL::Null_tag > {}; test_get_monom_representation(traits);
test_leading_coefficient(traits);
test_innermost_leading_coefficient(traits);
template< class Polynomial_traits_d > test_degree(traits);
struct Test_polynomial_traits_d< test_total_degree(traits);
Polynomial_traits_d, CGAL::Integral_domain_tag >
: public Test_polynomial_traits_d<
Polynomial_traits_d, CGAL::Integral_domain_without_division_tag > {};
template< class Polynomial_traits_d > // modifier
struct Test_polynomial_traits_d< Polynomial_traits_d, CGAL::Field_tag > test_swap(traits);
: public Test_polynomial_traits_d< test_move(traits);
Polynomial_traits_d, CGAL::Integral_domain_tag > {
void operator()() {
Test_polynomial_traits_d<
Polynomial_traits_d, CGAL::Integral_domain_tag >::operator()();
// Additional tests...
// Univariate_content;
test_univariate_content<Polynomial_traits_d>();
// Multivariate_content;
test_multivariate_content<Polynomial_traits_d>();
// Interpolate;
test_interpolate<Polynomial_traits_d>();
// Square_free_factorization;
test_square_free_factorization<Polynomial_traits_d>();
}
};
template< class Polynomial_traits_d > test_substitute(traits);
struct Test_polynomial_traits_d< test_substitute_homogeneous(traits);
Polynomial_traits_d, CGAL::Field_with_sqrt_tag >
: public Test_polynomial_traits_d< Polynomial_traits_d, CGAL::Field_tag > {};
template< class Polynomial_traits_d > test_shift(traits);
struct Test_polynomial_traits_d< test_negate(traits);
Polynomial_traits_d, CGAL::Field_with_kth_root_tag > test_invert(traits);
: public Test_polynomial_traits_d< test_translate(traits);
Polynomial_traits_d, CGAL::Field_with_sqrt_tag > {}; test_translate_homongenous(traits);
test_scale(traits);
test_scale_homogeneous(traits);
template< class Polynomial_traits_d > test_derivative(traits);
struct Test_polynomial_traits_d< test_make_square_free(traits);
Polynomial_traits_d, CGAL::Field_with_root_of_tag > test_canonicalize(traits);
: public Test_polynomial_traits_d<
Polynomial_traits_d, CGAL::Field_with_kth_root_tag > {};
template< class Polynomial_traits_d > // evaluates (sign depends on real embeddable)
struct Test_polynomial_traits_d< test_evaluate(traits);
Polynomial_traits_d, CGAL::Unique_factorization_domain_tag > test_evaluate_homogeneous(traits);
: public Test_polynomial_traits_d< test_is_zero_at(traits);
Polynomial_traits_d, CGAL::Integral_domain_tag > { test_is_zero_at_homogeneous(traits);
void operator()() {
Test_polynomial_traits_d<
Polynomial_traits_d, CGAL::Integral_domain_tag >::operator()();
// Additional tests...
// Univariate_content;
test_univariate_content<Polynomial_traits_d>();
// Multivariate_content;
test_multivariate_content<Polynomial_traits_d>();
// Square_free_factorization;
test_square_free_factorization<Polynomial_traits_d>();
}
};
template< class Polynomial_traits_d > // pseudo division
struct Test_polynomial_traits_d< Polynomial_traits_d, CGAL::Euclidean_ring_tag > test_pseudo_division(traits);
: public Test_polynomial_traits_d< test_pseudo_division_remainder(traits);
Polynomial_traits_d, CGAL::Unique_factorization_domain_tag > {}; test_pseudo_division_quotient(traits);
// utcf functions
test_gcd_up_to_constant_factor(traits);
test_integral_division_up_to_constant_factor(traits);
test_univariate_content_up_to_constant_factor(traits);
test_square_free_factorization_up_to_constant_factor(traits);
// resultant
test_resultant(traits);
}
template< class PT >
void test_real_embeddable_functors(const PT& traits, CGAL::Tag_true){
test_sign_at(traits);
test_sign_at_homogeneous(traits);
test_compare(traits);
}
template< class PT >
void test_real_embeddable_functors(const PT& traits, CGAL::Tag_false){
// Since Innermost_coefficient is not RealEmbeddable the following functors
// should be CGAL::Null_functor.
ASSERT_IS_NULL_FUNCTOR(typename PT::Sign_at);
ASSERT_IS_NULL_FUNCTOR(typename PT::Sign_at_homogeneous);
ASSERT_IS_NULL_FUNCTOR(typename PT::Compare);
}
// test functors depending on the Algebraic_category of ICoeff
template< class PT >
void test_ac_icoeff_functors(
const PT& traits, CGAL::Integral_domain_without_division_tag){
ASSERT_IS_NULL_FUNCTOR(typename PT::Multivariate_content);
ASSERT_IS_NULL_FUNCTOR(typename PT::Interpolate);
}
template< class PT >
void test_ac_icoeff_functors(
const PT& traits, CGAL::Unique_factorization_domain_tag){
test_multivariate_content(traits);
ASSERT_IS_NULL_FUNCTOR(typename PT::Interpolate);
}
template< class PT >
void test_ac_icoeff_functors(const PT& traits, CGAL::Field_tag){
test_multivariate_content(traits);
test_interpolate(traits);
}
// test functors depending on the Algebraic_category of Coefficient
template< class PT >
void test_ac_poly_functors(const PT& traits, CGAL::Integral_domain_without_division_tag){
ASSERT_IS_NULL_FUNCTOR(typename PT::Univariate_content);
ASSERT_IS_NULL_FUNCTOR(typename PT::Square_free_factorization);
}
template< class PT >
void test_ac_poly_functors(const PT& traits, CGAL::Unique_factorization_domain_tag){
test_univariate_content(traits);
test_square_free_factorization(traits);
}
template< class PT >
void test_polynomial_traits_d(const PT& traits){
typedef typename PT::Polynomial_d Polynomial_d;
typedef typename PT::Innermost_coefficient ICoeff;
typedef typename PT::Coefficient Coeff;
test_fundamental_functors(traits);
typedef typename CGAL::Algebraic_structure_traits<ICoeff> AST_IC;
test_ac_icoeff_functors(traits, typename AST_IC::Algebraic_category());
typedef typename CGAL::Algebraic_structure_traits<Polynomial_d> AST_Poly;
test_ac_poly_functors(traits, typename AST_Poly::Algebraic_category());
typedef typename CGAL::Real_embeddable_traits<ICoeff> RET_IC;
typedef typename RET_IC::Is_real_embeddable Is_real_embeddable;
test_real_embeddable_functors(traits, Is_real_embeddable());
}
template< class InnermostCoefficient > template< class InnermostCoefficient >
void test_multiple_dimensions() { void test_multiple_dimensions() {
@ -1465,7 +1456,7 @@ void test_multiple_dimensions() {
BOOST_STATIC_ASSERT((boost::is_same< typename PT::Innermost_coefficient, BOOST_STATIC_ASSERT((boost::is_same< typename PT::Innermost_coefficient,
Innermost_coefficient>::value)); Innermost_coefficient>::value));
BOOST_STATIC_ASSERT((PT::d == dimension)); BOOST_STATIC_ASSERT((PT::d == dimension));
Test_polynomial_traits_d<PT, Algebraic_category>()(); test_polynomial_traits_d(PT());
} }
{ {
typedef CGAL::Polynomial< InnermostCoefficient > Polynomial_1; typedef CGAL::Polynomial< InnermostCoefficient > Polynomial_1;
@ -1487,8 +1478,9 @@ void test_multiple_dimensions() {
BOOST_STATIC_ASSERT((boost::is_same< typename PT::Innermost_coefficient, BOOST_STATIC_ASSERT((boost::is_same< typename PT::Innermost_coefficient,
Innermost_coefficient>::value)); Innermost_coefficient>::value));
BOOST_STATIC_ASSERT((PT::d == dimension)); BOOST_STATIC_ASSERT((PT::d == dimension));
Test_polynomial_traits_d<PT, Algebraic_category>()(); test_polynomial_traits_d(PT());
}{ }
{
typedef CGAL::Polynomial< InnermostCoefficient > Polynomial_1; typedef CGAL::Polynomial< InnermostCoefficient > Polynomial_1;
typedef CGAL::Polynomial<Polynomial_1> Polynomial_2; typedef CGAL::Polynomial<Polynomial_1> Polynomial_2;
typedef CGAL::Polynomial<Polynomial_2> Polynomial_3; typedef CGAL::Polynomial<Polynomial_2> Polynomial_3;
@ -1510,43 +1502,8 @@ void test_multiple_dimensions() {
BOOST_STATIC_ASSERT((boost::is_same< typename PT::Innermost_coefficient, BOOST_STATIC_ASSERT((boost::is_same< typename PT::Innermost_coefficient,
Innermost_coefficient>::value)); Innermost_coefficient>::value));
BOOST_STATIC_ASSERT((PT::d == dimension)); BOOST_STATIC_ASSERT((PT::d == dimension));
Test_polynomial_traits_d<PT, Algebraic_category>()(); test_polynomial_traits_d(PT());
} }
#ifdef WITH_D10
{
typedef CGAL::Polynomial< InnermostCoefficient > Polynomial_1;
typedef CGAL::Polynomial<Polynomial_1> Polynomial_2;
typedef CGAL::Polynomial<Polynomial_2> Polynomial_3;
typedef CGAL::Polynomial<Polynomial_3> Polynomial_4;
typedef CGAL::Polynomial<Polynomial_4> Polynomial_5;
typedef CGAL::Polynomial<Polynomial_5> Polynomial_6;
typedef CGAL::Polynomial<Polynomial_6> Polynomial_7;
typedef CGAL::Polynomial<Polynomial_7> Polynomial_8;
typedef CGAL::Polynomial<Polynomial_8> Polynomial_9;
typedef CGAL::Polynomial<Polynomial_9> Polynomial_10;
const int dimension = 10;
typedef Polynomial_10 Polynomial_d;
typedef Polynomial_9 Coefficient;
typedef InnermostCoefficient Innermost_coefficient;
typedef CGAL::Polynomial_traits_d<Polynomial_d> PT;
typedef CGAL::Algebraic_structure_traits<Innermost_coefficient> AST_IC;
typedef typename AST_CI::Algebraic_category Algebraic_category;
BOOST_STATIC_ASSERT(
(boost::is_same<typename PT::Polynomial_d,Polynomial_d>::value));
BOOST_STATIC_ASSERT(
(boost::is_same< typename PT::Coefficient, Coefficient>::value));
BOOST_STATIC_ASSERT((boost::is_same< typename PT::Innermost_coefficient,
Innermost_coefficient>::value));
BOOST_STATIC_ASSERT((PT::d == dimension));
Test_polynomial_traits_d<PT, Algebraic_category>()();
}
#endif
} }
template < typename AK> template < typename AK>
@ -1590,6 +1547,16 @@ void test_AT(){
CGAL::set_pretty_mode(std::cerr); CGAL::set_pretty_mode(std::cerr);
std::cerr << std::endl;
std::cerr <<
"Test for coefficient type CGAL::Modular"
<< std::endl;
std::cerr <<
"----------------------------------------------------------------------"
<< std::endl;
test_multiple_dimensions< CGAL::Modular >();
typedef typename AT::Integer Integer; typedef typename AT::Integer Integer;
typedef typename AT::Rational Rational; typedef typename AT::Rational Rational;
@ -1629,6 +1596,8 @@ void test_AT(){
test_multiple_dimensions< CGAL::Sqrt_extension< Rational, Rational > >(); test_multiple_dimensions< CGAL::Sqrt_extension< Rational, Rational > >();
test_rebind<AT>(); test_rebind<AT>();
} }