mirror of https://github.com/CGAL/cgal
Added examples of the RS interface.
This commit is contained in:
parent
594fd8ff54
commit
764af11539
|
|
@ -19,6 +19,8 @@ Algebraic_kernel_GBRS/include/CGAL/MpfiInterval.C -text
|
|||
Algebraic_kernel_GBRS/include/CGAL/MpfiInterval.h -text
|
||||
Algebraic_kernel_GBRS/test/Gbrs_polynomial/Gbrs_polynomial_1.C -text
|
||||
Algebraic_kernel_GBRS/test/Gbrs_polynomial/makefile -text
|
||||
Algebraic_kernel_GBRS/test/Gbrs_solve/makefile -text
|
||||
Algebraic_kernel_GBRS/test/Gbrs_solve/rs.C -text
|
||||
Algebraic_kernel_GBRS/test/MpfiInterval/Mpfi.C -text
|
||||
Algebraic_kernel_GBRS/test/MpfiInterval/makefile -text
|
||||
Alpha_shapes_2/demo/Alpha_shapes_2/data/m30f.jpg -text svneol=unset#image/jpeg
|
||||
|
|
|
|||
|
|
@ -0,0 +1,12 @@
|
|||
include ${CGAL_MAKEFILE}
|
||||
|
||||
OBJS=rs
|
||||
|
||||
all: ${OBJS}
|
||||
|
||||
rs: rs.C
|
||||
${CGAL_CXX} -g ${CGAL_CXXFLAGS} ${CGAL_LIBPATHFLAGS} $< ${CGAL_LDFLAGS} -o $@
|
||||
|
||||
clean:
|
||||
rm -f ${OBJS}
|
||||
|
||||
|
|
@ -0,0 +1,35 @@
|
|||
#include <CGAL/Gbrs_algebraic_kernel.h>
|
||||
#include <vector>
|
||||
|
||||
typedef CGAL::GBRS_algebraic_kernel<CGAL::Gmpq> AlgKernel;
|
||||
typedef AlgKernel::Coefficient Coefficient;
|
||||
typedef AlgKernel::Algebraic_real_1 Algebraic;
|
||||
typedef AlgKernel::Polynomial_1 Polynomial;
|
||||
|
||||
int main () {
|
||||
AlgKernel ker;
|
||||
// construct the polynomial x^3-2x
|
||||
std::vector<Coefficient> coefs;
|
||||
coefs.push_back (Coefficient (1));
|
||||
coefs.push_back (Coefficient (0));
|
||||
coefs.push_back (Coefficient (-2));
|
||||
coefs.push_back (Coefficient (0));
|
||||
coefs.push_back (Coefficient (0));
|
||||
coefs.push_back (Coefficient (0));
|
||||
Polynomial p = ker.construct_polynomial_1_object()
|
||||
(coefs.begin (), coefs.end ());
|
||||
std::cout << "p(x) = " << p << std::endl;
|
||||
|
||||
// find the roots of p
|
||||
std::vector<Algebraic> roots (3);
|
||||
std::vector<Algebraic>::iterator r_end =
|
||||
ker.construct_solve_1_object ()
|
||||
(p, roots.begin (), false);
|
||||
std::vector<Algebraic>::iterator it;
|
||||
std::cout << "roots:" << std::endl;
|
||||
for (it = roots.begin (); it != r_end; ++it)
|
||||
std::cout << *it << std::endl;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue