mptensor
v0.3.0
Parallel Library for Tensor Network Methods
|
Test codes for Tensor. More...
Typedefs | |
typedef Tensor< scalapack::Matrix, double > | TensorD |
typedef Tensor< scalapack::Matrix, complex > | TensorC |
Functions | |
void | test_arithmetic (const mpi_comm &comm, int L, std::ostream &ostrm) |
Test for arithmetic operators. More... | |
void | test_arithmetic_complex (const mpi_comm &comm, int L, std::ostream &ostrm) |
Test for arithmetic operators (complex version) More... | |
void | test_contract (const mpi_comm &comm, int L, std::ostream &ostrm) |
Test for TensorD::contract (partial trace) More... | |
void | test_contract_complex (const mpi_comm &comm, int L, std::ostream &ostrm) |
Test for TensorC::contract (partial trace) More... | |
void | test_eigh (const mpi_comm &comm, int L, std::ostream &ostrm) |
Test for TensorD::eigh. More... | |
void | test_eigh_complex (const mpi_comm &comm, int L, std::ostream &ostrm) |
Test for TensorC::eigh. More... | |
void | test_eigh_general (const mpi_comm &comm, int L, std::ostream &ostrm) |
Test for TensorD::eigh (generalized eigenvalue problem) More... | |
void | test_eigh_general_complex (const mpi_comm &comm, int L, std::ostream &ostrm) |
Test for TensorC::eigh. More... | |
void | test_eigh_rank2 (const mpi_comm &comm, int L, std::ostream &ostrm) |
Test for TensorD::eigh. More... | |
void | test_eigh_rank2_complex (const mpi_comm &comm, int L, std::ostream &ostrm) |
Test for TensorC::eigh. More... | |
void | test_kron (const mpi_comm &comm, int L, std::ostream &ostrm) |
Test for TensorD::kron. More... | |
void | test_kron_complex (const mpi_comm &comm, int L, std::ostream &ostrm) |
Test for TensorC::kron. More... | |
void | test_qr (const mpi_comm &comm, int L, std::ostream &ostrm) |
Test for TensorD::qr. More... | |
void | test_qr_complex (const mpi_comm &comm, int L, std::ostream &ostrm) |
Test for TensorC::qr. More... | |
void | test_qr_rank2 (const mpi_comm &comm, int L, std::ostream &ostrm) |
Test for TensorD::qr (Matrix version) More... | |
void | test_qr_rank2_complex (const mpi_comm &comm, int L, std::ostream &ostrm) |
Test for TensorC::qr (Matrix version) More... | |
void | test_reshape (const mpi_comm &comm, int L, std::ostream &ostrm) |
Test for TensorD::reshape. More... | |
void | test_reshape_complex (const mpi_comm &comm, int L, std::ostream &ostrm) |
Test for TensorC::reshape. More... | |
void | test_set_slice (const mpi_comm &comm, int L, std::ostream &ostrm) |
Test for TensorD::set_slice. More... | |
void | test_set_slice_complex (const mpi_comm &comm, int L, std::ostream &ostrm) |
Test for TensorC::slice. More... | |
void | test_slice (const mpi_comm &comm, int L, std::ostream &ostrm) |
Test for TensorD::slice. More... | |
void | test_slice_complex (const mpi_comm &comm, int L, std::ostream &ostrm) |
Test for TensorC::slice. More... | |
void | test_svd (const mpi_comm &comm, int L, std::ostream &ostrm) |
Test for TensorD::svd. More... | |
void | test_svd_complex (const mpi_comm &comm, int L, std::ostream &ostrm) |
Test for TensorC::svd. More... | |
void | test_transpose (const mpi_comm &comm, int L, std::ostream &ostrm) |
Test for TensorD::transpose. More... | |
void | test_tensordot (const mpi_comm &comm, int L, std::ostream &ostrm) |
Test for TensorD::tensordot. More... | |
void | test_trace (const mpi_comm &comm, int L, std::ostream &ostrm) |
Test for full trace of tensor. More... | |
void | test_trace2 (const mpi_comm &comm, int L, std::ostream &ostrm) |
Test for full contraction of two tensors. More... | |
void | test_transpose_complex (const mpi_comm &comm, int L, std::ostream &ostrm) |
Test for TensorC::transpose. More... | |
void | test_tensordot_complex (const mpi_comm &comm, int L, std::ostream &ostrm) |
Test for TensorC::tensordot. More... | |
void | test_trace_complex (const mpi_comm &comm, int L, std::ostream &ostrm) |
Test for full trace of tensor (complex version) More... | |
void | test_trace2_complex (const mpi_comm &comm, int L, std::ostream &ostrm) |
Test for full contraction of two tensors (complex version) More... | |
For tensor elements | |
double | func2_1 (Index idx, Shape shape) |
complex | cfunc2_1 (Index idx, Shape shape) |
double | func4_1 (Index idx, Shape shape) |
double | func4_2 (Index idx, Shape shape) |
complex | cfunc4_1 (Index idx, Shape shape) |
complex | cfunc4_2 (Index idx, Shape shape) |
Test codes for Tensor.
typedef Tensor<scalapack::Matrix, complex> tests::TensorC |
typedef Tensor<scalapack::Matrix, double> tests::TensorD |
void tests::test_arithmetic | ( | const mpi_comm & | comm, |
int | L, | ||
std::ostream & | ostrm | ||
) |
Test for arithmetic operators.
comm | MPI communicator |
L | size of tensor, A.shape = (L, L+1, L+2, L+3) |
ostrm | output stream for results |
void tests::test_arithmetic_complex | ( | const mpi_comm & | comm, |
int | L, | ||
std::ostream & | ostrm | ||
) |
Test for arithmetic operators (complex version)
comm | MPI communicator |
L | size of tensor, A.shape = (L, L+1, L+2, L+3) |
ostrm | output stream for results |
void tests::test_contract | ( | const mpi_comm & | comm, |
int | L, | ||
std::ostream & | ostrm | ||
) |
Test for TensorD::contract (partial trace)
B = contract(A, Axes(0), Axes(2)), \( B_{ab} = \sum_{i} A_{iaib} \)
comm | MPI communicator |
L | size of tensor, A.shape = (L, L+1, L, L+2) |
ostrm | output stream for results |
void tests::test_contract_complex | ( | const mpi_comm & | comm, |
int | L, | ||
std::ostream & | ostrm | ||
) |
Test for TensorC::contract (partial trace)
B = contract(A, Axes(0), Axes(2)), \( B_{ab} = \sum_{i} A_{iaib} \)
comm | MPI communicator |
L | size of tensor, A.shape = (L, L+1, L, L+2) |
ostrm | output stream for results |
void tests::test_eigh | ( | const mpi_comm & | comm, |
int | L, | ||
std::ostream & | ostrm | ||
) |
Test for TensorD::eigh.
A[i,j,k,l] => Contract( Z[i,k,a] * W[a] * (Z[a,l,j])^t )
comm | MPI communicator |
L | size of tensor, A.shape = (L,L,L,L) |
ostrm | output stream for results |
void tests::test_eigh_complex | ( | const mpi_comm & | comm, |
int | L, | ||
std::ostream & | ostrm | ||
) |
Test for TensorC::eigh.
A[i,j,k,l] => Contract( Z[i,k,a] * W[a] * conj(Z[a,l,j]^t) )
comm | MPI communicator |
L | size of tensor, A.shape = (L,L,L,L) |
ostrm | output stream for results |
void tests::test_eigh_general | ( | const mpi_comm & | comm, |
int | L, | ||
std::ostream & | ostrm | ||
) |
Test for TensorD::eigh (generalized eigenvalue problem)
A[i,j,k,l] Z[l,k,a] = B[j,l,i,k] Z[l,k,a] W[a]
comm | MPI communicator |
L | size of tensor, A.shape = (L,L,L,L) |
ostrm | output stream for results |
void tests::test_eigh_general_complex | ( | const mpi_comm & | comm, |
int | L, | ||
std::ostream & | ostrm | ||
) |
Test for TensorC::eigh.
A[i,j,k,l] => Contract( Z[i,k,a] * W[a] * conj(Z[a,l,j]^t) )
comm | MPI communicator |
L | size of tensor, A.shape = (L,L,L,L) |
ostrm | output stream for results |
void tests::test_eigh_rank2 | ( | const mpi_comm & | comm, |
int | L, | ||
std::ostream & | ostrm | ||
) |
Test for TensorD::eigh.
A[i,j] => Contract( Z[i,a] * W[a] * (Z[a,j])^t )
comm | MPI communicator |
L | size of tensor, A.shape = (L*L, L*L) |
ostrm | output stream for results |
void tests::test_eigh_rank2_complex | ( | const mpi_comm & | comm, |
int | L, | ||
std::ostream & | ostrm | ||
) |
Test for TensorC::eigh.
A[i,j] => Contract( Z[i,a] * W[a] * conj(Z[a,j]^t) )
comm | MPI communicator |
L | size of tensor, A.shape = (L*L, L*L) |
ostrm | output stream for results |
void tests::test_kron | ( | const mpi_comm & | comm, |
int | L, | ||
std::ostream & | ostrm | ||
) |
Test for TensorD::kron.
C = kron(A, B)
comm | MPI communicator |
L | size of tensor, A.shape = (L, L+1), B.shape = (L+2, L+3) |
ostrm | output stream for results |
void tests::test_kron_complex | ( | const mpi_comm & | comm, |
int | L, | ||
std::ostream & | ostrm | ||
) |
Test for TensorC::kron.
C = kron(A, B)
comm | MPI communicator |
L | size of tensor, A.shape = (L, L+1), B.shape = (L+2, L+3) |
ostrm | output stream for results |
void tests::test_qr | ( | const mpi_comm & | comm, |
int | L, | ||
std::ostream & | ostrm | ||
) |
Test for TensorD::qr.
A[i,j,k,l] => Contract( Q[k,i,a] * R[a,j,l])
This is equivalent to the following numpy code.
comm | MPI communicator |
L | size of tensor, A.shape = (L, L+1, L+2, L+3) |
ostrm | output stream for results |
void tests::test_qr_complex | ( | const mpi_comm & | comm, |
int | L, | ||
std::ostream & | ostrm | ||
) |
Test for TensorC::qr.
A[i,j,k,l] => Contract( Q[k,i,a] * R[a,j,l])
This is equivalent to the following numpy code.
comm | MPI communicator |
L | size of tensor, A.shape = (L, L+1, L+2, L+3) |
ostrm | output stream for results |
void tests::test_qr_rank2 | ( | const mpi_comm & | comm, |
int | L, | ||
std::ostream & | ostrm | ||
) |
Test for TensorD::qr (Matrix version)
comm | MPI communicator |
L | size of tensor, A.shape = (L*(L+1), L*L) |
ostrm | output stream for results |
void tests::test_qr_rank2_complex | ( | const mpi_comm & | comm, |
int | L, | ||
std::ostream & | ostrm | ||
) |
Test for TensorC::qr (Matrix version)
comm | MPI communicator |
L | size of tensor, A.shape = (L*(L+1), L*L) |
ostrm | output stream for results |
void tests::test_reshape | ( | const mpi_comm & | comm, |
int | L, | ||
std::ostream & | ostrm | ||
) |
Test for TensorD::reshape.
B = reshape(A, (N0*N1, N2*N3))
comm | MPI communicator |
L | size of tensor A.shape = (L, L+1, L+2, L+3) |
ostrm | output stream for results |
void tests::test_reshape_complex | ( | const mpi_comm & | comm, |
int | L, | ||
std::ostream & | ostrm | ||
) |
Test for TensorC::reshape.
B = reshape(A, (N0*N1, N2*N3))
comm | MPI communicator |
L | size of tensor A.shape = (L, L+1, L+2, L+3) |
ostrm | output stream for results |
void tests::test_set_slice | ( | const mpi_comm & | comm, |
int | L, | ||
std::ostream & | ostrm | ||
) |
Test for TensorD::set_slice.
A[:, 3:6, :, :] = B and A[1:4, 0:2, :, 2:5] = C
comm | MPI communicator |
L | size of tensor A.shape = (L, L+1, L+2, L+3) |
ostrm | output stream for results |
void tests::test_set_slice_complex | ( | const mpi_comm & | comm, |
int | L, | ||
std::ostream & | ostrm | ||
) |
Test for TensorC::slice.
A[:, 3:6, :, :] = B and A[1:4, 0:2, :, 2:5] = C
comm | MPI communicator |
L | size of tensor A.shape = (L, L+1, L+2, L+3) |
ostrm | output stream for results |
void tests::test_slice | ( | const mpi_comm & | comm, |
int | L, | ||
std::ostream & | ostrm | ||
) |
Test for TensorD::slice.
B = A[:, 3:6, :, :] and C = A[:, 2:4, :, 1:5]
comm | MPI communicator |
L | size of tensor A.shape = (L, L+1, L+2, L+3) |
ostrm | output stream for results |
void tests::test_slice_complex | ( | const mpi_comm & | comm, |
int | L, | ||
std::ostream & | ostrm | ||
) |
Test for TensorC::slice.
B = A[:, 3:6, :, :] and C = A[:, 2:4, :, 1:5]
comm | MPI communicator |
L | size of tensor A.shape = (L, L+1, L+2, L+3) |
ostrm | output stream for results |
void tests::test_svd | ( | const mpi_comm & | comm, |
int | L, | ||
std::ostream & | ostrm | ||
) |
Test for TensorD::svd.
A[i,j,k,l] => Contract( U[k,i,a] * S[a] * V[a,j,l])
This is equivalent to the following numpy code.
comm | MPI communicator |
L | size of tensor, A.shape = (L, L+1, L+2, L+3) |
ostrm | output stream for results |
void tests::test_svd_complex | ( | const mpi_comm & | comm, |
int | L, | ||
std::ostream & | ostrm | ||
) |
Test for TensorC::svd.
A[i,j,k,l] => Contract( U[k,i,a] * S[a] * V[a,j,l])
This is equivalent to the following numpy code.
comm | MPI communicator |
L | size of tensor, A.shape = (L, L+1, L+2, L+3) |
ostrm | output stream for results |
void tests::test_tensordot | ( | const mpi_comm & | comm, |
int | L, | ||
std::ostream & | ostrm | ||
) |
Test for TensorD::tensordot.
C = tensordot(A, B, axes=([1,3],[2,0]))
This test may take a long time for check.
comm | MPI communicator |
L | size of tensor, A.shape = (L, L+4, L+1, L+5), B.shape = (L+5, L+2, L+4, L+3) |
ostrm | output stream for results |
void tests::test_tensordot_complex | ( | const mpi_comm & | comm, |
int | L, | ||
std::ostream & | ostrm | ||
) |
Test for TensorC::tensordot.
C = tensordot(A, B, axes=([1,3],[2,0]))
This test may take a long time for check.
comm | MPI communicator |
L | size of tensor, A.shape = (L, L+4, L+1, L+5), B.shape = (L+5, L+2, L+4, L+3) |
ostrm | output stream for results |
void tests::test_trace | ( | const mpi_comm & | comm, |
int | L, | ||
std::ostream & | ostrm | ||
) |
Test for full trace of tensor.
trace(A, Axes(0,1), Axes(3,2)) \( = \sum_{i,j} A_{ijji} \)
comm | MPI communicator |
L | size of tensor, A.shape = (L, L+1, L+1, L) |
ostrm | output stream for results |
void tests::test_trace2 | ( | const mpi_comm & | comm, |
int | L, | ||
std::ostream & | ostrm | ||
) |
Test for full contraction of two tensors.
trace(A, B, Axes(0,3,2,1), Axes(3,2,0,1)) \( = \sum_{a,b,c,d} A_{adcb} B_{dcab} \)
comm | MPI communicator |
L | size of tensor, A.shape = (L, L+1, L+2, L+3) |
ostrm | output stream for results |
void tests::test_trace2_complex | ( | const mpi_comm & | comm, |
int | L, | ||
std::ostream & | ostrm | ||
) |
Test for full contraction of two tensors (complex version)
trace(A, B, Axes(0,3,2,1), Axes(3,2,0,1)) \( = \sum_{a,b,c,d} A_{adcb} B_{dcab} \)
comm | MPI communicator |
L | size of tensor, A.shape = (L, L+1, L+2, L+3) |
ostrm | output stream for results |
void tests::test_trace_complex | ( | const mpi_comm & | comm, |
int | L, | ||
std::ostream & | ostrm | ||
) |
Test for full trace of tensor (complex version)
trace(A, Axes(0,1), Axes(3,2)) \( = \sum_{i,j} A_{ijji} \)
comm | MPI communicator |
L | size of tensor, A.shape = (L, L+1, L+1, L) |
ostrm | output stream for results |
void tests::test_transpose | ( | const mpi_comm & | comm, |
int | L, | ||
std::ostream & | ostrm | ||
) |
Test for TensorD::transpose.
B = transpose(A, (2,0,3,1))
comm | MPI communicator |
L | size of tensor A.shape = (L, L+1, L+2, L+3) |
ostrm | output stream for results |
void tests::test_transpose_complex | ( | const mpi_comm & | comm, |
int | L, | ||
std::ostream & | ostrm | ||
) |
Test for TensorC::transpose.
B = transpose(A, (2,0,3,1))
comm | MPI communicator |
L | size of tensor A.shape = (L, L+1, L+2, L+3) |
ostrm | output stream for results |