blaze::DeclDiagTrait< MT > Struct Template Reference

Base template for the DeclDiagTrait class. More...

#include <DeclDiagTrait.h>

Detailed Description

template<typename MT>
struct blaze::DeclDiagTrait< MT >

Base template for the DeclDiagTrait class.

General

The DeclDiagTrait class template offers the possibility to select the resulting data type of a generic decldiag() operation on the given type MT. DeclDiagTrait defines the nested type Type, which represents the resulting data type of the decldiag() operation. In case the given data type is not a dense or sparse matrix type, the resulting data type Type is set to INVALID_TYPE. Note that const and volatile qualifiers and reference modifiers are generally ignored.

Creating custom specializations

Per default, DeclDiagTrait supports all matrix types of the Blaze library (including views and adaptors). For all other data types it is possible to specialize the DeclDiagTrait template. The following example shows the according specialization for the SymmetricMatrix class template:

template< typename MT, bool SO, bool DF, bool NF >
struct DeclDiagTrait< SymmetricMatrix<MT,SO,DF,NF> >
{
using Type = DiagonalMatrix<MT>;
};


Examples

The following example demonstrates the use of the DeclDiagTrait template, where depending on the given matrix type the resulting type is selected:

// Definition of the resulting type of a row-major dynamic matrix
using MatrixType1 = DynamicMatrix<int,rowMajor>;
using DeclDiagType1 = typename DeclDiagTrait<MatrixType1>::Type;
// Definition of the resulting type of a symmetric column-major static matrix
using MatrixType2 = SymmetricMatrix< StaticMatrix<int,3UL,3UL,columnMajor> >;
using DeclDiagType2 = typename DeclDiagTrait<MatrixType2>::Type;

The documentation for this struct was generated from the following file: