2 #include <isl/options.h>
5 #include <isl/val_gmp.h>
9 #include <isl_set_polylib.h>
10 #include <barvinok/basis_reduction.h>
11 #include <barvinok/options.h>
15 Matrix
*glpk_Polyhedron_Reduced_Basis(Polyhedron
*P
,
16 struct barvinok_options
*options
)
22 #ifndef HAVE_LIBCDDGMP
23 Matrix
*cdd_Polyhedron_Reduced_Basis(Polyhedron
*P
,
24 struct barvinok_options
*options
)
30 Matrix
*isl_Polyhedron_Reduced_Basis(Polyhedron
*P
,
31 struct barvinok_options
*options
)
37 int nvar
= P
->Dimension
;
42 ctx
= isl_ctx_alloc();
45 isl_options_set_gbr_only_first(ctx
, options
->gbr_only_first
);
47 space
= isl_space_set_alloc(ctx
, 0, nvar
);
48 bset
= isl_basic_set_new_from_polylib(P
, space
);
50 basis
= isl_basic_set_reduced_basis(bset
);
51 isl_basic_set_free(bset
);
53 M
= Matrix_Alloc(nvar
, nvar
);
55 for (i
= 0; i
< nvar
; ++i
)
56 for (j
= 0; j
< nvar
; ++j
) {
57 v
= isl_mat_get_element_val(basis
, 1 + i
, 1 + j
);
58 isl_val_get_num_gmp(v
, M
->p
[i
][j
]);
69 Matrix
*Polyhedron_Reduced_Basis(Polyhedron
*P
, struct barvinok_options
*options
)
71 if (options
->gbr_lp_solver
== BV_GBR_GLPK
)
72 return glpk_Polyhedron_Reduced_Basis(P
, options
);
73 else if (options
->gbr_lp_solver
== BV_GBR_CDD
)
74 return cdd_Polyhedron_Reduced_Basis(P
, options
);
75 else if (options
->gbr_lp_solver
== BV_GBR_ISL
)
76 return isl_Polyhedron_Reduced_Basis(P
, options
);