From 49d652c600bcaa98d089a03f58db7124084d4d26 Mon Sep 17 00:00:00 2001 From: Gael Guennebaud Date: Wed, 30 Nov 2011 21:55:54 +0100 Subject: [PATCH] fix assigment from uncompressed --- Eigen/src/SparseCore/SparseMatrixBase.h | 88 ++++++++++++++----------- 1 file changed, 48 insertions(+), 40 deletions(-) diff --git a/Eigen/src/SparseCore/SparseMatrixBase.h b/Eigen/src/SparseCore/SparseMatrixBase.h index 0dd56c5ec..849e00593 100644 --- a/Eigen/src/SparseCore/SparseMatrixBase.h +++ b/Eigen/src/SparseCore/SparseMatrixBase.h @@ -180,16 +180,7 @@ template class SparseMatrixBase : public EigenBase Derived& markAsRValue() { m_isRValue = true; return derived(); } SparseMatrixBase() : m_isRValue(false) { /* TODO check flags */ } - -// inline Derived& operator=(const Derived& other) -// { -// // std::cout << "Derived& operator=(const Derived& other)\n"; -// // if (other.isRValue()) -// // derived().swap(other.const_cast_derived()); -// // else -// this->operator=(other); -// return derived(); -// } + template Derived& operator=(const ReturnByValue& other) @@ -199,6 +190,52 @@ template class SparseMatrixBase : public EigenBase } + template + inline Derived& operator=(const SparseMatrixBase& other) + { + return assign(other.derived()); + } + + inline Derived& operator=(const Derived& other) + { +// if (other.isRValue()) +// derived().swap(other.const_cast_derived()); +// else + return assign(other.derived()); + } + + protected: + + template + inline Derived& assign(const OtherDerived& other) + { + const bool transpose = (Flags & RowMajorBit) != (OtherDerived::Flags & RowMajorBit); + const Index outerSize = (int(OtherDerived::Flags) & RowMajorBit) ? other.rows() : other.cols(); + if ((!transpose) && other.isRValue()) + { + // eval without temporary + derived().resize(other.rows(), other.cols()); + derived().setZero(); + derived().reserve((std::max)(this->rows(),this->cols())*2); + for (Index j=0; j inline void assignGeneric(const OtherDerived& other) { @@ -230,36 +267,7 @@ template class SparseMatrixBase : public EigenBase derived() = temp.markAsRValue(); } - - template - inline Derived& operator=(const SparseMatrixBase& other) - { - const bool transpose = (Flags & RowMajorBit) != (OtherDerived::Flags & RowMajorBit); - const Index outerSize = (int(OtherDerived::Flags) & RowMajorBit) ? other.rows() : other.cols(); - if ((!transpose) && other.isRValue()) - { - // eval without temporary - derived().resize(other.rows(), other.cols()); - derived().setZero(); - derived().reserve((std::max)(this->rows(),this->cols())*2); - for (Index j=0; j inline Derived& operator=(const SparseSparseProduct& product);