mptensor  v0.3.0
Parallel Library for Tensor Network Methods
template<template< typename > class Matrix, typename C >
Tensor< Matrix, C > mptensor::transpose (Tensor< Matrix, C > T, const Axes &axes)
 Transposition of tensor with lazy evaluation. More...
 
template<template< typename > class Matrix, typename C >
Tensor< Matrix, C > mptensor::transpose (const Tensor< Matrix, C > &T, const Axes &axes, size_t urank_new)
 Transposition of tensor without lazy evaluation. More...
 
template<template< typename > class Matrix, typename C >
Tensor< Matrix, C > mptensor::reshape (const Tensor< Matrix, C > &T, const Shape &shape_new)
 Change the shape of tensor. More...
 
template<template< typename > class Matrix, typename C >
Tensor< Matrix, C > mptensor::slice (const Tensor< Matrix, C > &T, size_t n_axes, size_t i_begin, size_t i_end)
 Slice a tensor. More...
 
template<template< typename > class Matrix, typename C >
Tensor< Matrix, C > mptensor::slice (const Tensor< Matrix, C > &T, const Index &index_begin, const Index &index_end)
 Slice a tensor. More...
 
template<template< typename > class Matrix, typename C >
Tensor< Matrix, C > mptensor::extend (const Tensor< Matrix, C > &T, const Shape &shape_new)
 Extend the size of a tensor. More...
 

Detailed Description

Operations in order to change the shape of a tensor

Function Documentation

◆ extend()

template<template< typename > class Matrix, typename C >
Tensor< Matrix, C > mptensor::extend ( const Tensor< Matrix, C > &  T,
const Shape shape_new 
)

Extend the size of a tensor.

Parameters
[in]TTensor to be extended.
[in]shape_newNew shape.
Returns
Extended tensor.
Note
New shape should be larger than the original shape.

◆ reshape()

template<template< typename > class Matrix, typename C >
Tensor< Matrix, C > mptensor::reshape ( const Tensor< Matrix, C > &  T,
const Shape shape_new 
)

Change the shape of tensor.

Parameters
[in]TTensor to be reshaped.
[in]shape_newNew shape.
Returns
Reshaped tensor.
Note
The new shape should be compatible with the original shape. The total size of tensor does not change.
Warning
mptensor uses the column major, unlike NumPy.

◆ slice() [1/2]

template<template< typename > class Matrix, typename C >
Tensor< Matrix, C > mptensor::slice ( const Tensor< Matrix, C > &  T,
const Index index_begin,
const Index index_end 
)

Slice a tensor.

This function mimics slicing in python such as [start:end]. If index_begin[r]==index_end[r], this rank is not sliced. For example,

slice(T, Index(1,0,3), Index(4,0,6));
Tensor< Matrix, C > slice(const Tensor< Matrix, C > &a, size_t n_axes, size_t i_begin, size_t i_end)
Slice a tensor.
Definition: tensor_impl.hpp:1215
Index(size_t j0)
Definition: index_constructor.hpp:11

will return T[1:4, :, 3:6].

Parameters
[in]TTensor to be sliced.
[in]index_beginStart of indices.
[in]index_endEnd of indices.
Returns
Sliced tensor.

◆ slice() [2/2]

template<template< typename > class Matrix, typename C >
Tensor< Matrix, C > mptensor::slice ( const Tensor< Matrix, C > &  T,
size_t  n_axes,
size_t  i_begin,
size_t  i_end 
)

Slice a tensor.

This function mimics slicing in python such as [start:end].

Parameters
[in]TTensor to be sliced.
[in]n_axesAxes to be sliced.
[in]i_beginStart of index.
[in]i_endEnd of index.
Returns
Sliced tensor.

◆ transpose() [1/2]

template<template< typename > class Matrix, typename C >
Tensor< Matrix, C > mptensor::transpose ( const Tensor< Matrix, C > &  T,
const Axes axes,
size_t  urank_new 
)

Transposition of tensor without lazy evaluation.

When axes=[1,2,0], \( T_{ijk} \) is transformed into \( T_{jki} \).

Parameters
[in]TTensor to be transposed.
[in]axesOrder of axes.
[in]urank_newUpper rank of new tensor.
Returns
Transposed tensor
Note
This function may cause communications.

◆ transpose() [2/2]

template<template< typename > class Matrix, typename C >
Tensor< Matrix, C > mptensor::transpose ( Tensor< Matrix, C >  T,
const Axes axes 
)
inline

Transposition of tensor with lazy evaluation.

When axes=[1,2,0], \( T_{ijk} \) is transformed into \( T_{jki} \).

Parameters
[in]TTensor to be transposed.
[in]axesOrder of axes
Returns
Transposed tensor