Views¶
Synopsis:
template <typename ValueType, int Rank, typename TraversalOrder=void> class array_view;
template <typename ValueType, typename TraversalOrder=void> class matrix_view;
template <typename ValueType> class vector_view;
template <typename ValueType, int Rank, typename TraversalOrder=void> class array_const_view;
template <typename ValueType, typename TraversalOrder=void> class matrix_const_view;
template <typename ValueType> class vector_const_view;
The view types of X (= array, matrix, vector) are called X_view, and X_const_view, with the same template parameters as the regular type.
A view is give access to a restricted portion of the array, matrix or vector, i.e. a partial view of the data. The view can also be complete (i.e. show all the container).
The views model the MutableCuboidArray, MutableMatrix, MutableVector, like the corresponding regular type.
The const views are similar to view, except that theirs contents cannot be modified. They model the ImmutableCuboidArray, ImmutableMatrix, ImmutableVector, like the corresponding const regular type.
Views have view semantics, i.e. their behave like a documentation/manual/triqs to the data, they are not regular type. In particular, they never make copy of the data. See Regular type vs view type for a detailed discussion of the difference between a regular type and its corresponding view.
Views are largely interoperable: it is easy and quick to take a matrix_view of an array, or vice versa. Cf constructors belows.
Const views can be constructed from a view, but the reverse is not true (Cf constructors).
Memory Management
Views offers a strong guarantee of the existence of the data, like a std::shared_ptr. Cf View memory management for details.
Template parameters¶
Template parameter | Accepted type | Access in the class | Meaning |
---|---|---|---|
ValueType | any regular type (typically a scalar). | value_type | The type of the element of the array |
Rank | int | rank | The rank of the array |
TraversalOrder | ull_t | Traversal Order for all loops |
NB: Rank is only present for array, since matrix have rank 2 and vector rank 1.
Member types¶
Member type | Definitions |
---|---|
value_type | ValueType |
view_type | The corresponding view type |
const_view_type | The corresponding const view type |
regular_type | The corresponding regular type |
Member constexpr¶
Member | Type | Definitions |
---|---|---|
rank | int | Rank of the container (Rank for array), 2 for matrix, 1 for vector |
Member functions¶
Member function | Meaning |
---|---|
(constructor) | |
(destructor) | |
operator () | element of access/views/lazy expressions |
operator = | assigns values to the container |
operator +=,-=,*=,/= | compound assignment operators |
begin/cbegin | returns iterator to the beginning |
end/cend | returns iterator to the end |
rebind | rebind the view |
bool is_empty() const | Is the array empty ? |
Note
views cannot be resized.
Non-member functions¶
Member function | Meaning |
---|---|
swap | Swap of 2 containers |
deep_swap | Deep swap of the data of 2 containers ??? |
operator<< | Writing to stream |