unitaria.Tensor

class unitaria.Tensor(A: Node, B: Node)[source]

Bases: Node

Node representing the tensor product of two other nodes

The order of operations is such that A corresponds to the more significant digits of the index, i.e.

>>> import unitaria as ut
>>> import numpy as np
>>> ut.Tensor(ut.Identity(ut.Subspace("#")), ut.Increment(bits=1)).toarray().real
array([[0., 1., 0., 0.],
       [1., 0., 0., 0.],
       [0., 0., 0., 1.],
       [0., 0., 1., 0.]])

The & operator for ut.Node is overloaded to be the tensor product, i.e. you can equivalently write

>>> import unitaria as ut
>>> import numpy as np
>>> (ut.Identity(ut.Subspace("#")) & ut.Increment(bits=1)).toarray().real
array([[0., 1., 0., 0.],
       [1., 0., 0., 0.],
       [0., 0., 0., 1.],
       [0., 0., 1., 0.]])
Parameters:
  • A – The first factor

  • B – The second factor