qnet.convert.to_sympy_matrix module

Conversion of QNET expressions to sympy matrices. For small Hilbert spaces, this facilitates some analytic treatments, such as decomposition into a basis.

Summary

Functions:

SympyCreate Creation operator for a Hilbert space of dimension n, as an instance of sympy.Matrix
basis_state n x 1 sympy.Matrix representing the i’th eigenstate of an n-dimensional Hilbert space (i >= 0)
convert_to_sympy_matrix Convert a QNET expression to an explicit n x n instance of sympy.Matrix, where n is the dimension of full_space.

__all__: convert_to_sympy_matrix

Reference

qnet.convert.to_sympy_matrix.basis_state(i, n)[source]

n x 1 sympy.Matrix representing the i’th eigenstate of an n-dimensional Hilbert space (i >= 0)

qnet.convert.to_sympy_matrix.SympyCreate(n)[source]

Creation operator for a Hilbert space of dimension n, as an instance of sympy.Matrix

qnet.convert.to_sympy_matrix.convert_to_sympy_matrix(expr, full_space=None)[source]

Convert a QNET expression to an explicit n x n instance of sympy.Matrix, where n is the dimension of full_space. The entries of the matrix may contain symbols.

Parameters:
  • expr – a QNET expression
  • full_space (qnet.algebra.hilbert_space_algebra.HilbertSpace) – The Hilbert space in which expr is defined. If not given, expr.space is used. The Hilbert space must have a well-defined basis.
Raises:
  • qnet.algebra.hilbert_space_algebra.BasisNotSetError – if full_space does not have a defined basis
  • ValueError – if expr is not in full_space, or if expr cannot be converted.