mptensor  v0.3.0
Parallel Library for Tensor Network Methods

Modules

 Decompositions
 
 Linear equation
 
template<template< typename > class Matrix, typename C >
mptensor::trace (const Tensor< Matrix, C > &M)
 Trace of matrix (rank-2 tensor) More...
 
template<template< typename > class Matrix, typename C >
mptensor::trace (const Tensor< Matrix, C > &T, const Axes &axes_1, const Axes &axes_2)
 Full trace of tensor. More...
 
template<template< typename > class Matrix, typename C >
mptensor::trace (const Tensor< Matrix, C > &A, const Tensor< Matrix, C > &B, const Axes &axes_a, const Axes &axes_b)
 Full contraction of two tensors. More...
 
template<template< typename > class Matrix, typename C >
Tensor< Matrix, C > mptensor::contract (const Tensor< Matrix, C > &T, const Axes &axes_1, const Axes &axes_2)
 Partial trace of tensor. More...
 
template<template< typename > class Matrix, typename C >
Tensor< Matrix, C > mptensor::tensordot (const Tensor< Matrix, C > &a, const Tensor< Matrix, C > &b, const Axes &axes_a, const Axes &axes_b)
 Compute tensor dot product. More...
 
template<template< typename > class Matrix, typename C >
Tensor< Matrix, C > mptensor::kron (const Tensor< Matrix, C > &a, const Tensor< Matrix, C > &b)
 Compute the Kronecker product. More...
 

Detailed Description

Operations for linear algebra.

Function Documentation

◆ contract()

template<template< typename > class Matrix, typename C >
Tensor< Matrix, C > mptensor::contract ( const Tensor< Matrix, C > &  T,
const Axes axes_1,
const Axes axes_2 
)

Partial trace of tensor.

axes_1[k] and axes_2[k] are contracted. For example.

B = trace(A, Axes(0,2), Axes(5,4))
C trace(const Tensor< Matrix, C > &a)
Trace of matrix (rank-2 tensor)
Definition: tensor_impl.hpp:1409
Index Axes
Definition: tensor.hpp:45

returns \( B_{ab} = \sum_{ij} A_{iajbji} \).

Parameters
TTensor to partially trace.
axes_1Axes to trace.
axes_2Axes to trace.
Returns
Contracted tensor.

◆ kron()

template<template< typename > class Matrix, typename C >
Tensor< Matrix, C > mptensor::kron ( const Tensor< Matrix, C > &  a,
const Tensor< Matrix, C > &  b 
)

Compute the Kronecker product.

Parameters
aTensor to product.
bTensor to product.
Returns
The Kronecker product of a and b.

If A.shape() = A[r0,...,rN] and B.shape() = B[s0,...,sN], the Kronecker product has shape [r0*s0,..., rN*sN]. Each element is given as

kron(A, B)[k0,...,kN] = A[i0,...,iN] * B[j0,...,jN]
Tensor< Matrix, C > kron(const Tensor< Matrix, C > &a, const Tensor< Matrix, C > &b)
Compute the Kronecker product.
Definition: tensor_impl.hpp:1612

where

kt = it + jt * st
Note
The rank of a and b should be the same.
Warning
To be consistent with the reshape operation, the new indices of the Kronecker product are determined by the column major, unlike in NumPy. Thus, if the shapes of A and B are [r0, r1] and [s0, s1], the Kronecker product of A and B satisfies
reshape(kron(A, B), [r0, s0, r1, s1])[i, j, k, l] = A[i, k] * B[j, l]
Tensor< Matrix, C > reshape(const Tensor< Matrix, C > &a, const Shape &shape_new)
Change the shape of tensor.
Definition: tensor_impl.hpp:1149

◆ tensordot()

template<template< typename > class Matrix, typename C >
Tensor< Matrix, C > mptensor::tensordot ( const Tensor< Matrix, C > &  a,
const Tensor< Matrix, C > &  b,
const Axes axes_a,
const Axes axes_b 
)

Compute tensor dot product.

For example, \( T_{abcd} = \sum_{ij} A_{iajb} B_{cjdi} \) is

T = tensordot(A, B, Axes(0,2), Axes(3,1));
Tensor< Matrix, C > tensordot(const Tensor< Matrix, C > &a, const Tensor< Matrix, C > &b, const Axes &axes_a, const Axes &axes_b)
Compute tensor dot product.
Definition: tensor_impl.hpp:1648
Parameters
aTensor.
bTensor.
axes_aAxes of tensor a to contract.
axes_bAxes of tensor b to contract.
Returns
Result.

◆ trace() [1/3]

template<template< typename > class Matrix, typename C >
C mptensor::trace ( const Tensor< Matrix, C > &  A,
const Tensor< Matrix, C > &  B,
const Axes axes_a,
const Axes axes_b 
)

Full contraction of two tensors.

axes_a[k] and axes_b[k] are contracted. For example,

trace(A, B, Axes(0,1,2), Axes(2,0,1))

returns \( \sum_{ijk} A_{ijk} B_{kij} \).

Parameters
ATensor to contract.
BTensor to contract.
axes_aAxes order of tensor A.
axes_bAxes order of tensor B.
Returns
Value of full contraction.
Note
This function is more effective than tensordot and MPI_Bcast.

◆ trace() [2/3]

template<template< typename > class Matrix, typename C >
C mptensor::trace ( const Tensor< Matrix, C > &  M)

Trace of matrix (rank-2 tensor)

Parameters
MRank-2 tensor
Returns
Value of trace. \( \sum_i M_{ii} \)

◆ trace() [3/3]

template<template< typename > class Matrix, typename C >
C mptensor::trace ( const Tensor< Matrix, C > &  T,
const Axes axes_1,
const Axes axes_2 
)

Full trace of tensor.

axes_1[k] and axes_2[k] are contracted. For example,

trace(T, Axes(0,1,3), Axes(2,4,5))

returns \( \sum_{ijk} T_{ijikjk}\).

Parameters
TTensor to trace.
axes_1Axes of tensor.
axes_2Axes of tensor.
Returns
Value of tensor.