LEDA real Extended

     Home         Projects      Teaching   Publications  Downloads    Members  

How to use EXT in EXACUS

EXT is the LEDA real extension, containing the diamond operator. It can be downloaded from the EXACUS home page. Further it should be included in the next LEDA version.

There are several possibilities to use EXT in EXACUS.

This text explains how to do (1) and (2). (3) is postponed.

How to compile EXT with EXACUS

To use EXT, you have to download and compile it. In EXACUS, you have to

Use EXT::real as another LEDA::real version (1)

This does make sense as long as you don't use the next LEDA version. The EXT::real have a better separation bound than the LEDA::real, so everything should be faster. (However, in my examples, there was not so much difference.)

If you want use the EXT::reals instead of the LEDA::reals, do the same as above and compile EXACUS with the flag -DNiX_USE_EXT

That's all! Then EXACUS automatically takes EXT::reals instead of LEDA::reals. Everything else stays the same.

Explicit call of EXT functions (2)

This does make sense to do things the Algebraic_real cannot do or to compare the two methods.

Suppose you want to call the real_roots() functor from EXT instead of the real_roots() functor from EXACUS to compare the roots of two polynomials. In EXACUS, there was:

Poly_int1 p(integralize_polynomial(substitute_x(curve1().f(), x1), dummy));
Poly_int1 q(integralize_polynomial(substitute_x(curve2().f(), x1), dummy));

Uspensky_int usp1(p), usp2(q);
s.reserve(usp1.number_of_real_roots() + usp2.number_of_real_roots());
std::vector<Algebraic_real> roots1, roots2;
roots1.reserve(usp1.number_of_real_roots());
roots2.reserve(usp2.number_of_real_roots());

typename Algebraic_real::Real_roots<Integer> real_roots;
real_roots(usp1, std::back_inserter(roots1));
real_roots(usp2, std::back_inserter(roots2));

You have to do the following changes. First you have to include the EXT files

#include <EXT/real.h> // the EXT reals
#include <EXT/nt_traits.h> // nt_traits for EXT reals
#include <EXT/conversion.h> // conversion from EXACUS polynomials

You have to replace Algebraic_real by EXT::real at the appropriate places. Then the piece of code from above reads:

Poly_int1 p(integralize_polynomial(substitute_x(curve1().f(), x1), dummy));
Poly_int1 q(integralize_polynomial(substitute_x(curve2().f(), x1), dummy));
std::vector<EXT::real> roots1, roots2;

int n1 = EXT::real_roots(p,std::back_inserter(roots1));
int n2 = EXT::real_roots(q,std::back_inserter(roots2));
s.reserve(n1 + n2);

(The main difference is that Uspensky is called inside the numbertype.)
Then you have to make sure to use the EXT::real Compare function, so you have to replace

switch ((*it1).compare(*it2))

by something like

typename NiX::NT_traits<EXT::real>::Compare ext_compare;
switch (ext_compare((*it1),(*it2)))