pbpt
|
A non-owning, mutable view/proxy of vector-like data. More...
#include <matrix.hpp>
Public Member Functions | |
constexpr | VectorView (const T *start, int stride) |
Constructs a read-only vector view. | |
constexpr const T & | operator[] (int i) const |
Provides read-only access to an element of the view. | |
constexpr const T & | at (int i) const |
Provides read-only access to an element of the view. | |
constexpr int | dims () const noexcept |
Returns the number of dimensions of the view. | |
constexpr T | dot (const Vector< T, N > &rhs) const |
Calculates the dot product with an owning vector. | |
constexpr T | dot (const VectorView< T, N > &rhs) const |
Calculates the dot product with another vector view. | |
constexpr Vector< T, N > | to_vector () const |
Converts the view into a new, owning Vec instance. | |
constexpr T & | operator[] (int i) |
Provides mutable access to an element of the view. | |
constexpr T & | at (int i) |
Provides mutable access to an element of the view. | |
constexpr VectorView & | operator= (const Vector< T, N > &other) |
Assigns an owning vector's content to the region represented by this view. | |
constexpr VectorView & | operator= (const VectorView< T, N > &other) |
Assigns another vector view's content to the region represented by this view. | |
void | apply (const std::function< void(T &, int)> &func) |
Applies a function to each element of the view. |
Protected Attributes | |
const T * | m_start_ptr |
Pointer to the first element of the viewed data. | |
int | m_stride |
The distance (in number of elements) between consecutive elements in the view. |
A non-owning, mutable view/proxy of vector-like data.
Extends ConstVectorView to allow modification of the underlying data.
|
inlineconstexpr |
Constructs a read-only vector view.
start | Pointer to the first element. |
stride | The step size to move between elements. For a row view, this is 1. For a column view, this is the column count of the source matrix. |
|
inline |
Applies a function to each element of the view.
func | The function to apply. |
|
inlineconstexpr |
Provides mutable access to an element of the view.
i | The index of the element. |
|
inlineconstexpr |
Provides read-only access to an element of the view.
i | The index of the element. |
|
inlineconstexpr |
Calculates the dot product with an owning vector.
rhs | The other vector. |
|
inlineconstexpr |
Calculates the dot product with another vector view.
rhs | The other vector view. |
|
inlineconstexpr |
Assigns an owning vector's content to the region represented by this view.
other | The vector to copy from. |
|
inlineconstexpr |
Assigns another vector view's content to the region represented by this view.
other | The vector view to copy from. |
|
inlineconstexpr |
Provides mutable access to an element of the view.
i | The index of the element. |
|
inlineconstexpr |
Provides read-only access to an element of the view.
i | The index of the element. |
|
inlineconstexpr |
Converts the view into a new, owning Vec instance.
This performs a copy of the elements from the viewed region.