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(const QQ
& c
, const vec_ZZ
& num
, const mat_ZZ
& den_f
)
18 gf
->add(c
, num
, den_f
);
21 void partial_reducer::split(const mat_ZZ
& num
, vec_ZZ
& num_s
, mat_ZZ
& num_p
,
22 const 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
) {
33 for (int k
= 0; k
< nvar
; ++k
)
35 den_s
[r
] = tmp
* lambda
;
36 all_zero
= den_s
[r
] == 0;
38 for (int k
= nvar
; k
< dim
; ++k
) {
39 den_r
[r
][k
-nvar
] = den_f
[r
][k
];
41 all_zero
= den_r
[r
][k
-nvar
] == 0;
47 num_s
.SetLength(num
.NumRows());
48 num_p
.SetDims(num
.NumRows(), lower
);
49 for (int i
= 0; i
< num
.NumRows(); ++i
) {
50 for (int k
= 0; k
< nvar
; ++k
)
52 num_s
[i
] = tmp
* lambda
;
53 for (int k
= nvar
; k
< dim
; ++k
)
54 num_p
[i
][k
-nvar
] = num
[i
][k
];
58 void partial_reducer::base(const QQ
& c
, const vec_ZZ
& num
, const mat_ZZ
& den_f
)
60 gf
->add(c
, num
, den_f
);
63 void partial_reducer::base(const vec_QQ
& c
, const mat_ZZ
& num
, const mat_ZZ
& den_f
)
65 gf
->add(new short_rat(c
, num
, den_f
));
68 void partial_bfcounter::base(mat_ZZ
& factors
, bfc_vec
& v
)
71 unsigned nf
= factors
.NumRows();
73 for (int i
= 0; i
< v
.size(); ++i
) {
74 bfc_term
* bfct
= static_cast<bfc_term
*>(v
[i
]);
75 den
.SetDims(0, lower
);
78 for (int j
= 0; j
< nf
; ++j
) {
79 total_power
+= v
[i
]->powers
[j
];
80 den
.SetDims(total_power
, lower
);
81 for (int k
= 0; k
< v
[i
]->powers
[j
]; ++k
)
82 den
[p
++] = factors
[j
];
84 for (int j
= 0; j
< v
[i
]->terms
.NumRows(); ++j
)
85 gf
->add(bfct
->c
[j
], v
[i
]->terms
[j
], den
);