|
| | 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.
|
| |
Operations for linear algebra.
◆ contract()
Partial trace of tensor.
axes_1[k] and axes_2[k] are contracted. For example.
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
-
| T | Tensor to partially trace. |
| axes_1 | Axes to trace. |
| axes_2 | Axes to trace. |
- Returns
- Contracted tensor.
◆ kron()
Compute the Kronecker product.
- Parameters
-
- 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
Tensor< MatrixType > kron(const Tensor< MatrixType > &a, const Tensor< MatrixType > &b)
Compute the Kronecker product.
Definition tensor_impl.hpp:1626
where
- 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()
Compute tensor dot product.
For example, \( T_{abcd} = \sum_{ij} A_{iajb} B_{cjdi} \) is
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
-
| a | Tensor. |
| b | Tensor. |
| axes_a | Axes of tensor a to contract. |
| axes_b | Axes of tensor b to contract. |
- Returns
- Result.
◆ trace() [1/3]
Full contraction of two tensors.
axes_a[k] and axes_b[k] are contracted. For example,
returns \( \sum_{ijk} A_{ijk} B_{kij} \).
- Parameters
-
| A | Tensor to contract. |
| B | Tensor to contract. |
| axes_a | Axes order of tensor A. |
| axes_b | Axes order of tensor B. |
- Returns
- Value of full contraction.
- Note
- This function is more effective than tensordot and MPI_Bcast.
◆ trace() [2/3]
Trace of matrix (rank-2 tensor)
- Parameters
-
- Returns
- Value of trace. \( \sum_i M_{ii} \)
◆ trace() [3/3]
Full trace of tensor.
axes_1[k] and axes_2[k] are contracted. For example,
returns \( \sum_{ijk} T_{ijikjk}\).
- Parameters
-
| T | Tensor to trace. |
| axes_1 | Axes of tensor. |
| axes_2 | Axes of tensor. |
- Returns
- Value of tensor.