mptensor  v0.3.0
Parallel Library for Tensor Network Methods
tests Namespace Reference

Test codes for Tensor. More...

Typedefs

typedef Tensor< scalapack::Matrix, double > TensorD
 
typedef Tensor< scalapack::Matrix, complexTensorC
 

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)
 

Detailed Description

Test codes for Tensor.

Typedef Documentation

◆ TensorC

◆ TensorD

Function Documentation

◆ cfunc2_1()

complex tests::cfunc2_1 ( Index  idx,
Shape  shape 
)
inline

◆ cfunc4_1()

complex tests::cfunc4_1 ( Index  idx,
Shape  shape 
)
inline

◆ cfunc4_2()

complex tests::cfunc4_2 ( Index  idx,
Shape  shape 
)
inline

◆ func2_1()

double tests::func2_1 ( Index  idx,
Shape  shape 
)
inline

◆ func4_1()

double tests::func4_1 ( Index  idx,
Shape  shape 
)
inline

◆ func4_2()

double tests::func4_2 ( Index  idx,
Shape  shape 
)
inline

◆ test_arithmetic()

void tests::test_arithmetic ( const mpi_comm comm,
int  L,
std::ostream &  ostrm 
)

Test for arithmetic operators.

Parameters
commMPI communicator
Lsize of tensor, A.shape = (L, L+1, L+2, L+3)
ostrmoutput stream for results

◆ test_arithmetic_complex()

void tests::test_arithmetic_complex ( const mpi_comm comm,
int  L,
std::ostream &  ostrm 
)

Test for arithmetic operators (complex version)

Parameters
commMPI communicator
Lsize of tensor, A.shape = (L, L+1, L+2, L+3)
ostrmoutput stream for results

◆ test_contract()

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} \)

Parameters
commMPI communicator
Lsize of tensor, A.shape = (L, L+1, L, L+2)
ostrmoutput stream for results

◆ test_contract_complex()

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} \)

Parameters
commMPI communicator
Lsize of tensor, A.shape = (L, L+1, L, L+2)
ostrmoutput stream for results

◆ test_eigh()

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 )

Parameters
commMPI communicator
Lsize of tensor, A.shape = (L,L,L,L)
ostrmoutput stream for results

◆ test_eigh_complex()

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) )

Parameters
commMPI communicator
Lsize of tensor, A.shape = (L,L,L,L)
ostrmoutput stream for results

◆ test_eigh_general()

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]

Parameters
commMPI communicator
Lsize of tensor, A.shape = (L,L,L,L)
ostrmoutput stream for results

◆ test_eigh_general_complex()

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) )

Parameters
commMPI communicator
Lsize of tensor, A.shape = (L,L,L,L)
ostrmoutput stream for results

◆ test_eigh_rank2()

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 )

Parameters
commMPI communicator
Lsize of tensor, A.shape = (L*L, L*L)
ostrmoutput stream for results

◆ test_eigh_rank2_complex()

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) )

Parameters
commMPI communicator
Lsize of tensor, A.shape = (L*L, L*L)
ostrmoutput stream for results

◆ test_kron()

void tests::test_kron ( const mpi_comm comm,
int  L,
std::ostream &  ostrm 
)

Test for TensorD::kron.

C = kron(A, B)

Parameters
commMPI communicator
Lsize of tensor, A.shape = (L, L+1), B.shape = (L+2, L+3)
ostrmoutput stream for results

◆ test_kron_complex()

void tests::test_kron_complex ( const mpi_comm comm,
int  L,
std::ostream &  ostrm 
)

Test for TensorC::kron.

C = kron(A, B)

Parameters
commMPI communicator
Lsize of tensor, A.shape = (L, L+1), B.shape = (L+2, L+3)
ostrmoutput stream for results

◆ test_qr()

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.

AT = np.transpose(AT, (2,0,1,3))
shape = AT.shape
AT.reshape( (shape[0]*shape[1], shape[2]*shape[3]) )
Q, R = linalg.qr(AT, mode='reduced')
Q.reshape( (shape[0], shape[1], Q.shape[2]) )
R.reshape( (R.shape[0], shape[2], shape[3]) )
tuple shape
Definition: output.py:28
Parameters
commMPI communicator
Lsize of tensor, A.shape = (L, L+1, L+2, L+3)
ostrmoutput stream for results

◆ test_qr_complex()

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.

AT = np.transpose(AT, (2,0,1,3))
shape = AT.shape
AT.reshape( (shape[0]*shape[1], shape[2]*shape[3]) )
Q, R = linalg.qr(AT, mode='reduced')
Q.reshape( (shape[0], shape[1], Q.shape[2]) )
R.reshape( (R.shape[0], shape[2], shape[3]) )
Parameters
commMPI communicator
Lsize of tensor, A.shape = (L, L+1, L+2, L+3)
ostrmoutput stream for results

◆ test_qr_rank2()

void tests::test_qr_rank2 ( const mpi_comm comm,
int  L,
std::ostream &  ostrm 
)

Test for TensorD::qr (Matrix version)

Q, R = np.linalg.qr(A,mode='reduced')
Parameters
commMPI communicator
Lsize of tensor, A.shape = (L*(L+1), L*L)
ostrmoutput stream for results

◆ test_qr_rank2_complex()

void tests::test_qr_rank2_complex ( const mpi_comm comm,
int  L,
std::ostream &  ostrm 
)

Test for TensorC::qr (Matrix version)

Q, R = np.linalg.qr(A,mode='reduced')
Parameters
commMPI communicator
Lsize of tensor, A.shape = (L*(L+1), L*L)
ostrmoutput stream for results

◆ test_reshape()

void tests::test_reshape ( const mpi_comm comm,
int  L,
std::ostream &  ostrm 
)

Test for TensorD::reshape.

B = reshape(A, (N0*N1, N2*N3))

Parameters
commMPI communicator
Lsize of tensor A.shape = (L, L+1, L+2, L+3)
ostrmoutput stream for results

◆ test_reshape_complex()

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))

Parameters
commMPI communicator
Lsize of tensor A.shape = (L, L+1, L+2, L+3)
ostrmoutput stream for results

◆ test_set_slice()

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

Parameters
commMPI communicator
Lsize of tensor A.shape = (L, L+1, L+2, L+3)
ostrmoutput stream for results

◆ test_set_slice_complex()

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

Parameters
commMPI communicator
Lsize of tensor A.shape = (L, L+1, L+2, L+3)
ostrmoutput stream for results

◆ test_slice()

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]

Parameters
commMPI communicator
Lsize of tensor A.shape = (L, L+1, L+2, L+3)
ostrmoutput stream for results

◆ test_slice_complex()

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]

Parameters
commMPI communicator
Lsize of tensor A.shape = (L, L+1, L+2, L+3)
ostrmoutput stream for results

◆ test_svd()

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.

A = np.transpose(A, (2,0,1,3))
shape = A.shape
A.reshape( (shape[0]*shape[1], shape[2]*shape[3]) )
U, S, V = linalg.svd(A, full_matrix=False)
U.reshape( (shape[0],shape[1],len(S)) )
V.reshape( (len(S),shape[2],shape[3]) )
Parameters
commMPI communicator
Lsize of tensor, A.shape = (L, L+1, L+2, L+3)
ostrmoutput stream for results

◆ test_svd_complex()

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.

A = np.transpose(A, (2,0,1,3))
shape = A.shape
A.reshape( (shape[0]*shape[1], shape[2]*shape[3]) )
U, S, V = linalg.svd(A, full_matrix=False)
U.reshape( (shape[0],shape[1],len(S)) )
V.reshape( (len(S),shape[2],shape[3]) )
Parameters
commMPI communicator
Lsize of tensor, A.shape = (L, L+1, L+2, L+3)
ostrmoutput stream for results

◆ test_tensordot()

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.

Parameters
commMPI communicator
Lsize of tensor, A.shape = (L, L+4, L+1, L+5), B.shape = (L+5, L+2, L+4, L+3)
ostrmoutput stream for results

◆ test_tensordot_complex()

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.

Parameters
commMPI communicator
Lsize of tensor, A.shape = (L, L+4, L+1, L+5), B.shape = (L+5, L+2, L+4, L+3)
ostrmoutput stream for results

◆ test_trace()

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} \)

Parameters
commMPI communicator
Lsize of tensor, A.shape = (L, L+1, L+1, L)
ostrmoutput stream for results

◆ test_trace2()

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} \)

Parameters
commMPI communicator
Lsize of tensor, A.shape = (L, L+1, L+2, L+3)
ostrmoutput stream for results

◆ test_trace2_complex()

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} \)

Parameters
commMPI communicator
Lsize of tensor, A.shape = (L, L+1, L+2, L+3)
ostrmoutput stream for results

◆ test_trace_complex()

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} \)

Parameters
commMPI communicator
Lsize of tensor, A.shape = (L, L+1, L+1, L)
ostrmoutput stream for results

◆ test_transpose()

void tests::test_transpose ( const mpi_comm comm,
int  L,
std::ostream &  ostrm 
)

Test for TensorD::transpose.

B = transpose(A, (2,0,3,1))

Parameters
commMPI communicator
Lsize of tensor A.shape = (L, L+1, L+2, L+3)
ostrmoutput stream for results

◆ test_transpose_complex()

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))

Parameters
commMPI communicator
Lsize of tensor A.shape = (L, L+1, L+2, L+3)
ostrmoutput stream for results