cleaning useless function

parent 1f951295
......@@ -63,25 +63,15 @@ void buildmats(const std::string& critpairs_file,
step_reductors.clear();
// std::set<std::pair<Monomial, PolynomialInMatrix> > set_pols;
std::vector<Polynomial> crit_pols;
for (const auto& it : step_critical_pairs) {
// 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));
// 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 =
......@@ -89,7 +79,6 @@ void buildmats(const std::string& critpairs_file,
step_critical_pairs.clear();
// TODO(pj): Not good to give already row_decorations
B->row_dec_ = v1;
B->col_dec_ = v2;
......@@ -97,17 +86,14 @@ void buildmats(const std::string& critpairs_file,
D->col_dec_ = v2;
std::cerr << "buildmats: " << std::endl;
std::cerr << " F4 matrix size: " << A->row_size() + C->row_size() <<
"*" << A->column_size() + B->column_size() << std::endl;
std::cerr << " size of A: " << A->row_size() << std::endl;
std::cerr << " density of A, B, C, D: " <<
std::cerr << " F4 matrix size: (" << A->row_size() << "+" << C->row_size() <<
")*(" << A->column_size() << "+" << B->column_size() << ")" << std::endl;
std::cerr << " Total densities of A, B, C, D: " <<
A->density()*100 << "%, " <<
B->density()*100 << "%, " <<
C->density()*100 << "%, " <<
D->density()*100 << "%. " << std::endl;
TINYGB_TRY(WriteSpMat (*A, matA_file), "buildmats");
TINYGB_TRY(WriteRowMajMat(*B, matB_file), "buildmats");
TINYGB_TRY(WriteRowMajMat(*C, matC_file), "buildmats");
......
......@@ -26,10 +26,6 @@ class MatrixFactory {
const std::vector<std::pair<Monomial, PolynomialInMatrix> >&,
const std::vector<Monomial>&);
static std::pair<std::shared_ptr<RowMajMat>, std::shared_ptr<RowMajMat>> BuildRowMajor(
const std::set<std::pair<Monomial, PolynomialInMatrix> >&,
const std::pair<std::vector<Monomial>, std::vector<Monomial> >&);
static std::shared_ptr<RowMajMat> BuildRowMajor(
const std::vector<Polynomial>&,
const std::vector<Monomial>&);
......@@ -86,70 +82,6 @@ std::shared_ptr<RowMajMat> MatrixFactory::BuildRowMajor(
return R;
}
std::pair<std::shared_ptr<RowMajMat>,std::shared_ptr<RowMajMat>> MatrixFactory::BuildRowMajor(
const std::set<std::pair<Monomial, PolynomialInMatrix> >& set_pols,
const std::pair<std::vector<Monomial>,std::vector<Monomial> >& list_monomials) {
auto C = std::make_shared<RowMajMat>(set_pols.size(), list_monomials.first.size());
auto D = std::make_shared<RowMajMat>(set_pols.size(), list_monomials.second.size());
Polynomial tmp;
// map which sends a monomial to the corresponding column number of C or D
// (according to the value of the flag).
std::map<Monomial, std::pair<bool, std::size_t> > map_mon;
for (std::size_t i = 0; i < list_monomials.first.size(); ++i)
map_mon.insert(std::pair<Monomial, std::pair<bool, std::size_t> >(
list_monomials.first[i],
std::pair<bool, std::size_t>(true, i)));
for (std::size_t i = 0; i < list_monomials.second.size(); ++i)
map_mon.insert(std::pair<Monomial, std::pair<bool, std::size_t> >(
list_monomials.second[i],
std::pair<bool, std::size_t>(false, i)));
// Entries of list_mon_C are: pointer to matrix, column number in the
// pointed matrix, column number in C.
// list_mon_D is similar for D.
// These list are built from polynomials stored in matrices.
std::list<std::tuple<std::shared_ptr<const StorageMatrix>, std::size_t, std::size_t> > list_mon_C, list_mon_D;
std::size_t num_pol = 0;
for (const auto& it : set_pols) {
// Initialization of list_mon_C and list_mon_D.
list_mon_C.clear();
list_mon_D.clear();
std::shared_ptr<const StorageMatrix> M = it.second.pMatrix();
std::size_t row = it.second.row();
for (std::size_t i = 0; i < M->column_size(); ++i) {
Monomial tmp_mon;
if (!(*M)(row, i).is_zero())
tmp_mon = M->ColumnMonomial(i);
else
continue;
tmp_mon *= it.first;
std::pair<bool, std::size_t> req = map_mon[tmp_mon];
if (req.first)
list_mon_C.push_back(std::tuple<std::shared_ptr<const StorageMatrix>, std::size_t, std::size_t>(M, i, req.second));
else
list_mon_D.push_back(std::tuple<std::shared_ptr<const StorageMatrix>, std::size_t, std::size_t>(M, i, req.second));
}
// The leading monomial is done separately.
Monomial LM = it.second.LeadingMonomial();
std::pair<bool, std::size_t> req = map_mon[LM*it.first];
if (req.first)
C->SetEntry(num_pol, req.second, GivaroWrapper::k.one);
else
D->SetEntry(num_pol, req.second, GivaroWrapper::k.one);
// Main loop for constructing the matrix.
for (const auto& it2 : list_mon_C)
C->SetEntry(num_pol, std::get<2>(it2), (*std::get<0>(it2))(row, std::get<1>(it2)).v);
for (const auto& it2 : list_mon_D)
D->SetEntry(num_pol, std::get<2>(it2), (*std::get<0>(it2))(row, std::get<1>(it2)).v);
num_pol++;
}
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(
......
......@@ -50,11 +50,12 @@ class SpMat {
return nb_nonzero_elts_by_row_[n];
}
// for square upper triangular with ones on the diagonal
double density() const {
std::size_t nb_nonzero_elts = 0;
for (std::size_t i = 0; i < row_size(); ++i)
nb_nonzero_elts += nb_nonzero_elts_by_row_[i];
return (double)nb_nonzero_elts/(double)row_size()/(double)column_size();
return (double)nb_nonzero_elts/((double)row_size()*(row_size()-1))*2;
}
void Print() const;
......
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