Skip to content

Commit

Permalink
Add Is_one
Browse files Browse the repository at this point in the history
  • Loading branch information
afabri committed Jan 25, 2024
1 parent 878d90b commit 1348552
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 0 deletions.
1 change: 1 addition & 0 deletions CGAL_Core/examples/Core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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")
32 changes: 32 additions & 0 deletions CGAL_Core/examples/Core/zero-one.cpp
Original file line number Diff line number Diff line change
@@ -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;
}
16 changes: 16 additions & 0 deletions Number_types/include/CGAL/CORE_Expr.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 >
Expand Down

0 comments on commit 1348552

Please sign in to comment.