|
mptensor v0.6.0
Parallel Library for Tensor Network Methods
|
Lists of integers that specify element indices, axes, and shapes. More...
Classes | |
| class | mptensor::BasicIndex< T > |
Typedefs | |
| using | mptensor::Index = BasicIndex< std::ptrdiff_t > |
| using | mptensor::Axes = Index |
| using | mptensor::Shape = Index |
Lists of integers that specify element indices, axes, and shapes.
Index, Axes, and Shape are aliases of the same class, BasicIndex<std::ptrdiff_t>. Create one like a python list: Index(0, 1, 2), Axes{2, 0, 1}, or Axes a = 2;.
Negative values count from the end, as in numpy:
-1 is the last axis, e.g. transpose(A, Axes(-1, 0, 1));-1 is the last element, e.g. A.get_value(Index(-1, 0), v);slice(A, 0, 1, -1) is A[1:-1].Out-of-range values throw std::out_of_range, and negative sizes in a Shape throw std::invalid_argument, before any communication starts.
range(start, stop, step) creates a sequence as in python, e.g. range(-1, -5, -1) reverses the axes of a rank-4 tensor.
Public axes.
| using mptensor::Index = typedef BasicIndex<std::ptrdiff_t> |
Public element index.
Public shape.
|
inline |
Normalize each axis: [-rank, rank) -> [0, rank).
Normalize an axis: [-rank, rank) -> [0, rank).
|
inline |
Normalize a global element index against shape.
Normalize an element index: [-n, n) -> [0, n).
Normalize an exclusive slice end: [-n, n] -> [0, n].
| BasicIndex< T > mptensor::operator+ | ( | const BasicIndex< T > & | lhs, |
| const BasicIndex< T > & | rhs | ||
| ) |
Joint two indices: Index(0,1) + Index(2,3) = Index(0,1,2,3)
| std::ostream & mptensor::operator<< | ( | std::ostream & | os, |
| const BasicIndex< T > & | idx | ||
| ) |
The format is the same as a list of python, for example "[0, 1, 2]".
Same as range(start, stop, 1).
|
inline |
Arithmetic sequence start, start+step, ... up to (not including) stop.
Same as range() in python: the result is empty if stop is not reached in the direction of step, e.g. range(3, 2) or range(0, 5, -1). Negative values are allowed, e.g. range(-1, -5, -1) is [-1, -2, -3, -4], which reverses the axes of a rank-4 tensor.
!
| std::invalid_argument | if step == 0. |
|
inline |
Convert a public shape to the internal type. Negative sizes are invalid.
|
inline |
Convert an internal index to the public type.