Blaze  3.6
blaze::ReduceTrait< T, OP, RF > Struct Template Reference

Base template for the ReduceTrait class. More...

#include <ReduceTrait.h>

Detailed Description

template<typename T, typename OP, size_t... RF>
struct blaze::ReduceTrait< T, OP, RF >

Base template for the ReduceTrait class.

General

The ReduceTrait class template offers the possibility to select the resulting data type of a generic reduction operation on the given type T. ReduceTrait defines the nested type Type, which represents the resulting data type of the reduction operation. In case no result type can be determined for the type T, 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

ReduceTrait is guaranteed to work for all vector and matrix types of the Blaze library (including views and adaptors) and all data types that work in combination with the provided reduction operation OP. In order to add support for user-defined data types or in order to adapt to special cases it is possible to specialize the ReduceTrait template. The following examples shows the according specialization for total and partial reduction operations with a dynamic matrix, respectively:

template< typename T, bool SO, typename OP >
struct ReduceTrait< DynamicMatrix<T,SO>, OP >
{
using Type = T;
};
template< typename T, bool SO, typename OP >
struct ReduceTrait< DynamicMatrix<T,SO>, OP, 0UL >
{
using Type = DynamicVector<T,rowVector>;
};
template< typename T, bool SO, typename OP >
struct ReduceTrait< DynamicMatrix<T,SO>, OP, 1UL >
{
using Type = DynamicVector<T,columnVector>;
};

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