aboutsummaryrefslogtreecommitdiffhomepage
path: root/Eigen/src/SparseCore
diff options
context:
space:
mode:
authorGravatar Gael Guennebaud <g.gael@free.fr>2014-07-01 11:48:49 +0200
committerGravatar Gael Guennebaud <g.gael@free.fr>2014-07-01 11:48:49 +0200
commit7ffd55c98034964f735e7d6f11c01dcc2cf883ee (patch)
treeba075f2d13caa4aa7b0c5582ddc4687525c8178c /Eigen/src/SparseCore
parentc401167712e632a2739ceed26233a510238fc5fc (diff)
Do not bypass aliasing in sparse e assignments
Diffstat (limited to 'Eigen/src/SparseCore')
-rw-r--r--Eigen/src/SparseCore/SparseAssign.h4
-rw-r--r--Eigen/src/SparseCore/SparseMatrix.h19
2 files changed, 17 insertions, 6 deletions
diff --git a/Eigen/src/SparseCore/SparseAssign.h b/Eigen/src/SparseCore/SparseAssign.h
index 68a6ca20e..c99f4b74e 100644
--- a/Eigen/src/SparseCore/SparseAssign.h
+++ b/Eigen/src/SparseCore/SparseAssign.h
@@ -143,7 +143,7 @@ template<typename Derived>
template<typename OtherDerived>
inline Derived& SparseMatrixBase<Derived>::operator=(const SparseMatrixBase<OtherDerived>& other)
{
- internal::call_assignment_no_alias(derived(), other.derived());
+ internal::call_assignment/*_no_alias*/(derived(), other.derived());
return derived();
}
@@ -184,7 +184,7 @@ void assign_sparse_to_sparse(DstXprType &dst, const SrcXprType &src)
typedef typename internal::evaluator<SrcXprType>::type SrcEvaluatorType;
SrcEvaluatorType srcEvaluator(src);
-
+
const bool transpose = (DstEvaluatorType::Flags & RowMajorBit) != (SrcEvaluatorType::Flags & RowMajorBit);
const Index outerSize = (int(SrcEvaluatorType::Flags) & RowMajorBit) ? src.rows() : src.cols();
if ((!transpose) && src.isRValue())
diff --git a/Eigen/src/SparseCore/SparseMatrix.h b/Eigen/src/SparseCore/SparseMatrix.h
index 56bf5aaf1..6df4da51a 100644
--- a/Eigen/src/SparseCore/SparseMatrix.h
+++ b/Eigen/src/SparseCore/SparseMatrix.h
@@ -649,7 +649,13 @@ class SparseMatrix
EIGEN_STATIC_ASSERT((internal::is_same<Scalar, typename OtherDerived::Scalar>::value),
YOU_MIXED_DIFFERENT_NUMERIC_TYPES__YOU_NEED_TO_USE_THE_CAST_METHOD_OF_MATRIXBASE_TO_CAST_NUMERIC_TYPES_EXPLICITLY)
check_template_parameters();
+#ifndef EIGEN_TEST_EVALUATORS
*this = other.derived();
+#else
+ const bool needToTranspose = (Flags & RowMajorBit) != (internal::evaluator<OtherDerived>::Flags & RowMajorBit);
+ if (needToTranspose) *this = other.derived();
+ else internal::call_assignment_no_alias(*this, other.derived());
+#endif
}
/** Constructs a sparse matrix from the sparse selfadjoint view \a other */
@@ -722,6 +728,7 @@ class SparseMatrix
return *this;
}
+#ifndef EIGEN_TEST_EVALUATORS
#ifndef EIGEN_PARSED_BY_DOXYGEN
template<typename Lhs, typename Rhs>
inline SparseMatrix& operator=(const SparseSparseProduct<Lhs,Rhs>& product)
@@ -738,6 +745,7 @@ class SparseMatrix
inline SparseMatrix& operator=(const EigenBase<OtherDerived>& other)
{ return Base::operator=(other.derived()); }
#endif
+#endif // EIGEN_TEST_EVALUATORS
template<typename OtherDerived>
EIGEN_DONT_INLINE SparseMatrix& operator=(const SparseMatrixBase<OtherDerived>& other);
@@ -1174,7 +1182,9 @@ EIGEN_DONT_INLINE SparseMatrix<Scalar,_Options,_Index>& SparseMatrix<Scalar,_Opt
else
{
if(other.isRValue())
+ {
initAssignment(other.derived());
+ }
// there is no special optimization
return Base::operator=(other.derived());
}
@@ -1336,12 +1346,13 @@ struct evaluator<SparseMatrix<_Scalar,_Options,_Index> >
Flags = SparseMatrixType::Flags
};
- evaluator(const SparseMatrixType &mat) : m_matrix(mat) {}
+ evaluator() : m_matrix(0) {}
+ evaluator(const SparseMatrixType &mat) : m_matrix(&mat) {}
- operator SparseMatrixType&() { return m_matrix.const_cast_derived(); }
- operator const SparseMatrixType&() const { return m_matrix; }
+ operator SparseMatrixType&() { return m_matrix->const_cast_derived(); }
+ operator const SparseMatrixType&() const { return *m_matrix; }
- const SparseMatrixType &m_matrix;
+ const SparseMatrixType *m_matrix;
};
}