mptensor v0.6.0
Parallel Library for Tensor Network Methods
Loading...
Searching...
No Matches
mptensor::BasicIndex< T > Class Template Reference

#include <index.hpp>

Public Types

using value_type = T
 
using index_t = std::vector< T >
 

Public Member Functions

 BasicIndex ()=default
 
 BasicIndex (const index_t &index)
 
template<typename U , typename = std::enable_if_t<internal::is_index_value_v<U> && !std::is_same_v<U, T>>>
 BasicIndex (const std::vector< U > &index)
 Converting constructor from a vector of another integer type.
 
 BasicIndex (std::initializer_list< T > list)
 
template<typename... Ints, typename = std::enable_if_t<(sizeof...(Ints) > 0) && (internal::is_index_value_v<Ints> && ...)>>
 BasicIndex (Ints... js)
 Python-like list literal, e.g. Index(0, 1, -1).
 
const T & operator[] (size_t i) const
 
T & operator[] (size_t i)
 
size_t size () const
 
void push (T i)
 
void resize (size_t n)
 
void assign (size_t n, const T j[])
 
void sort ()
 
BasicIndex inverse_permutation () const
 Inverse of a permutation: inv[(*this)[i]] = i.
 
BasicIndex inverse () const
 Same as inverse_permutation().
 
bool operator== (const BasicIndex &rhs) const
 
BasicIndex & operator+= (const BasicIndex &rhs)
 

Detailed Description

template<typename T>
class mptensor::BasicIndex< T >

List of non-negative or signed integers used as an index, axes, or shape.

Index (= Axes = Shape) is the public type. internal::UIndex (= internal::UAxes = internal::UShape) is used inside the library.

Member Typedef Documentation

◆ index_t

template<typename T >
using mptensor::BasicIndex< T >::index_t = std::vector<T>

◆ value_type

template<typename T >
using mptensor::BasicIndex< T >::value_type = T

Constructor & Destructor Documentation

◆ BasicIndex() [1/5]

template<typename T >
mptensor::BasicIndex< T >::BasicIndex ( )
default

◆ BasicIndex() [2/5]

template<typename T >
mptensor::BasicIndex< T >::BasicIndex ( const index_t &  index)
inline

◆ BasicIndex() [3/5]

template<typename T >
template<typename U , typename = std::enable_if_t<internal::is_index_value_v<U> && !std::is_same_v<U, T>>>
mptensor::BasicIndex< T >::BasicIndex ( const std::vector< U > &  index)
inline

Converting constructor from a vector of another integer type.

◆ BasicIndex() [4/5]

template<typename T >
mptensor::BasicIndex< T >::BasicIndex ( std::initializer_list< T >  list)
inline

◆ BasicIndex() [5/5]

template<typename T >
template<typename... Ints, typename = std::enable_if_t<(sizeof...(Ints) > 0) && (internal::is_index_value_v<Ints> && ...)>>
mptensor::BasicIndex< T >::BasicIndex ( Ints...  js)
inline

Python-like list literal, e.g. Index(0, 1, -1).

Not explicit: Axes a = 2; creates [2].

Member Function Documentation

◆ assign()

template<typename T >
void mptensor::BasicIndex< T >::assign ( size_t  n,
const T  j[] 
)
inline

◆ inverse()

template<typename T >
BasicIndex mptensor::BasicIndex< T >::inverse ( ) const
inline

◆ inverse_permutation()

template<typename T >
BasicIndex mptensor::BasicIndex< T >::inverse_permutation ( ) const
inline

Inverse of a permutation: inv[(*this)[i]] = i.

For example, the inverse permutation of (2, 0, 1) is (1, 2, 0).

Exceptions
std::out_of_rangeif an element is outside [0, size()).
std::invalid_argumentif an element appears twice.

◆ operator+=()

template<typename T >
BasicIndex & mptensor::BasicIndex< T >::operator+= ( const BasicIndex< T > &  rhs)
inline

◆ operator==()

template<typename T >
bool mptensor::BasicIndex< T >::operator== ( const BasicIndex< T > &  rhs) const
inline

◆ operator[]() [1/2]

template<typename T >
T & mptensor::BasicIndex< T >::operator[] ( size_t  i)
inline

◆ operator[]() [2/2]

template<typename T >
const T & mptensor::BasicIndex< T >::operator[] ( size_t  i) const
inline

◆ push()

template<typename T >
void mptensor::BasicIndex< T >::push ( T  i)
inline

◆ resize()

template<typename T >
void mptensor::BasicIndex< T >::resize ( size_t  n)
inline

◆ size()

template<typename T >
size_t mptensor::BasicIndex< T >::size ( ) const
inline

◆ sort()

template<typename T >
void mptensor::BasicIndex< T >::sort ( )
inline

The documentation for this class was generated from the following file: