qalgebra.convert.to_sympy_matrix module

Conversion of QAlgebra 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 QAlgebra 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

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

Convert a QAlgebra 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 QAlgebra expression

  • full_space (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
  • BasisNotSetError – if full_space does not have a defined basis

  • ValueError – if expr is not in full_space, or if expr cannot be converted.

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

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

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