Library-internal helpers; not part of the public API.
More...
|
| template<typename T , typename I > |
| T | mptensor::internal::checked_index_cast (I value) |
| |
| size_t | mptensor::internal::normalize_value (std::ptrdiff_t v, size_t n, bool end_inclusive, const char *kind, std::ptrdiff_t position, const char *position_name="position") |
| |
| UAxes | mptensor::internal::identity_axes (size_t n) |
| |
| std::pair< size_t, size_t > | mptensor::internal::normalize_slice_range (std::ptrdiff_t begin, std::ptrdiff_t end, size_t n, size_t axis) |
| |
| void | mptensor::internal::normalize_slice_ranges (const Index &begin, const Index &end, const UShape &shape, UIndex &ubegin, UIndex &uend) |
| |
| template<typename MatrixType > |
| Tensor< MatrixType > | mptensor::internal::transpose_impl (const Tensor< MatrixType > &a, const UAxes &axes, size_t urank_new) |
| |
| template<typename MatrixType > |
| Tensor< MatrixType > | mptensor::internal::reshape_impl (const Tensor< MatrixType > &a, const UShape &shape_new) |
| |
Library-internal helpers; not part of the public API.
- Warning
- Not part of the public API. These names may change or be removed without notice, and user code should not use them.
Helpers used inside the library. Public functions convert their arguments to the internal types (internal::UIndex, internal::UAxes, internal::UShape, all holding size_t) once at the entry point; everything after that works on size_t.
◆ UAxes
◆ UIndex
◆ UShape
◆ checked_index_cast()
| T mptensor::internal::checked_index_cast |
( |
I |
value | ) |
|
Convert an integer to T, or throw std::out_of_range if it does not fit.
◆ identity_axes()
◆ normalize_slice_range()
| std::pair< size_t, size_t > mptensor::internal::normalize_slice_range |
( |
std::ptrdiff_t |
begin, |
|
|
std::ptrdiff_t |
end, |
|
|
size_t |
n, |
|
|
size_t |
axis |
|
) |
| |
|
inline |
Normalize a scalar slice [begin, end) on an axis of size n.
- Exceptions
-
| std::out_of_range | if a bound is out of range or the slice is empty. |
◆ normalize_slice_ranges()
Normalize Index-style slice bounds; raw begin[r] == end[r] means the full axis.
◆ normalize_value()
| size_t mptensor::internal::normalize_value |
( |
std::ptrdiff_t |
v, |
|
|
size_t |
n, |
|
|
bool |
end_inclusive, |
|
|
const char * |
kind, |
|
|
std::ptrdiff_t |
position, |
|
|
const char * |
position_name = "position" |
|
) |
| |
|
inline |
Normalize one value into [0, n) (or [0, n] if end_inclusive).
- Parameters
-
| v | Value to normalize; negative values count from n. |
| n | Size of the range (rank or dimension). |
| end_inclusive | Accept n itself (for an exclusive slice end). |
| kind | Name of the value shown in the error message, e.g. "axis". |
| position | Element number (or axis) shown in the error message; negative for a scalar argument. |
| position_name | Word shown before position, e.g. "position" or "axis". |
- Exceptions
-
| std::out_of_range | if v is out of range. |
◆ reshape_impl()
Body of reshape(): shape_new is already normalized.
◆ transpose_impl()
◆ is_index_value_v
Initial value:=
std::is_integral_v<I> || is_unscoped_enum<I>::value
True for integer types and unscoped enumerations (accepted as index values).
◆ normalized