prereducing Spairs

parent 337d606e
......@@ -36,7 +36,7 @@ void buildmats(const std::string& critpairs_file,
for (const auto& itPP : step_critical_pairs) {
itPP.left().second.AddMonomialsMultipliedByCofactor(tlv2, itPP.left().first);
itPP.right().second.AddMonomialsMultipliedByCofactor(tlv2, itPP.right().first);
tlv2.insert(itPP.left().first*itPP.left().second.LeadingMonomial());
// tlv2.insert(itPP.left().first*itPP.left().second.LeadingMonomial());
// TODO(pj) : improve efficiency
}
......@@ -63,19 +63,30 @@ void buildmats(const std::string& critpairs_file,
step_reductors.clear();
std::set<std::pair<Monomial, PolynomialInMatrix> > set_pols;
// std::set<std::pair<Monomial, PolynomialInMatrix> > set_pols;
std::vector<Polynomial> crit_pols;
for (const auto& it : step_critical_pairs) {
set_pols.insert(it.left());
set_pols.insert(it.right());
// crit_pols.push_back(it.Spolynomial());
Polynomial tmp = it.left().second.to_polynomial()*it.left().first;
tmp -= it.right().second.to_polynomial()*it.right().first;
tmp.DivideByLeadingCoefficient();
crit_pols.push_back(tmp);
// set_pols.insert(it.left());
// set_pols.insert(it.right());
}
// TODO(pj): is it useful to have a factory method just for this case?
auto pair_mat =
MatrixFactory::BuildRowMajor(set_pols, std::pair<std::vector<Monomial>, std::vector<Monomial> >(v1, v2));
// auto pair_mat =
// MatrixFactory::BuildRowMajor(set_pols, std::pair<std::vector<Monomial>, std::vector<Monomial> >(v1, v2));
// std::shared_ptr<RowMajMat> C = pair_mat.first;
// std::shared_ptr<RowMajMat> D = pair_mat.second;
std::shared_ptr<RowMajMat> C =
MatrixFactory::BuildRowMajor(crit_pols, v1);
std::shared_ptr<RowMajMat> D =
MatrixFactory::BuildRowMajor(crit_pols, v2);
std::shared_ptr<RowMajMat> C = pair_mat.first;
std::shared_ptr<RowMajMat> D = pair_mat.second;
step_critical_pairs.clear();
......
......@@ -150,6 +150,8 @@ std::pair<std::shared_ptr<RowMajMat>,std::shared_ptr<RowMajMat>> MatrixFactory::
return std::pair<std::shared_ptr<RowMajMat>,std::shared_ptr<RowMajMat>>(C, D);
}
// TODO: if the input polynomials must be monic, then this should be specified
// in an assert
std::shared_ptr<RowMajMat> MatrixFactory::BuildRowMajor(
const std::vector<Polynomial>& list_pols,
const std::vector<Monomial>& list_monomials) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment