- edited description
- changed title to makePositiveDefinite() not working on submatrices
makePositiveDefinite() not working on submatrices
Example:
#include <blaze/Math.h>
int main(int, char **)
{
blaze::DynamicMatrix<double> Q(3, 3);
makePositiveDefinite(Q); // OK
makePositiveDefinite(submatrix(Q, 0, 0, 2, 2)); // <-- compilation error
return 0;
}
As a user I would expectmakePositiveDefinite
to work on submatrices the same way it works on full matrices.
Comments (3)
-
reporter -
Hi Mikhail!
Thanks for creating this issue. You are correct, submatrices currently don’t provide a
makePositiveDefinite()
function. However, since themakePositiveDefinite
function is part of the Blaze internals (i.e. marked asBLAZE_INTERNAL
) and not documented in the wiki, we don’t consider it a bug that the according overload is missing. For that reason we consider this issue a feature request instead of a bug and will integrate an according function with one of the next push operations. Till then, please use the following function that is very similar to the implementation we’ll provide:template< typename MT // Type of the matrix , AlignmentFlag AF // Alignment flag , bool SO // Storage order , bool DF // Density flag , size_t... CSAs > // Compile time submatrix arguments void makePositiveDefinite( Submatrix<MT,AF,SO,DF,CSAs...>& matrix ) { using blaze::randomize; using ET = ElementType_t<MT>; BLAZE_CONSTRAINT_MUST_BE_SCALAR_TYPE( ET ); if( !isSquare( matrix ) ) { BLAZE_THROW_INVALID_ARGUMENT( "Invalid non-square matrix provided" ); } const size_t n( matrix.rows() ); randomize( matrix ); matrix *= ctrans( matrix ); for( size_t i=0UL; i<n; ++i ) { matrix(i,i) += ET(n); } BLAZE_INTERNAL_ASSERT( isHermitian( matrix ), "Non-symmetric matrix detected" ); }
Thanks again for creating this issue,
Best regards,
Klaus!
-
- Log in to comment