Summing a large set of Lazy_exact_nt<CGAL::Gmpq> numbers.

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Summing a large set of Lazy_exact_nt<CGAL::Gmpq> numbers.

mauriciojz
Occasionally I have to calculate the sum of a large set of rational numbers. The problem is that I use  Lazy_exact_nt<CGAL::Gmpq>, which sometimes results in a segfault due to the number of stored operations. Is there a nicer way to force the lazy number type to dump these stored operations besides calling a ".exact()" every now and then? Is it more interesting to just use CGAL::Gmpq while performing the sum and then construct its lazy version in the end?

Thank you.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Summing a large set of Lazy_exact_nt<CGAL::Gmpq> numbers.

Sebastien Loriot (GeometryFactory)
On 03/23/2017 03:59 PM, mauriciojz wrote:
> Occasionally I have to calculate the sum of a large set of rational numbers.
> The problem is that I use  /Lazy_exact_nt<CGAL::Gmpq>/, which sometimes
> results in a /segfault/ due to the number of stored operations. Is there a
> nicer way to force the lazy number type to dump these stored operations
> besides calling a ".exact()" every now and then? Is it more interesting to
> just use /CGAL::Gmpq/ while performing the sum and then construct its lazy
> version in the end?
>

It depends what you want to do. What do you want to do with your some of
rational. If at the end you need the exact value, then you should
definitely directly use Gmpq. Each operation with Lazy_exact_nt is
constructing a node in the dag. Calling exact() is the only way to
reduce the size of the dag. We can think of a more elaborate strategy
but again it depends on what your needs.

Sebastien.

> Thank you.
>
>
>
> --
> View this message in context: http://cgal-discuss.949826.n4.nabble.com/Summing-a-large-set-of-Lazy-exact-nt-CGAL-Gmpq-numbers-tp4662600.html
> Sent from the cgal-discuss mailing list archive at Nabble.com.
>


--
You are currently subscribed to cgal-discuss.
To unsubscribe or access the archives, go to
https://sympa.inria.fr/sympa/info/cgal-discuss


Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Summing a large set of Lazy_exact_nt<CGAL::Gmpq> numbers.

mauriciojz
I have no problem with the lazy evaluation, but sometimes I have to compare two of these numbers which happen to be equal resulting in a segfault because it has to resort to its exact value.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Summing a large set of Lazy_exact_nt<CGAL::Gmpq> numbers.

Marc Glisse
On Sat, 25 Mar 2017, mauriciojz wrote:

> I have no problem with the lazy evaluation, but sometimes I have to compare
> two of these numbers which happen to be equal resulting in a /segfault/
> because it has to resort to its exact value.

Just checking: if you increase (drastically) the stack size for your
program, the segfault disappears, right?

--
Marc Glisse

--
You are currently subscribed to cgal-discuss.
To unsubscribe or access the archives, go to
https://sympa.inria.fr/sympa/info/cgal-discuss


Loading...