IsDenseMatrix and Submatrix

Issue #242 wontfix
Jannik Schürg created an issue

I am using BLAZE_CONSTRAINT_MUST_BE_DENSE_MATRIX_TYPE and I got the error

test.cpp:158:3:error: static_assert failed due to requirement
      '::blaze::IsDenseMatrix_v<blaze::Submatrix<blaze::CustomMatrix<double, true, true, false, blaze::DynamicMatrix<double, false> >, blaze::unaligned, false, true> &>'
      "Non-dense matrix type detected"
  BLAZE_CONSTRAINT_MUST_BE_DENSE_MATRIX_TYPE(MT3);
blaze/blaze/math/constraints/DenseMatrix.h:62:4: note: expanded from macro 'BLAZE_CONSTRAINT_MUST_BE_DENSE_MATRIX_TYPE'
   static_assert( ::blaze::IsDenseMatrix_v<T>, "Non-dense matrix type detected" )

for the type '::blaze::IsDenseMatrix_v<blaze::Submatrix<blaze::CustomMatrix<double, true, true, false, blaze::DynamicMatrix<double, false> >, blaze::unaligned, false, true> &>. Is this expected bahavior? It worked around v3.3.

Comments (1)

  1. Klaus Iglberger

    Hi Jannik!

    Thanks for creating issue. As the following test code proves, both the type trait as well as the constraint work perfectly:

    std::vector<int> v{ 1, 2, 3, 4, 5, 6, 7, 8, 9 };
    CustomMatrix<int,unaligned,unpadded> A( v.data(), 3UL, 3UL );
    auto B = submatrix( A, 1UL, 1UL, 2UL, 2UL );
    
    std::cout << " IsDenseMatrix< decltype(B) >::value = " << IsDenseMatrix< decltype(B) >::value << "\n";  // Prints 1
    
    BLAZE_CONSTRAINT_MUST_BE_DENSE_MATRIX_TYPE( decltype(B) );  // Cleanly compiles
    

    From the error message, however, I get the information that you are asking whether a reference to a submatrix IS-A DenseMatrix:

    '::blaze::IsDenseMatrix_v<blaze::Submatrix<blaze::CustomMatrix<double, true, true, false, blaze::DynamicMatrix<double, false> >, blaze::unaligned, false, true> &>'
                                                                                                                                                                    ^
                                                                                                                                                   'reference to a blaze::Submatrix'
    

    A reference (or pointer) to a dense matrix type is not considered a dense matrix type itself. When using std::remove_reference or blaze::RemoveReference on the type the code will compile cleanly.

    The erroneous behavior of the IsDenseMatrix type trait (along with many similar type traits) was fixed with commit 2728d4d, which as officially released in Blaze 3.5. Before, references as well as types with conversion operators would erroneously be flagged as dense matrix types.

    I hope this helps, Thanks again for creating the issue,

    Best regards,

    Klaus!

  2. Log in to comment