std::experimental:: reduce, std::experimental:: hmin, std::experimental:: hmax
|
ヘッダーで定義
<experimental/simd>
|
||
|
template
<
class
T,
class
Abi,
class
BinaryOperation
=
std::
plus
<>
>
T reduce ( const simd < T, Abi > & v, BinaryOperation binary_op = { } ) ; |
(1) | (parallelism TS v2) |
|
template
<
class
M,
class
V,
class
BinaryOperation
>
typename
V
::
value_type
|
(2) | (parallelism TS v2) |
|
template
<
class
M,
class
V
>
typename
V
::
value_type
|
(3) | (parallelism TS v2) |
|
template
<
class
M,
class
V
>
typename
V
::
value_type
|
(4) | (parallelism TS v2) |
|
template
<
class
M,
class
V
>
typename
V
::
value_type
|
(5) | (parallelism TS v2) |
|
template
<
class
M,
class
V
>
typename
V
::
value_type
|
(6) | (parallelism TS v2) |
|
template
<
class
M,
class
V
>
typename
V
::
value_type
|
(7) | (parallelism TS v2) |
|
template
<
class
T,
class
Abi
>
T hmin ( const simd < T, Abi > & v ) noexcept ; |
(8) | (parallelism TS v2) |
|
template
<
class
M,
class
V
>
typename
V
::
value_type
|
(9) | (parallelism TS v2) |
|
template
<
class
M,
class
V
>
typename
V
::
value_type
|
(9) | (並列処理 TS v2) |
|
template
<
class
T,
class
Abi
>
T hmax ( const simd < T, Abi > & v ) noexcept ; |
(10) | (parallelism TS v2) |
|
template
<
class
M,
class
V
>
typename
V
::
value_type
|
(11) | (parallelism TS v2) |
binary_op が結合的でも可換的でもない場合、動作は非決定的となります。
目次 |
パラメータ
| v | - |
リダクションを適用する
simd
ベクトル
|
| x | - |
リダクションを適用する
where
式の戻り値
|
| identity_element | - | binary_op に対する単位元として機能する値。 binary_op ( identity_element, a ) == a が V :: value_type 型のすべての有限な a に対して成り立たなければならない |
| binary_op | - |
二項
FunctionObject
。
V
::
value_type
型または
simd
<
V
::
value_type
, A
>
型(未指定のABIタグ
A
を持つ)の引数に未指定の順序で適用される。
binary_op
(
v, v
)
は
V
に変換可能でなければならない
|
戻り値
このタイプの操作の結果:
T
例
#include <array> #include <cassert> #include <cstddef> #include <experimental/simd> #include <functional> #include <iostream> #include <numeric> namespace stdx = std::experimental; int main() { using V = stdx::native_simd<double>; alignas(stdx::memory_alignment_v<V>) std::array<V::value_type, 1024> data; std::iota(data.begin(), data.end(), 0); V::value_type acc{}; for (std::size_t i = 0; i < data.size(); i += V::size()) acc += stdx::reduce(V(&data[i], stdx::vector_aligned), std::plus{}); std::cout << "sum of data = " << acc << '\n'; using W = stdx::fixed_size_simd<int, 4>; alignas(stdx::memory_alignment_v<W>) std::array<int, 4> arr{2, 5, 4, 1}; auto w = W(&arr[0], stdx::vector_aligned); assert(stdx::hmin(w) == 1 and stdx::hmax(w) == 5); }
出力:
sum of data = 523776
関連項目
|
(C++17)
|
std::accumulate
と同様だが、順序が不定
(関数テンプレート) |