Blaze 3.9
blaze::KronTrait< T1, T2, typename > Struct Template Reference

Base template for the KronTrait class. More...

#include <KronTrait.h>

Inherits decltype evalKronTrait std::declval< T1 & >, and std::declval< T2 & >.

Detailed Description

template<typename T1, typename T2, typename>
struct blaze::KronTrait< T1, T2, typename >

Base template for the KronTrait class.

General

The KronTrait class template offers the possibility to select the resulting data type of a generic Kronecker product operation between the two given types T1 and T2. KronTrait defines the nested type Type, which represents the resulting data type of the Kronecker product. In case T1 and T2 cannot be combined in a Kronecker product, there is no nested type Type. Note that const and volatile qualifiers and reference modifiers are generally ignored.


Creating custom specializations

Per default, KronTrait supports all vector and matrix types of the Blaze library (including views and adaptors). For all other data types it is possible to specialize the KronTrait template. The following example shows the according specialization for the Kronecker product between two static matrices with equal storage order:

template< typename T1, size_t M1, size_t N1, bool SO, typename T2, size_t M2, size_t N2 >
struct KronTrait< StaticMatrix<T1,M1,N1,SO>, StaticMatrix<T2,M2,N2,SO> >
{
using Type = StaticMatrix< MultTrait_t<T1,T2>, M1*M2, N1*N2, SO >;
};


Examples

The following example demonstrates the use of the KronTrait template, where depending on the two given data types the resulting data type is selected:

template< typename T1, typename T2 > // The two generic types
typename KronTrait<T1,T2>::Type // The resulting generic return type
kronecker( T1 t1, T2 t2 ) //
{ // The function 'kronecker' returns the Kronecker
return kron( t1, t2 ); // product of the two given values
} //
decltype(auto) kron(const DenseMatrix< MT1, SO1 > &lhs, const DenseMatrix< MT2, SO2 > &rhs)
Computes the Kronecker product of two dense matrices ( ).
Definition: DMatDMatKronExpr.h:957

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