qcircuits.tensors module¶
-
class
qcircuits.tensors.Tensor(tensor)¶ Bases:
objectA container class for a tensor representing either a state vector or an operator, with methods for common functionality of both
StateandOperator.Parameters: tensor (numpy complex128 multidimensional array) – The tensor representing either a quantum state or an operator on the vector space for a quantum state. -
rank¶ Get the rank of the tensor. For d qubit systems, a
Statewill have rank d, while anOperatorwith have rank 2dReturns: The tensor rank. Return type: int
-
shape¶ Get the shape of the tensor. For d qubit systems, a
Statewill have shape [2] \(\times d\), while anOperatorwill have shape [2] \(\times 2d\).Returns: The tensor shape. Return type: int
-
tensor_power(n)¶ Return the
StateorOperatorgiven by the tensor product of this object with itself n times. Can also be called with the infix ** operator, i.e., A**n.Parameters: n (int) – The number of times to take the tensor product of this object with itself. Returns: If this object has tensor A, returns \(A^{\otimes n}\). Return type: State or Operator (depends on this object type)
-
tensor_product(arg)¶ Return the
StateorOperatorgiven by the tensor product of this object with anotherStateorOperator. Can also be called with the infix * operator, i.e., A * B.Parameters: arg (State) – The StateorOperatorwith which to take the tensor product.Returns: If this object has tensor A, and argument has tensor B, returns \(A\otimes B\). Return type: State or Operator (depends on argument type)
-