mptensor v0.5.1
Parallel Library for Tensor Network Methods
Loading...
Searching...
No Matches
Collaboration diagram for Linear algebra:

Modules

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

Detailed Description

Operations for linear algebra.

Function Documentation

◆ contract()

template<typename MatrixType >
Tensor< MatrixType > mptensor::contract ( const Tensor< MatrixType > &  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))
std::complex< double > complex
Definition complex.hpp:38
MatrixType::value_type trace(const Tensor< MatrixType > &a)
Trace of matrix (rank-2 tensor)
Definition tensor_impl.hpp:1423
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<typename MatrixType >
Tensor< MatrixType > mptensor::kron ( const Tensor< MatrixType > &  a,
const Tensor< MatrixType > &  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< MatrixType > kron(const Tensor< MatrixType > &a, const Tensor< MatrixType > &b)
Compute the Kronecker product.
Definition tensor_impl.hpp:1626

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< MatrixType > reshape(const Tensor< MatrixType > &a, const Shape &shape_new)
Change the shape of tensor.
Definition tensor_impl.hpp:1163

◆ tensordot()

template<typename MatrixType >
Tensor< MatrixType > mptensor::tensordot ( const Tensor< MatrixType > &  a,
const Tensor< MatrixType > &  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< MatrixType > tensordot(const Tensor< MatrixType > &a, const Tensor< MatrixType > &b, const Axes &axes_a, const Axes &axes_b)
Compute tensor dot product.
Definition tensor_impl.hpp:1662
Parameters
aTensor.
bTensor.
axes_aAxes of tensor a to contract.
axes_bAxes of tensor b to contract.
Returns
Result.

◆ trace() [1/3]

template<typename MatrixType >
MatrixType::value_type mptensor::trace ( const Tensor< MatrixType > &  A,
const Tensor< MatrixType > &  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<typename MatrixType >
MatrixType::value_type mptensor::trace ( const Tensor< MatrixType > &  M)

Trace of matrix (rank-2 tensor)

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

◆ trace() [3/3]

template<typename MatrixType >
MatrixType::value_type mptensor::trace ( const Tensor< MatrixType > &  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.