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

Base template for the ReduceTrait class. More...

#include <ReduceTrait.h>

Inherits decltype evalReduceTrait std::declval< T & >, and std::declval< OP >.

Detailed Description

template<typename T, typename OP, ReductionFlag... 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, there is no nested type 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, columnwise >
{
using Type = DynamicVector<T,rowVector>;
};
template< typename T, bool SO, typename OP >
struct ReduceTrait< DynamicMatrix<T,SO>, OP, rowwise >
{
using Type = DynamicVector<T,columnVector>;
};
constexpr ReductionFlag columnwise
Reduction flag for column-wise reduction operations.
Definition: ReductionFlag.h:97
constexpr ReductionFlag rowwise
Reduction flag for row-wise reduction operations.
Definition: ReductionFlag.h:77

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