Add Is_one

This commit is contained in:
Andreas Fabri 2024-01-25 18:23:49 +00:00
parent 878d90b20e
commit 1348552194
3 changed files with 49 additions and 0 deletions

View File

@ -9,4 +9,5 @@ if(NOT CGAL_Core_FOUND)
return()
endif()
create_single_source_cgal_program("zero-one.cpp")
create_single_source_cgal_program("delaunay.cpp")

View File

@ -0,0 +1,32 @@
#include <CGAL/CORE_Expr.h>
typedef CORE::Expr Real;
int main()
{
Real r(3.14);
CGAL::is_zero(r);
CGAL::is_one(r);
r = CGAL::sqrt(r);
CGAL::is_zero(r);
CGAL::is_one(r);
r = r * r;
CGAL::is_zero(r);
CGAL::is_one(r);
r = r - r;
CGAL::is_zero(r);
return 0;
}

View File

@ -123,6 +123,22 @@ template <> class Algebraic_structure_traits< CORE::Expr >
}
};
class Is_one
: public CGAL::cpp98::unary_function< Type, bool > {
public:
bool operator()( const Type& x ) const {
double inf, sup;
x.doubleInterval(inf,sup);
if((inf > 1) || (sup < 1)){
return false;
}
if((inf == 1) && (sup == 1)){
return true;
}
return x.cmp(Type::getOne());
}
};
};
template <> class Real_embeddable_traits< CORE::Expr >