1 #ifndef _FACTOR_REFINEMENT_H_ 2 #define _FACTOR_REFINEMENT_H_ 5 #include "BPASFieldOfFractions.hpp" 6 #include "../../include/RationalFunction/rationalfunction_euclideanmethods.h" 7 #include "../../include/RationalNumberPolynomial/mrpolynomial.h" 11 #include "../Utils/TemplateHelpers.hpp" 12 #include "../DataStructures/Factors.hpp" 23 template <
class Domain>
24 static void PolyRefine(
const Domain& a,
int e,
const Domain& b,
int f, Domain* ret_l,
int* ret_e, std::vector<
Factor<Domain>>* ret_G, Domain* ret_r,
int* ret_f) {
28 if(g.isOne() ==
true){
46 ret_G->push_back(std::make_pair(a,e+f));
58 std::vector<Factor<Domain>> G1,G2;
59 PolyRefine(a_,e,g,e+f,&l1,&e1,&G1,&r1,&f1);
60 PolyRefine(r1,f1,b_,f,&l2,&e2,&G2,&r2,&f2);
61 if(l2.isOne()==
false){
62 G2.push_back(std::make_pair(l2,e2));
67 ret_G->insert(ret_G->end(),G1.begin(),G1.end());
68 ret_G->insert(ret_G->end(),G2.begin(),G2.end());
85 template <
class Domain>
92 std::vector<Factor<Domain>> Q;
93 std::vector<Factor<Domain>> S;
98 for (
int i = 0; i < B.size(); ++i)
103 std::vector<Factor<Domain>> Gi;
108 PolyRefine(l0,m0,B[i].first,B[i].second,&li,&mi,&Gi,&di,&wi);
113 Q.insert(Q.end(),Gi.begin(),Gi.end());
114 if(di.isOne()==
false){
117 S.push_back(std::make_pair(di,wi));
133 ret_Q->insert(ret_Q->end(),Q.begin(),Q.end());
134 ret_S->insert(ret_S->end(),S.begin(),S.end());
145 template <
class Domain>
147 std::vector<Factor<Domain>> L,Q,S;
149 for (
int i = 0; i < A.size(); ++i)
153 std::vector<Factor<Domain>> tempQ,tempS;
154 MergeRefinePolySeq(A[i].first,A[i].second,S,&l,&m,&tempQ,&tempS);
156 Q.insert(Q.end(),tempQ.begin(),tempQ.end());
158 L.push_back(std::make_pair(l,m));
165 ret_L->insert(ret_L->end(),L.begin(),L.end());
166 ret_Q->insert(ret_Q->end(),Q.begin(),Q.end());
167 ret_S->insert(ret_S->end(),S.begin(),S.end());
184 template <
class Domain>
188 MergeRefineTwoSeq(A,B,&*ret_L,&*ret_Q,&*ret_S);
192 if(ret_L->size() == 0){
193 ret_L->push_back(std::make_pair(one,1));
195 if(ret_Q->size() == 0){
196 ret_Q->push_back(std::make_pair(one,1));
198 if(ret_S->size() == 0){
199 ret_S->push_back(std::make_pair(one,1));
Definition: FactorRefinement.hpp:14