Factory Functions

This module contains functions for creating HilbertSpace’s and HilbertBaseField’s. This is the preferred entry point for using the qitensor package.

qitensor.factory.base_field_lookup(dtype)

Returns the HilbertBaseField for the given data type.

Parameters:dtype (python type or Sage CommutativeRing or HilbertBaseField; default complex) – the base field data type
>>> from qitensor import base_field_lookup
>>> base_field_lookup(complex).__class__
<type 'qitensor.basefield.HilbertBaseField'>
qitensor.factory.indexed_space(label, indices, dtype=complex, latex_label=None, group_op=None)

Returns a finite-dimensional Hilbert space with an arbitrary index set.

Parameters:
  • label – a unique label for this Hilbert space
  • indices – a sequence defining the index set
  • dtype (python type or Sage CommutativeRing or HilbertBaseField; default complex) – the base field data type
  • latex_label – an optional latex representation of the label
  • group_op – group operation

group_op, if given, should be a class that defines an op(self, x, y) method. This supports things like the generalized pauliX operator. The default is op(self, x, y) = x*y. The qubit and qudit constructors use op(self, x, y) = (x+y)%D.

This is really just a shortcut for
base_field_lookup(dtype).indexed_space( ... )

See also: qubit(), qudit()

>>> from qitensor import indexed_space
>>> ha = indexed_space('a', ['x', 'y', 'z'])
>>> ha
|a>
>>> ha.indices
('x', 'y', 'z')
qitensor.factory.qubit(label, dtype=complex, latex_label=None)

Returns a two-dimensional Hilbert space with index set [0, 1].

Parameters:
  • label – a unique label for this Hilbert space
  • dtype (python type or Sage CommutativeRing or HilbertBaseField; default complex) – the base field data type
  • latex_label – an optional latex representation of the label
This is really just a shortcut for
base_field_lookup(dtype).qubit( ... )

See also: qudit(), indexed_space()

>>> from qitensor import qubit
>>> ha = qubit('a')
>>> ha
|a>
>>> ha.indices
(0, 1)
qitensor.factory.qudit(label, dim, dtype=complex, latex_label=None)

Returns a finite-dimensional Hilbert space with index set [0, 1, ..., n-1].

Parameters:
  • label – a unique label for this Hilbert space
  • dim – the dimension of the Hilbert space
  • dtype (python type or Sage CommutativeRing or HilbertBaseField; default complex) – the base field data type
  • latex_label – an optional latex representation of the label
This is really just a shortcut for
base_field_lookup(dtype).qudit( ... )

See also: qubit(), indexed_space()

>>> from qitensor import qudit
>>> ha = qudit('a', 3)
>>> ha
|a>
>>> ha.indices
(0, 1, 2)
qitensor.factory.GroupOpCyclic_factory(D)

Returns an instance of GroupOpCyclic_impl, the cyclic group of order D.

>>> from qitensor import GroupOpCyclic_factory
>>> g = GroupOpCyclic_factory(5)
>>> g.op(2, 7)
4
qitensor.factory.GroupOpTimes_factory()

Returns an instance of GroupOpTimes_impl, which operates on elements by multiplication.

>>> from qitensor import GroupOpTimes_factory
>>> g = GroupOpTimes_factory()
>>> g.op(3, 4)
12

Previous topic

Reference

Next topic

Hilbert Spaces

This Page