|
Stratax 0.4.0rc1
|
Positive-step non-owning slice views with clamped bounds. More...
#include <stratax/containers/Matrix.hpp>#include <stratax/containers/Tensor.hpp>#include <stratax/containers/Vector.hpp>#include <stratax/exceptions/Exceptions.hpp>#include <stratax/core/Shape.hpp>#include <stratax/core/Slice.hpp>#include <stratax/core/ArrayView.hpp>#include <array>#include <algorithm>#include <cstddef>#include <limits>#include <vector>#include <type_traits>#include <utility>#include <concepts>

Go to the source code of this file.
Classes | |
| struct | stratax::indexing::detail::ResolvedSlice |
| Normalized first index, signed step, and selected element count. More... | |
Typedefs | |
| template<typename Source > | |
| using | stratax::indexing::detail::view_element_t = std::conditional_t< std::is_const_v< std::remove_reference_t< Source > >, const typename std::remove_cvref_t< Source >::value_type, typename std::remove_cvref_t< Source >::value_type > |
| Element type preserving the source array constness. | |
Functions | |
| ResolvedSlice | stratax::indexing::detail::normalize_slice (const stratax::core::Slice &slice, size_type extent) |
| Normalizes explicit bounds against an extent without accessing storage. | |
| template<typename Vector > | |
| auto | stratax::indexing::detail::make_vector_slice_view (Vector &vec, const stratax::core::Slice &slice) |
| Constructs a one-axis view; see the public Vector slice overload. | |
| template<typename Matrix > | |
| auto | stratax::indexing::detail::make_matrix_slice_view (Matrix &mat, const stratax::core::Slice &rows, const stratax::core::Slice &cols) |
| Constructs a two-axis view; see the public Matrix slice overload. | |
| template<typename T > | |
| auto | stratax::indexing::slice (stratax::container::Vector< T > &vec, const stratax::core::Slice &slice) |
| Returns a non-owning Vector slice view (mutable when T is non-const). | |
| template<typename T > | |
| auto | stratax::indexing::slice (const stratax::container::Vector< T > &vec, const stratax::core::Slice &slice) |
| Returns a non-owning Vector slice view (read-only). | |
| template<typename T > | |
| auto | stratax::indexing::slice (stratax::container::Matrix< T > &mat, const stratax::core::Slice &rows, const stratax::core::Slice &cols) |
| Returns a non-owning Matrix slice view (mutable when T is non-const). | |
| template<typename T > | |
| auto | stratax::indexing::slice (const stratax::container::Matrix< T > &mat, const stratax::core::Slice &rows, const stratax::core::Slice &cols) |
| Returns a non-owning Matrix slice view (read-only). | |
| template<typename Tensor , typename... Slices> requires ( std::same_as< std::remove_cvref_t<Slices>, stratax::core::Slice > && ... ) | |
| auto | stratax::indexing::detail::make_tensor_slice_view (Tensor &tensor, Slices... slices) |
| Constructs a view with one slice per axis; see the public Tensor slice overloads. | |
| template<typename Tensor > | |
| auto | stratax::indexing::detail::make_tensor_slice_view (Tensor &tensor, const std::vector< stratax::core::Slice > &slices) |
| Constructs a view with one slice per axis; see the public Tensor slice overloads. | |
| template<typename T , typename... Slices> requires ( std::same_as< std::remove_cvref_t<Slices>, stratax::core::Slice > && ... ) | |
| auto | stratax::indexing::slice (stratax::container::Tensor< T > &tensor, Slices... slices) |
| Returns a non-owning Tensor slice view (mutable when T is non-const). | |
| template<typename T , typename... Slices> requires ( std::same_as< std::remove_cvref_t<Slices>, stratax::core::Slice > && ... ) | |
| auto | stratax::indexing::slice (const stratax::container::Tensor< T > &tensor, Slices... slices) |
| Returns a non-owning Tensor slice view (read-only). | |
| template<typename T > | |
| auto | stratax::indexing::slice (stratax::container::Tensor< T > &tensor, const std::vector< stratax::core::Slice > &slices) |
| Returns a non-owning Tensor slice view (mutable when T is non-const). | |
| template<typename T > | |
| auto | stratax::indexing::slice (const stratax::container::Tensor< T > &tensor, const std::vector< stratax::core::Slice > &slices) |
| Returns a non-owning Tensor slice view (read-only). | |
| template<typename T > | |
| stratax::core::ArrayView< T > | stratax::indexing::slice (stratax::core::ArrayView< T > &view, const std::vector< stratax::core::Slice > &slices) |
| Returns a non-owning ArrayView slice view (mutable when T is non-const). | |
Positive-step non-owning slice views with clamped bounds.
Definition in file Slicing.hpp.
| using stratax::indexing::detail::view_element_t = typedef std::conditional_t< std::is_const_v<std::remove_reference_t<Source> >, const typename std::remove_cvref_t<Source>::value_type, typename std::remove_cvref_t<Source>::value_type> |
Element type preserving the source array constness.
Definition at line 50 of file Slicing.hpp.
| auto stratax::indexing::detail::make_matrix_slice_view | ( | Matrix & | mat, |
| const stratax::core::Slice & | rows, | ||
| const stratax::core::Slice & | cols | ||
| ) |
Constructs a two-axis view; see the public Matrix slice overload.
Definition at line 162 of file Slicing.hpp.
| auto stratax::indexing::detail::make_tensor_slice_view | ( | Tensor & | tensor, |
| const std::vector< stratax::core::Slice > & | slices | ||
| ) |
Constructs a view with one slice per axis; see the public Tensor slice overloads.
Definition at line 403 of file Slicing.hpp.
| auto stratax::indexing::detail::make_tensor_slice_view | ( | Tensor & | tensor, |
| Slices... | slices | ||
| ) |
Constructs a view with one slice per axis; see the public Tensor slice overloads.
Definition at line 313 of file Slicing.hpp.
| auto stratax::indexing::detail::make_vector_slice_view | ( | Vector & | vec, |
| const stratax::core::Slice & | slice | ||
| ) |
Constructs a one-axis view; see the public Vector slice overload.
Definition at line 128 of file Slicing.hpp.
|
inline |
Normalizes explicit bounds against an extent without accessing storage.
| slice | Raw range; a negative-step stop of -1 is the reverse sentinel. |
| extent | Axis length, representable by difference_type. |
| Exceptions::IndexError | If the extent exceeds PTRDIFF_MAX. |
Definition at line 64 of file Slicing.hpp.
| auto stratax::indexing::slice | ( | const stratax::container::Matrix< T > & | mat, |
| const stratax::core::Slice & | rows, | ||
| const stratax::core::Slice & | cols | ||
| ) |
Returns a non-owning Matrix slice view (read-only).
| mat | Source Matrix whose storage is aliased. |
| rows | Positive-step row range. |
| cols | Positive-step column range. |
| Exceptions::IndexError | If a step is negative or an extent exceeds PTRDIFF_MAX. |
| Exceptions::DimensionError | If stride/offset arithmetic or metadata validation overflows. |
| std::bad_alloc | If metadata allocation fails. |
Definition at line 295 of file Slicing.hpp.
| auto stratax::indexing::slice | ( | const stratax::container::Tensor< T > & | tensor, |
| const std::vector< stratax::core::Slice > & | slices | ||
| ) |
Returns a non-owning Tensor slice view (read-only).
| tensor | Source Tensor whose storage is aliased. |
| slices | One explicit positive-step range per axis. |
| Exceptions::IndexError | If a step is negative or an extent exceeds PTRDIFF_MAX. |
| Exceptions::RankError | If the number of slices differs from the source rank. |
| Exceptions::DimensionError | If stride/offset arithmetic or metadata validation overflows. |
| std::bad_alloc | If metadata allocation fails. |
Definition at line 579 of file Slicing.hpp.
| auto stratax::indexing::slice | ( | const stratax::container::Tensor< T > & | tensor, |
| Slices... | slices | ||
| ) |
Returns a non-owning Tensor slice view (read-only).
| tensor | Source Tensor whose storage is aliased. |
| slices | One explicit positive-step range per axis. |
| Exceptions::IndexError | If a step is negative or an extent exceeds PTRDIFF_MAX. |
| Exceptions::RankError | If the number of slices differs from the source rank. |
| Exceptions::DimensionError | If stride/offset arithmetic or metadata validation overflows. |
| std::bad_alloc | If metadata allocation fails. |
Definition at line 535 of file Slicing.hpp.
| auto stratax::indexing::slice | ( | const stratax::container::Vector< T > & | vec, |
| const stratax::core::Slice & | slice | ||
| ) |
Returns a non-owning Vector slice view (read-only).
| vec | Source Vector whose storage is aliased. |
| slice | Explicit positive-step range, normalized and clamped to the vector size. |
| Exceptions::IndexError | If a step is negative or an extent exceeds PTRDIFF_MAX. |
| Exceptions::DimensionError | If stride/offset arithmetic or metadata validation overflows. |
| std::bad_alloc | If metadata allocation fails. |
Definition at line 248 of file Slicing.hpp.
| auto stratax::indexing::slice | ( | stratax::container::Matrix< T > & | mat, |
| const stratax::core::Slice & | rows, | ||
| const stratax::core::Slice & | cols | ||
| ) |
Returns a non-owning Matrix slice view (mutable when T is non-const).
| mat | Source Matrix whose storage is aliased. |
| rows | Positive-step row range. |
| cols | Positive-step column range. |
| Exceptions::IndexError | If a step is negative or an extent exceeds PTRDIFF_MAX. |
| Exceptions::DimensionError | If stride/offset arithmetic or metadata validation overflows. |
| std::bad_alloc | If metadata allocation fails. |
Definition at line 271 of file Slicing.hpp.
| auto stratax::indexing::slice | ( | stratax::container::Tensor< T > & | tensor, |
| const std::vector< stratax::core::Slice > & | slices | ||
| ) |
Returns a non-owning Tensor slice view (mutable when T is non-const).
| tensor | Source Tensor whose storage is aliased. |
| slices | One explicit positive-step range per axis. |
| Exceptions::IndexError | If a step is negative or an extent exceeds PTRDIFF_MAX. |
| Exceptions::RankError | If the number of slices differs from the source rank. |
| Exceptions::DimensionError | If stride/offset arithmetic or metadata validation overflows. |
| std::bad_alloc | If metadata allocation fails. |
Definition at line 556 of file Slicing.hpp.
| auto stratax::indexing::slice | ( | stratax::container::Tensor< T > & | tensor, |
| Slices... | slices | ||
| ) |
Returns a non-owning Tensor slice view (mutable when T is non-const).
| tensor | Source Tensor whose storage is aliased. |
| slices | One explicit positive-step range per axis. |
| Exceptions::IndexError | If a step is negative or an extent exceeds PTRDIFF_MAX. |
| Exceptions::RankError | If the number of slices differs from the source rank. |
| Exceptions::DimensionError | If stride/offset arithmetic or metadata validation overflows. |
| std::bad_alloc | If metadata allocation fails. |
Definition at line 508 of file Slicing.hpp.
| auto stratax::indexing::slice | ( | stratax::container::Vector< T > & | vec, |
| const stratax::core::Slice & | slice | ||
| ) |
Returns a non-owning Vector slice view (mutable when T is non-const).
| vec | Source Vector whose storage is aliased. |
| slice | Explicit positive-step range, normalized and clamped to the vector size. |
| Exceptions::IndexError | If a step is negative or an extent exceeds PTRDIFF_MAX. |
| Exceptions::DimensionError | If stride/offset arithmetic or metadata validation overflows. |
| std::bad_alloc | If metadata allocation fails. |
Definition at line 226 of file Slicing.hpp.
| stratax::core::ArrayView< T > stratax::indexing::slice | ( | stratax::core::ArrayView< T > & | view, |
| const std::vector< stratax::core::Slice > & | slices | ||
| ) |
Returns a non-owning ArrayView slice view (mutable when T is non-const).
| view | Source ArrayView whose storage is aliased. |
| slices | One explicit positive-step range per axis. |
| Exceptions::IndexError | If a step is negative or an extent exceeds PTRDIFF_MAX. |
| Exceptions::RankError | If the number of slices differs from the source rank. |
| Exceptions::DimensionError | If stride/offset arithmetic or metadata validation overflows. |
| std::bad_alloc | If metadata allocation fails. |
Definition at line 603 of file Slicing.hpp.