diff --git a/Eigen/src/SparseCore/SparseSelfAdjointView.h b/Eigen/src/SparseCore/SparseSelfAdjointView.h index d364c81df..80e794411 100644 --- a/Eigen/src/SparseCore/SparseSelfAdjointView.h +++ b/Eigen/src/SparseCore/SparseSelfAdjointView.h @@ -86,7 +86,7 @@ template class SparseSelfAdjointView * Note that there is no algorithmic advantage of performing such a product compared to a general sparse-sparse matrix product. * Indeed, the SparseSelfadjointView operand is first copied into a temporary SparseMatrix before computing the product. */ - template friend + template friend SparseSparseProduct::Flags&RowMajorBit) ? RowMajor : ColMajor),Index> > operator*(const SparseMatrixBase& lhs, const SparseSelfAdjointView& rhs) { diff --git a/Eigen/src/SparseCore/SparseVector.h b/Eigen/src/SparseCore/SparseVector.h index b05d409c3..188d9e1f1 100644 --- a/Eigen/src/SparseCore/SparseVector.h +++ b/Eigen/src/SparseCore/SparseVector.h @@ -241,11 +241,11 @@ class SparseVector template inline SparseVector& operator=(const SparseMatrixBase& other) { - if ( (bool(OtherDerived::IsVectorAtCompileTime) && int(RowsAtCompileTime)!=int(OtherDerived::RowsAtCompileTime)) - || ((!bool(OtherDerived::IsVectorAtCompileTime)) && ( bool(IsColVector) ? other.cols()>1 : other.rows()>1 ))) - return assign(other.transpose()); + if ( (bool(OtherDerived::IsVectorAtCompileTime) && int(RowsAtCompileTime)!=int(OtherDerived::RowsAtCompileTime)) + || ((!bool(OtherDerived::IsVectorAtCompileTime)) && ( bool(IsColVector) ? other.cols()>1 : other.rows()>1 ))) + return assign(other.transpose(), typename internal::conditional<((Flags & RowMajorBit) == (OtherDerived::Flags & RowMajorBit)),internal::true_type,internal::false_type>::type()); else - return assign(other); + return assign(other, typename internal::conditional<((Flags & RowMajorBit) != (OtherDerived::Flags & RowMajorBit)),internal::true_type,internal::false_type>::type()); } #ifndef EIGEN_PARSED_BY_DOXYGEN @@ -328,7 +328,10 @@ protected: } template - EIGEN_DONT_INLINE SparseVector& assign(const SparseMatrixBase& _other); + EIGEN_DONT_INLINE SparseVector& assign(const SparseMatrixBase& _other, internal::true_type); + + template + EIGEN_DONT_INLINE SparseVector& assign(const SparseMatrixBase& _other, internal::false_type); Storage m_data; Index m_size; @@ -400,31 +403,32 @@ class SparseVector::ReverseInnerIterator template template -EIGEN_DONT_INLINE SparseVector& SparseVector::assign(const SparseMatrixBase& _other) +EIGEN_DONT_INLINE SparseVector& SparseVector::assign(const SparseMatrixBase& _other, internal::true_type) { const OtherDerived& other(_other.derived()); - const bool needToTranspose = (Flags & RowMajorBit) != (OtherDerived::Flags & RowMajorBit); - if(needToTranspose) + + Index size = other.size(); + Index nnz = other.nonZeros(); + resize(size); + reserve(nnz); + for(Index i=0; i +template +EIGEN_DONT_INLINE SparseVector& SparseVector::assign(const SparseMatrixBase& _other, internal::false_type) +{ + const OtherDerived& other(_other.derived()); + // there is no special optimization + return Base::operator=(other); +} + } // end namespace Eigen #endif // EIGEN_SPARSEVECTOR_H