replace isl_{,in}equality_alloc by isl_constraint_alloc_{,in}equality
[barvinok/uuh.git] / skewed_genfun.cc
blobb637130acf246dd37b838f450fa5182212f54091
1 #include <iostream>
2 #include "conversion.h"
3 #include "skewed_genfun.h"
5 using std::endl;
7 void skewed_gen_fun::print(std::ostream& os, unsigned int nparam,
8 const char **param_name) const
10 mat_ZZ m;
11 if (T) {
12 os << "T:" << endl;
13 matrix2zz(T, m, T->NbRows, T->NbColumns);
14 os << m << endl;
16 if (eq) {
17 os << "eq:" << endl;
18 matrix2zz(eq, m, eq->NbRows, eq->NbColumns);
19 os << m << endl;
21 if (div) {
22 os << "div:" << endl;
23 matrix2zz(div, m, div->NbRows, div->NbColumns);
24 os << m << endl;
26 gf->print(os, nparam, param_name);
29 void skewed_gen_fun::coefficient(Value* params, Value* c,
30 barvinok_options *options) const
32 if (eq) {
33 for (int i = 0; i < eq->NbRows; ++i) {
34 Inner_Product(eq->p[i]+1, params, eq->NbColumns-2, eq->p[i]);
35 if (value_notzero_p(eq->p[i][0])) {
36 value_set_si(*c, 0);
37 return;
41 if (div) {
42 Value tmp;
43 value_init(tmp);
44 for (int i = 0; i < div->NbRows; ++i) {
45 Inner_Product(div->p[i], params, div->NbColumns-1, &tmp);
46 if (!mpz_divisible_p(tmp, div->p[i][div->NbColumns-1])) {
47 value_set_si(*c, 0);
48 return;
51 value_clear(tmp);
54 ZZ coeff;
55 if (!T)
56 coeff = gf->coefficient(params, options);
57 else {
58 Vector *p2 = Vector_Alloc(T->NbRows);
59 Matrix_Vector_Product(T, params, p2->p);
60 if (value_notone_p(p2->p[T->NbRows-1]))
61 Vector_AntiScale(p2->p, p2->p, p2->p[T->NbRows-1], T->NbRows);
62 coeff = gf->coefficient(p2->p, options);
63 Vector_Free(p2);
66 zz2value(coeff, *c);