diff options
author | Gael Guennebaud <g.gael@free.fr> | 2009-07-07 09:05:20 +0200 |
---|---|---|
committer | Gael Guennebaud <g.gael@free.fr> | 2009-07-07 09:05:20 +0200 |
commit | 544888e342bb7d75412bf0e17b66a3c6196d24eb (patch) | |
tree | 51b4bef9f2624e7573a6e9519c210b3ec0ee268b /Eigen/src/Sparse | |
parent | 1aea45335ff60c6a5ed6dc06cd798d050eff661a (diff) |
add a generic mechanism to copy a special matrix to a dense matrix so that
we don't need to add other specialization of MatrixBase::operator=, Matrix::=,
and Matrix::Matrix(...)
Diffstat (limited to 'Eigen/src/Sparse')
-rw-r--r-- | Eigen/src/Sparse/SparseMatrixBase.h | 26 |
1 files changed, 10 insertions, 16 deletions
diff --git a/Eigen/src/Sparse/SparseMatrixBase.h b/Eigen/src/Sparse/SparseMatrixBase.h index 8c53757b0..82527f7ef 100644 --- a/Eigen/src/Sparse/SparseMatrixBase.h +++ b/Eigen/src/Sparse/SparseMatrixBase.h @@ -451,25 +451,19 @@ template<typename Derived> class SparseMatrixBase // Derived& setRandom(); // Derived& setIdentity(); - Matrix<Scalar,RowsAtCompileTime,ColsAtCompileTime> toDense() const + template<typename DenseDerived> + void evalToDense(MatrixBase<DenseDerived>& dst) { - Matrix<Scalar,RowsAtCompileTime,ColsAtCompileTime> res(rows(),cols()); - res.setZero(); + dst.resize(rows(),cols()); + dst.setZero(); for (int j=0; j<outerSize(); ++j) - { for (typename Derived::InnerIterator i(derived(),j); i; ++i) - { - if(IsRowMajor) - std::cerr << i.row() << "," << i.col() << " == " << j << "," << i.index() << "\n"; - else - std::cerr << i.row() << "," << i.col() << " == " << i.index() << "," << j << "\n"; -// if(IsRowMajor) - res.coeffRef(i.row(),i.col()) = i.value(); -// else -// res.coeffRef(i.index(),j) = i.value(); - } - } - return res; + res.coeffRef(i.row(),i.col()) = i.value(); + } + + Matrix<Scalar,RowsAtCompileTime,ColsAtCompileTime> toDense() const + { + return derived(); } template<typename OtherDerived> |