Zero-out matrix for empty set of triplets.
diff --git a/Eigen/src/SparseCore/SparseMatrix.h b/Eigen/src/SparseCore/SparseMatrix.h
index 7ddb6fa..8fcdfdf 100644
--- a/Eigen/src/SparseCore/SparseMatrix.h
+++ b/Eigen/src/SparseCore/SparseMatrix.h
@@ -1130,7 +1130,11 @@
   using TransposedSparseMatrix =
       SparseMatrix<typename SparseMatrixType::Scalar, IsRowMajor ? ColMajor : RowMajor, StorageIndex>;
 
-  if (begin == end) return;
+  if (begin == end) {
+    // Clear out existing data (if any).
+    mat.setZero();
+    return;
+  }
 
   // There are two strategies to consider for constructing a matrix from unordered triplets:
   // A) construct the 'mat' in its native storage order and sort in-place (less memory); or,