mirror of
https://gitlab.com/libeigen/eigen.git
synced 2025-07-26 23:02:04 +08:00
Fix setFromTripplet with empty inputs
This commit is contained in:
parent
aa8b897607
commit
fcdbfabf7a
@ -911,6 +911,8 @@ void set_from_triplets(const InputIterator& begin, const InputIterator& end, Spa
|
|||||||
typedef typename SparseMatrixType::Scalar Scalar;
|
typedef typename SparseMatrixType::Scalar Scalar;
|
||||||
SparseMatrix<Scalar,IsRowMajor?ColMajor:RowMajor> trMat(mat.rows(),mat.cols());
|
SparseMatrix<Scalar,IsRowMajor?ColMajor:RowMajor> trMat(mat.rows(),mat.cols());
|
||||||
|
|
||||||
|
if(begin<end)
|
||||||
|
{
|
||||||
// pass 1: count the nnz per inner-vector
|
// pass 1: count the nnz per inner-vector
|
||||||
VectorXi wi(trMat.outerSize());
|
VectorXi wi(trMat.outerSize());
|
||||||
wi.setZero();
|
wi.setZero();
|
||||||
@ -924,6 +926,7 @@ void set_from_triplets(const InputIterator& begin, const InputIterator& end, Spa
|
|||||||
|
|
||||||
// pass 3:
|
// pass 3:
|
||||||
trMat.sumupDuplicates();
|
trMat.sumupDuplicates();
|
||||||
|
}
|
||||||
|
|
||||||
// pass 4: transposed copy -> implicit sorting
|
// pass 4: transposed copy -> implicit sorting
|
||||||
mat = trMat;
|
mat = trMat;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user