cgal icon indicating copy to clipboard operation
cgal copied to clipboard

Core: Use Expr::is_zero() of AST

Open afabri opened this issue 1 year ago • 7 comments

Summary of Changes

Accelerate comparison with zero

Release Management

  • Affected package(s): Number_types
  • License and copyright ownership: unchanged

afabri avatar Jan 25 '24 17:01 afabri

Is this implementation of Is_one really faster? From what I can see, doubleInterval itself should already be more costly than ==1.

mglisse avatar Jan 25 '24 21:01 mglisse

When comparing to 1 that constructs an Expr(1), and performs a subtraction. I wanted to avoid that.
I am also wondering if one should not use Lazy_exact_nt<Expr> instead of doing a filtering, but I said myself that Expr is somehow the same, but didn't find the interval hardcoded. And I am wondering if I first have to call Expr::approx() as done here

afabri avatar Jan 26 '24 07:01 afabri

When comparing to 1 that constructs an Expr(1), and performs a subtraction. I wanted to avoid that.

https://github.com/CGAL/cgal/blob/96f698ca09b61b6ca7587d43b022a0db43519699/CGAL_Core/include/CGAL/CORE/Expr_impl.h#L84-L89

doubleInterval also constructs an Expr from a double and performs a subtraction...

And I am wondering if I first have to call Expr::approx()

Looks like doubleValue already does it? Although the different precision is suspicious. https://github.com/CGAL/cgal/blob/96f698ca09b61b6ca7587d43b022a0db43519699/CGAL_Core/include/CGAL/CORE/Expr.h#L252-L253

but didn't find the interval hardcoded.

IIUC (but I know little about CORE) it stores an approximate value as a Real and a precision, not directly an interval.

mglisse avatar Jan 26 '24 08:01 mglisse

Successfully tested in CGA-6.0-Ic-173

sloriot avatar Feb 16 '24 10:02 sloriot

@afabri @mglisse Can you please go on with the discussion? I think Andreas has to answer to Marc's last remarks.

lrineau avatar Feb 16 '24 16:02 lrineau

This pull-request was previously marked with the label Tested, but has been modified with new commits. That label has been removed.

github-actions[bot] avatar Feb 22 '24 09:02 github-actions[bot]

For the time being let's reduce it to the initial scope, namely to have a faster test for being zero.

afabri avatar Feb 22 '24 09:02 afabri

Successfully tested in CGAL-6.0-Ic-192

sloriot avatar Mar 13 '24 16:03 sloriot