1
// Copyright (c) 2011 National and Kapodistrian University of Athens (Greece).
2
// All rights reserved.
4
// This file is part of CGAL (www.cgal.org); you can redistribute it and/or
5
// modify it under the terms of the GNU Lesser General Public License as
6
// published by the Free Software Foundation; either version 3 of the License,
7
// or (at your option) any later version.
9
// Licensees holding a valid commercial license may use this file in
10
// accordance with the commercial license agreement provided with the software.
12
// This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
13
// WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
18
// Author: Luis Peñaranda <luis.penaranda@gmx.com>
20
#ifndef CGAL_RS_ISOLE_1_H
21
#define CGAL_RS_ISOLE_1_H
23
#include <CGAL/RS/basic.h>
24
#include <CGAL/RS/rs_calls_1.h>
25
#include <CGAL/Gmpfi.h>
32
// CGAL::RS::isolator<P> solves a polynomial of type P and returns a vector
33
// of Gmpfi's containing the solutions. Currently, the only implemented
34
// isolator solves polynomials of type CGAL::Polynomial<CGAL::Gmpz>.
36
template <class PolynomialType>
38
typedef PolynomialType PolynomialT;
39
inline std::vector<Gmpfi>
40
operator()(const PolynomialT&,unsigned int prec=CGAL_RS_DEF_PREC);
43
template <class PolynomialType>
44
inline std::vector<Gmpfi>
45
isolator<PolynomialType>::operator()(const PolynomialType &p,unsigned int prec){
47
"isolator not implemented for this type of polynomials");
48
return std::vector<Gmpfi>();
52
inline std::vector<Gmpfi>
53
isolator<Polynomial<Gmpz> >::operator()(const Polynomial<Gmpz> &p,
56
unsigned int degree=p.degree();
57
mpz_t *coeffs=(mpz_t*)malloc((degree+1)*sizeof(mpz_t));
58
mpfi_ptr *intervals_mpfi=(mpfi_ptr*)malloc(degree*sizeof(mpfi_ptr));
59
std::vector<Gmpfi> intervals;
60
for(unsigned int i=0;i<=degree;++i)
61
coeffs[i][0]=*(p[i].mpz());
63
create_rs_upoly(coeffs,degree,rs_get_default_up());
65
set_rs_precisol(prec);
66
set_rs_verbose(CGAL_RS_VERB);
67
rs_run_algo(CGALRS_CSTR("UISOLE"));
68
numsols=affiche_sols_eqs(intervals_mpfi);
69
for(int j=0;j<numsols;++j)
70
intervals.push_back(Gmpfi(intervals_mpfi[j]));
79
#endif // CGAL_RS_ISOLE_1_H