Assigning a SymmetricMatrix to a symmetric sumbatrix of another SymmetrixMatrix uses a temporary matrix for evaluation

Issue #289 open
Mikhail Katliar created an issue

Example:

using namespace blaze;

SymmetricMatrix<StaticMatrix<double, 5, 5, columnMajor>> A;
randomize(A);

SymmetricMatrix<StaticMatrix<double, 4, 4, columnMajor>> B;
randomize(B);

submatrix<1, 1, 4, 4>(A) += B; // <-- evaluates a temporary for A + B

Here, during the add-assignment in line 9 a temporary matrix is used (which degrades the performance):

if( ( ( IsSymmetric_v<MT> || IsHermitian_v<MT> ) && hasOverlap() ) ||
    (~rhs).canAlias( &matrix_ ) ) {
  const AddType tmp( *this + (~rhs) );
  smpAssign( left, tmp );
}
else {
  smpAddAssign( left, ~rhs );
}

The if condition is true because the matrix is symmetric and hasOverlap() returns true.

Comments (7)

  1. Klaus Iglberger

    Hi Misha!

    Thanks for reporting this defect. You are correct, in this special case the temporary is not required. We will fix this as quickly as possible.

    Best regards,

    Klaus!

  2. Log in to comment