Sparse Core: Replace malloc/free with conditional_aligned

This commit is contained in:
Charles Schlosser
2022-08-23 21:44:22 +00:00
committed by Rasmus Munk Larsen
parent 6aad0f821b
commit b2a13c9dd1
3 changed files with 38 additions and 59 deletions

View File

@@ -80,12 +80,18 @@ void assign_sparse_to_sparse(DstXprType &dst, const SrcXprType &src)
const bool transpose = (DstEvaluatorType::Flags & RowMajorBit) != (SrcEvaluatorType::Flags & RowMajorBit);
const Index outerEvaluationSize = (SrcEvaluatorType::Flags&RowMajorBit) ? src.rows() : src.cols();
Index reserveSize = 0;
for (Index j = 0; j < outerEvaluationSize; ++j)
for (typename SrcEvaluatorType::InnerIterator it(srcEvaluator, j); it; ++it)
reserveSize++;
if ((!transpose) && src.isRValue())
{
// eval without temporary
dst.resize(src.rows(), src.cols());
dst.setZero();
dst.reserve((std::min)(src.rows()*src.cols(), (std::max)(src.rows(),src.cols())*2));
dst.reserve(reserveSize);
for (Index j=0; j<outerEvaluationSize; ++j)
{
dst.startVec(j);
@@ -109,7 +115,7 @@ void assign_sparse_to_sparse(DstXprType &dst, const SrcXprType &src)
DstXprType temp(src.rows(), src.cols());
temp.reserve((std::min)(src.rows()*src.cols(), (std::max)(src.rows(),src.cols())*2));
temp.reserve(reserveSize);
for (Index j=0; j<outerEvaluationSize; ++j)
{
temp.startVec(j);