Checks

This module provides utility functions for manipulating quantum many-body operators and matrices.

ed_lgt.tools.checks.alert(phrase, debug)[source]

Display an alert message during program execution.

Parameters:
  • phrase (str) – The alert message to display.

  • debug (bool) – If True, the alert and message are executed; if False, they are skipped.

Raises:

TypeError – If the input arguments are of incorrect types or formats.

ed_lgt.tools.checks.anti_commutator(A, B)[source]

Compute the anti-commutator of two sparse matrices.

Parameters:
  • A (scipy.sparse.csr_matrix) – First matrix

  • B (scipy.sparse.csr_matrix) – Second matrix

Raises:

TypeError – If the input arguments are of incorrect types or formats.

Returns:

The anti-commutator of matrices A and B.

Return type:

scipy.sparse.csr_matrix

ed_lgt.tools.checks.check_commutator(A, B)[source]

Check the commutation relations between two operators A and B.

Parameters:
  • A (scipy.sparse.csr_matrix) – First matrix

  • B (scipy.sparse.csr_matrix) – Second matrix

Raises:
  • TypeError – If the input arguments are of incorrect types or formats.

  • ValueError – If the commutation ratio is greater than a threshold.

ed_lgt.tools.checks.check_hermitian(A)[source]

Check if a sparse matrix A is Hermitian.

Parameters:

A (scipy.sparse.csr_matrix) – The sparse matrix to check for Hermiticity.

Raises:

TypeError – If the input matrix is not in the correct format.

ed_lgt.tools.checks.check_matrix(A, B)[source]

Check the difference between two sparse matrices A and B computing the Frobenius Norm

Parameters:
  • A (scipy.sparse.csr_matrix) – First matrix

  • B (scipy.sparse.csr_matrix) – Second matrix

Raises:
  • TypeError – If the input arguments are of incorrect types or formats.

  • ValueError – If the matrices have different shapes or the difference ratio is above a threshold.

ed_lgt.tools.checks.commutator(A, B)[source]

Compute the commutator of two sparse matrices.

Parameters:
  • A (scipy.sparse.csr_matrix) – First matrix

  • B (scipy.sparse.csr_matrix) – Second matrix

Raises:

TypeError – If the input arguments are of incorrect types or formats.

Returns:

The commutator of matrices A and B.

Return type:

scipy.sparse.csr_matrix

ed_lgt.tools.checks.get_time(func)[source]

Times any function

ed_lgt.tools.checks.pause(phrase, debug)[source]

Pause the execution of the program and display a message.

Parameters:
  • phrase (str) – The message to display.

  • debug (bool) – If True, the pause and message are executed; if False, they are skipped.

Raises:

TypeError – If the input arguments are of incorrect types or formats.

ed_lgt.tools.checks.validate_parameters(lvals=None, loc_dims=None, lattice_dim=None, has_obc=None, axes=None, site_label=None, coords=None, ops_dict=None, op_list=None, op_names_list=None, op_sites_list=None, add_dagger=None, get_real=None, get_imag=None, staggered_basis=None, stag_label=None, all_sites_equal=None, gauge_basis=None, dictionary=None, filename=None, phrase=None, debug=None, psi=None, spmatrix=None, index=None, threshold=None, print_plaq=None, spin_list=None, int_list=None, sz_list=None, pure_theory=None, matter=None, psi_vacuum=None, get_singlet=None)[source]

This is a function for type validation of parameters widely used in the library

See also

checks Module