mirror of
https://gitlab.com/libeigen/eigen.git
synced 2025-06-04 18:54:00 +08:00
Add explicit ctor for diagonal to sparse conversion
This commit is contained in:
parent
c38c195321
commit
4c8cd13b35
@ -695,6 +695,15 @@ class SparseMatrix
|
||||
initAssignment(other);
|
||||
other.evalTo(*this);
|
||||
}
|
||||
|
||||
/** \brief Copy constructor with in-place evaluation */
|
||||
template<typename OtherDerived>
|
||||
explicit SparseMatrix(const DiagonalBase<OtherDerived>& other)
|
||||
: Base(), m_outerSize(0), m_innerSize(0), m_outerIndex(0), m_innerNonZeros(0)
|
||||
{
|
||||
check_template_parameters();
|
||||
*this = other.derived();
|
||||
}
|
||||
|
||||
/** Swaps the content of two sparse matrices of the same type.
|
||||
* This is a fast operation that simply swaps the underlying pointers and parameters. */
|
||||
|
@ -372,6 +372,8 @@ template<typename SparseMatrixType> void sparse_basic(const SparseMatrixType& re
|
||||
SparseMatrixType m2(rows, rows);
|
||||
m2 = d.asDiagonal();
|
||||
VERIFY_IS_APPROX(m2, refMat2);
|
||||
SparseMatrixType m3(d.asDiagonal());
|
||||
VERIFY_IS_APPROX(m3, refMat2);
|
||||
refMat2 += d.asDiagonal();
|
||||
m2 += d.asDiagonal();
|
||||
VERIFY_IS_APPROX(m2, refMat2);
|
||||
|
Loading…
x
Reference in New Issue
Block a user