factory methods should return unique_ptr

parent 5af46f89
......@@ -6,7 +6,7 @@ debug = ARGUMENTS.get('debug', 0)
env = Environment( #variables = vars,
CXX = 'g++',
CXXFLAGS = Split('-I./include -I./src \
-march=native -mtune=native -std=gnu++11 -fabi-version=6 \
-march=native -mtune=native -std=gnu++14 -fabi-version=6 \
-fpermissive -Wall -Wextra -fopenmp'),
LIBPATH = '#lib/',
LIBS = Split('-lopenblas -lgivaro -lgmpxx -lgmp'),
......
......@@ -18,23 +18,23 @@ class MatrixFactory {
public:
// TODO(pj): Check that no zero element is added
// TODO(pj): Is the vector of monomials required?
static std::shared_ptr<SpMat> BuildSparseUpperTriangular(
static std::unique_ptr<SpMat> BuildSparseUpperTriangular(
const std::vector<std::pair<Monomial, PolynomialInMatrix> >&,
const std::vector<Monomial>&);
static std::shared_ptr<RowMajMat> BuildRowMajor(
static std::unique_ptr<RowMajMat> BuildRowMajor(
const std::vector<std::pair<Monomial, PolynomialInMatrix> >&,
const std::vector<Monomial>&);
static std::shared_ptr<RowMajMat> BuildRowMajor(
static std::unique_ptr<RowMajMat> BuildRowMajor(
const std::vector<Polynomial>&,
const std::vector<Monomial>&);
};
std::shared_ptr<SpMat> MatrixFactory::BuildSparseUpperTriangular(
std::unique_ptr<SpMat> MatrixFactory::BuildSparseUpperTriangular(
const std::vector<std::pair<Monomial, PolynomialInMatrix> >& list_reductors,
const std::vector<Monomial>& list_monomials) {
auto R = std::make_shared<SpMat>();
auto R = std::make_unique<SpMat>();
R->nb_nonzero_elts_by_row_.clear();
R->row_size_ = list_reductors.size();
R->column_size_ = list_monomials.size();
......@@ -62,10 +62,10 @@ std::shared_ptr<SpMat> MatrixFactory::BuildSparseUpperTriangular(
return R;
}
std::shared_ptr<RowMajMat> MatrixFactory::BuildRowMajor(
std::unique_ptr<RowMajMat> MatrixFactory::BuildRowMajor(
const std::vector<std::pair<Monomial, PolynomialInMatrix> > &list_reductors,
const std::vector<Monomial> &list_monomials) {
auto R = std::make_shared<RowMajMat>(list_reductors.size(), list_monomials.size());
auto R = std::make_unique<RowMajMat>(list_reductors.size(), list_monomials.size());
Polynomial tmp;
std::map<Monomial, std::size_t> map_mon;
for (std::size_t i = 0; i < list_monomials.size(); ++i)
......@@ -84,10 +84,10 @@ std::shared_ptr<RowMajMat> MatrixFactory::BuildRowMajor(
// TODO: if the input polynomials must be monic, then this should be specified
// in an assert
std::shared_ptr<RowMajMat> MatrixFactory::BuildRowMajor(
std::unique_ptr<RowMajMat> MatrixFactory::BuildRowMajor(
const std::vector<Polynomial>& list_pols,
const std::vector<Monomial>& list_monomials) {
auto R = std::make_shared<RowMajMat>(list_pols.size(), list_monomials.size());
auto R = std::make_unique<RowMajMat>(list_pols.size(), list_monomials.size());
std::map<Monomial, std::size_t> map_mon;
for (std::size_t i = 0; i < list_monomials.size(); ++i)
map_mon.insert(std::pair<Monomial, std::size_t>(list_monomials[i], i));
......
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