qitensor: a python module for quantum information and map-state dualityThis module is essentially a wrapper for numpy that uses semantics useful for finite dimensional quantum mechanics of many particles. In particular, this should be useful for the study of quantum information and quantum computing. Each array is associated with a tensor-product Hilbert space. The underlying spaces can be bra spaces or ket spaces. When arrays are multiplied, a tensor contraction is performed among the bra spaces of the left array and the ket spaces of the right array. Various linear algebra methods are available which are aware of the Hilbert space tensor product structure.
Download
Python module: qitensor-0.11.tar.gz
DocumentationThe documentation contains usage examples and an API reference: qitensor docsSynopsis>>> from qitensor import qubit
>>> ha = qubit('a')
>>> hb = qubit('b')
>>> ha * hb
|a,b>
>>> x = (ha * hb).array()
>>> x
HilbertArray(|a,b>,
array([[ 0.+0.j, 0.+0.j],
[ 0.+0.j, 0.+0.j]]))
>>> from qitensor import qudit
>>> hc = qudit('c', 3)
>>> hc.array()
HilbertArray(|c>,
array([ 0.+0.j, 0.+0.j, 0.+0.j]))
In Sage the arrays can use the Symbolic Ring. Also, Sage's block_matrix is used to pretty-print the arrays.
sage: from qitensor import qubit
sage: ha = qubit('a', dtype=SR)
sage: hb = qubit('b', dtype=SR)
sage: (x, y) = var('x y')
sage: U = (ha * hb).eye()
sage: U[{ ha: 0, ha.H: 0, hb: 0, hb.H: 0 }] = x
sage: U[{ ha: 0, ha.H: 0, hb: 0, hb.H: 1 }] = y
sage: U
|a,b><a,b|
[x y|0 0]
[0 1|0 0]
[---+---]
[0 0|1 0]
[0 0|0 1]
sage: U.I
|a,b><a,b|
[ 1/x -y/x| 0 0]
[ 0 1| 0 0]
[---------+---------]
[ 0 0| 1 0]
[ 0 0| 0 1]
|