mptensor v0.6.0
Parallel Library for Tensor Network Methods
Loading...
Searching...
No Matches
Internal API

Library-internal helpers; not part of the public API. More...

Namespaces

namespace  mptensor::internal
 Library-internal helpers and types.
 

Classes

struct  mptensor::internal::is_unscoped_enum< I, bool >
 
struct  mptensor::internal::normalized_t
 

Typedefs

using mptensor::internal::UIndex = BasicIndex< std::size_t >
 
using mptensor::internal::UAxes = UIndex
 
using mptensor::internal::UShape = UIndex
 

Functions

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)
 

Variables

template<typename I >
constexpr bool mptensor::internal::is_index_value_v
 
constexpr normalized_t mptensor::internal::normalized {}
 

Detailed Description

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.

Typedef Documentation

◆ UAxes

◆ UIndex

Internal element index.

◆ UShape

Function Documentation

◆ checked_index_cast()

template<typename T , typename I >
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()

UAxes mptensor::internal::identity_axes ( size_t  n)
inline

[0, 1, ..., n-1]

◆ 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_rangeif a bound is out of range or the slice is empty.

◆ normalize_slice_ranges()

void mptensor::internal::normalize_slice_ranges ( const Index &  begin,
const Index &  end,
const UShape &  shape,
UIndex &  ubegin,
UIndex &  uend 
)
inline

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
vValue to normalize; negative values count from n.
nSize of the range (rank or dimension).
end_inclusiveAccept n itself (for an exclusive slice end).
kindName of the value shown in the error message, e.g. "axis".
positionElement number (or axis) shown in the error message; negative for a scalar argument.
position_nameWord shown before position, e.g. "position" or "axis".
Exceptions
std::out_of_rangeif v is out of range.

◆ reshape_impl()

template<typename MatrixType >
Tensor< MatrixType > mptensor::internal::reshape_impl ( const Tensor< MatrixType > &  a,
const UShape &  shape_new 
)

Body of reshape(): shape_new is already normalized.

◆ transpose_impl()

template<typename MatrixType >
Tensor< MatrixType > mptensor::internal::transpose_impl ( const Tensor< MatrixType > &  a,
const UAxes &  axes,
size_t  urank_new 
)

Body of transpose(): axes are already normalized.

Variable Documentation

◆ is_index_value_v

template<typename I >
constexpr bool mptensor::internal::is_index_value_v
inlineconstexpr
Initial value:
=
std::is_integral_v<I> || is_unscoped_enum<I>::value

True for integer types and unscoped enumerations (accepted as index values).

◆ normalized

constexpr normalized_t mptensor::internal::normalized {}
inlineconstexpr

Value of normalized_t.