2 #include <isl/options.h>
3 #include <isl/val_gmp.h>
4 #include <isl_set_polylib.h>
5 #include <barvinok/basis_reduction.h>
6 #include <barvinok/options.h>
10 Matrix
*glpk_Polyhedron_Reduced_Basis(Polyhedron
*P
,
11 struct barvinok_options
*options
)
17 #ifndef HAVE_LIBCDDGMP
18 Matrix
*cdd_Polyhedron_Reduced_Basis(Polyhedron
*P
,
19 struct barvinok_options
*options
)
25 Matrix
*isl_Polyhedron_Reduced_Basis(Polyhedron
*P
,
26 struct barvinok_options
*options
)
32 int nvar
= P
->Dimension
;
37 ctx
= isl_ctx_alloc();
40 isl_options_set_gbr_only_first(ctx
, options
->gbr_only_first
);
42 dim
= isl_space_set_alloc(ctx
, 0, nvar
);
43 bset
= isl_basic_set_new_from_polylib(P
, dim
);
45 basis
= isl_basic_set_reduced_basis(bset
);
46 isl_basic_set_free(bset
);
48 M
= Matrix_Alloc(nvar
, nvar
);
50 for (i
= 0; i
< nvar
; ++i
)
51 for (j
= 0; j
< nvar
; ++j
) {
52 v
= isl_mat_get_element_val(basis
, 1 + i
, 1 + j
);
53 isl_val_get_num_gmp(v
, M
->p
[i
][j
]);
64 Matrix
*Polyhedron_Reduced_Basis(Polyhedron
*P
, struct barvinok_options
*options
)
66 if (options
->gbr_lp_solver
== BV_GBR_GLPK
)
67 return glpk_Polyhedron_Reduced_Basis(P
, options
);
68 else if (options
->gbr_lp_solver
== BV_GBR_CDD
)
69 return cdd_Polyhedron_Reduced_Basis(P
, options
);
70 else if (options
->gbr_lp_solver
== BV_GBR_ISL
)
71 return isl_Polyhedron_Reduced_Basis(P
, options
);