1 #include "genfun_constructor.h"
3 gf_base
*gf_base::create(Polyhedron
*context
, unsigned dim
, unsigned nparam
,
4 barvinok_options
*options
)
7 if (options
->incremental_specialization
== 2)
8 red
= new partial_bfcounter(context
, dim
, nparam
);
9 else if (options
->incremental_specialization
== 1)
10 red
= new partial_ireducer(context
, dim
, nparam
);
12 red
= new partial_reducer(context
, dim
, nparam
);
16 void partial_ireducer::base(QQ
& c
, const vec_ZZ
& num
, const mat_ZZ
& den_f
)
18 gf
->add(c
, num
, den_f
);
21 void partial_reducer::split(vec_ZZ
& num
, ZZ
& num_s
, vec_ZZ
& num_p
,
22 mat_ZZ
& den_f
, vec_ZZ
& den_s
, mat_ZZ
& den_r
)
24 unsigned len
= den_f
.NumRows(); // number of factors in den
25 unsigned nvar
= tmp
.length();
28 den_r
.SetDims(len
, lower
);
30 for (int r
= 0; r
< len
; ++r
) {
31 for (int k
= 0; k
< nvar
; ++k
)
33 den_s
[r
] = tmp
* lambda
;
35 for (int k
= nvar
; k
< dim
; ++k
)
36 den_r
[r
][k
-nvar
] = den_f
[r
][k
];
39 for (int k
= 0; k
< nvar
; ++k
)
42 num_p
.SetLength(lower
);
43 for (int k
= nvar
; k
< dim
; ++k
)
44 num_p
[k
-nvar
] = num
[k
];
47 void partial_reducer::base(QQ
& c
, const vec_ZZ
& num
, const mat_ZZ
& den_f
)
49 gf
->add(c
, num
, den_f
);
52 void partial_bfcounter::base(mat_ZZ
& factors
, bfc_vec
& v
)
55 unsigned nf
= factors
.NumRows();
57 for (int i
= 0; i
< v
.size(); ++i
) {
58 bfc_term
* bfct
= static_cast<bfc_term
*>(v
[i
]);
59 den
.SetDims(0, lower
);
62 for (int j
= 0; j
< nf
; ++j
) {
63 total_power
+= v
[i
]->powers
[j
];
64 den
.SetDims(total_power
, lower
);
65 for (int k
= 0; k
< v
[i
]->powers
[j
]; ++k
)
66 den
[p
++] = factors
[j
];
68 for (int j
= 0; j
< v
[i
]->terms
.NumRows(); ++j
)
69 gf
->add(bfct
->c
[j
], v
[i
]->terms
[j
], den
);