2 #include <isl/options.h>
3 #include <isl_set_polylib.h>
4 #include <barvinok/basis_reduction.h>
5 #include <barvinok/options.h>
9 Matrix
*glpk_Polyhedron_Reduced_Basis(Polyhedron
*P
,
10 struct barvinok_options
*options
)
16 #ifndef HAVE_LIBCDDGMP
17 Matrix
*cdd_Polyhedron_Reduced_Basis(Polyhedron
*P
,
18 struct barvinok_options
*options
)
24 Matrix
*isl_Polyhedron_Reduced_Basis(Polyhedron
*P
,
25 struct barvinok_options
*options
)
31 int nvar
= P
->Dimension
;
35 int isl_gbr_only_first
;
37 ctx
= isl_ctx_alloc_with_options(&barvinok_options_args
, options
);
40 isl_gbr_only_first
= isl_options_get_gbr_only_first(ctx
);
41 isl_options_set_gbr_only_first(ctx
, options
->gbr_only_first
);
43 dim
= isl_space_set_alloc(ctx
, 0, nvar
);
44 bset
= isl_basic_set_new_from_polylib(P
, dim
);
46 basis
= isl_basic_set_reduced_basis(bset
);
47 isl_basic_set_free(bset
);
49 M
= Matrix_Alloc(nvar
, nvar
);
52 for (i
= 0; i
< nvar
; ++i
)
53 for (j
= 0; j
< nvar
; ++j
) {
54 isl_mat_get_element(basis
, 1 + i
, 1 + j
, &v
);
55 isl_int_get_gmp(v
, M
->p
[i
][j
]);
63 isl_options_set_gbr_only_first(ctx
, isl_gbr_only_first
);
68 Matrix
*Polyhedron_Reduced_Basis(Polyhedron
*P
, struct barvinok_options
*options
)
70 if (options
->gbr_lp_solver
== BV_GBR_GLPK
)
71 return glpk_Polyhedron_Reduced_Basis(P
, options
);
72 else if (options
->gbr_lp_solver
== BV_GBR_CDD
)
73 return cdd_Polyhedron_Reduced_Basis(P
, options
);
74 else if (options
->gbr_lp_solver
== BV_GBR_ISL
)
75 return isl_Polyhedron_Reduced_Basis(P
, options
);