|
Stratax
Scientific computing containers and operations
|
#include <stratax/containers/Matrix.hpp>#include <stratax/containers/Tensor.hpp>#include <stratax/containers/Vector.hpp>#include <stratax/core/Exceptions.hpp>#include <stratax/core/Shape.hpp>#include <stratax/core/Slice.hpp>#include <stratax/core/Strides.hpp>#include <stratax/core/Validation.hpp>#include <array>#include <cstddef>#include <type_traits>#include <utility>Go to the source code of this file.
Namespaces | |
| namespace | stratax |
| namespace | stratax::ops |
| namespace | stratax::ops::detail |
Functions | |
| template<std::size_t N, std::size_t... Is> | |
| stratax::core::Shape | stratax::ops::detail::shape_from_slices_impl (const std::array< stratax::core::Slice, N > &ranges, std::index_sequence< Is... >) |
| Builds a shape from a compile-time slice array. | |
| template<std::size_t N> | |
| stratax::core::Shape | stratax::ops::detail::shape_from_slices (const std::array< stratax::core::Slice, N > &ranges) |
| Builds a shape from a slice array. | |
| template<typename T> | |
| stratax::container::Vector< T > | slice (const stratax::container::Vector< T > &vec, const stratax::core::Slice &slice) |
| Copies a half-open range from a vector. | |
| template<typename T> | |
| stratax::container::Matrix< T > | slice (const stratax::container::Matrix< T > &mat, const stratax::core::Slice &rows, const stratax::core::Slice &cols) |
| Copies a rectangular half-open region from a matrix. | |
| template<typename T, typename... Slices> | |
| stratax::container::Tensor< T > | slice (const stratax::container::Tensor< T > &tensor, Slices... slices) |
| Copies a multidimensional half-open region from a tensor. | |
| stratax::container::Matrix< T > slice | ( | const stratax::container::Matrix< T > & | mat, |
| const stratax::core::Slice & | rows, | ||
| const stratax::core::Slice & | cols ) |
Copies a rectangular half-open region from a matrix.
Rows in [rows.start(), rows.stop()) and columns in [cols.start(), cols.stop()) are copied into a new row-major matrix.
| mat | Source matrix. |
| rows | Row slice. |
| cols | Column slice. |
| Exceptions::IndexError | If either slice exceeds the matrix bounds. |
Definition at line 106 of file Slice.hpp.
References stratax::container::Matrix< T >::cols(), stratax::core::validation::require_at_most(), stratax::container::Matrix< T >::rows(), stratax::core::Slice::size(), stratax::core::Slice::start(), and stratax::core::Slice::stop().
| stratax::container::Tensor< T > slice | ( | const stratax::container::Tensor< T > & | tensor, |
| Slices... | slices ) |
Copies a multidimensional half-open region from a tensor.
One Slice must be provided for each tensor dimension. The result shape is formed from the size of each slice, and values are copied in row-major order.
| tensor | Source tensor. |
| slices | One slice per tensor dimension. |
| Exceptions::DimensionError | If the number of slices does not match the tensor rank. |
| Exceptions::IndexError | If any slice exceeds the corresponding dimension. |
Definition at line 155 of file Slice.hpp.
References stratax::core::validation::checked_add(), stratax::core::validation::checked_multiply(), stratax::container::Tensor< T >::empty(), stratax::container::Tensor< T >::rank(), stratax::core::validation::require_at_most(), stratax::core::validation::require_rank(), stratax::container::Tensor< T >::shape(), stratax::ops::detail::shape_from_slices(), stratax::container::Tensor< T >::size(), and stratax::container::Tensor< T >::strides().
| stratax::container::Vector< T > slice | ( | const stratax::container::Vector< T > & | vec, |
| const stratax::core::Slice & | slice ) |
Copies a half-open range from a vector.
The returned vector contains elements in [slice.start(), slice.stop()) using the source vector's flat storage order.
| vec | Source vector. |
| slice | Half-open element range. |
| Exceptions::IndexError | If the slice stop is greater than vec.size(). |
Definition at line 67 of file Slice.hpp.
References stratax::core::validation::require_at_most(), stratax::container::Vector< T >::size(), and slice().
Referenced by slice().