Vc  1.3.3-dev
SIMD Vector Classes for C++
array< T, Size > Struct Template Reference

Detailed Description

template<class T, size_t Size>
struct Vc::array< T, Size >

This is std::array with additional subscript operators supporting gather and scatter operations.

The std::array documentation applies.

Gathers from structured data (AoS: arrays of struct) are possible via a special subscript operator. Example:

1 Vc::array<float, 100> data;
2 std::iota(data.begin(), data.end(), 0.f); // fill with values 0, 1, 2, ...
3 auto indexes = float_v::IndexType::IndexesFromZero();
4 float_v gathered = data[indexes]; // gathered == [0, 1, 2, ...]

This also works for gathers into arrays of structures:

1 struct Point { float x, y, z; };
2 Vc::array<Point, 100> points;
3 // fill points ...
4 auto indexes = float_v::IndexType::IndexesFromZero();
5 float_v xs = data[indexes][&Point::x]; // [points[0].x, points[1].x, points[2].x, ...]
6 float_v ys = data[indexes][&Point::y]; // [points[0].y, points[1].y, points[2].y, ...]
7 float_v zs = data[indexes][&Point::z]; // [points[0].z, points[1].z, points[2].z, ...]

Arrays may also be nested:

1  :
2 Vc::array<Vc::array<float, 3>, 100> points;
3 // fill points ...
4 auto indexes = float_v::IndexType::IndexesFromZero();
5 float_v xs = data[indexes][0]; // [points[0][0], points[1][0], points[2][0], ...]
6 float_v ys = data[indexes][1]; // [points[0][1], points[1][1], points[2][1], ...]
7 float_v zs = data[indexes][2]; // [points[0][2], points[1][2], points[2][2], ...]

Definition at line 86 of file array.

Public Member Functions

Data-Parallel Subscripting for Gather & Scatter
template<typename I >
auto operator[] (I &&arg_) -> decltype(subscript_operator(*this, std::forward< I >(arg_)))
 
template<typename I >
auto operator[] (I &&arg_) const -> decltype(subscript_operator(*this, std::forward< I >(arg_)))
 

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