2 #include <isl_set_polylib.h>
3 #include <barvinok/basis_reduction.h>
4 #include <barvinok/options.h>
8 Matrix
*glpk_Polyhedron_Reduced_Basis(Polyhedron
*P
,
9 struct barvinok_options
*options
)
15 #ifndef HAVE_LIBCDDGMP
16 Matrix
*cdd_Polyhedron_Reduced_Basis(Polyhedron
*P
,
17 struct barvinok_options
*options
)
24 Matrix
*pip_Polyhedron_Reduced_Basis(Polyhedron
*P
,
25 struct barvinok_options
*options
)
29 Matrix
*pip_dual_Polyhedron_Reduced_Basis(Polyhedron
*P
,
30 struct barvinok_options
*options
)
36 Matrix
*isl_Polyhedron_Reduced_Basis(Polyhedron
*P
,
37 struct barvinok_options
*options
)
43 int nvar
= P
->Dimension
;
47 int isl_gbr_only_first
= options
->isl
->gbr_only_first
;
49 options
->isl
->gbr_only_first
= options
->gbr_only_first
;
50 ctx
= isl_ctx_alloc_with_options(barvinok_options_arg
, options
);
53 dim
= isl_dim_set_alloc(ctx
, 0, nvar
);
54 bset
= isl_basic_set_new_from_polylib(P
, dim
);
56 basis
= isl_basic_set_reduced_basis(bset
);
57 isl_basic_set_free(bset
);
59 M
= Matrix_Alloc(nvar
, nvar
);
62 for (i
= 0; i
< nvar
; ++i
)
63 for (j
= 0; j
< nvar
; ++j
) {
64 isl_mat_get_element(basis
, 1 + i
, 1 + j
, &v
);
65 isl_int_get_gmp(v
, M
->p
[i
][j
]);
73 options
->isl
->gbr_only_first
= isl_gbr_only_first
;
78 Matrix
*Polyhedron_Reduced_Basis(Polyhedron
*P
, struct barvinok_options
*options
)
80 if (options
->gbr_lp_solver
== BV_GBR_GLPK
)
81 return glpk_Polyhedron_Reduced_Basis(P
, options
);
82 else if (options
->gbr_lp_solver
== BV_GBR_CDD
)
83 return cdd_Polyhedron_Reduced_Basis(P
, options
);
84 else if (options
->gbr_lp_solver
== BV_GBR_PIP
)
85 return pip_Polyhedron_Reduced_Basis(P
, options
);
86 else if (options
->gbr_lp_solver
== BV_GBR_PIP_DUAL
)
87 return pip_dual_Polyhedron_Reduced_Basis(P
, options
);
88 else if (options
->gbr_lp_solver
== BV_GBR_ISL
)
89 return isl_Polyhedron_Reduced_Basis(P
, options
);