qcircuits.tensors module¶
-
class
qcircuits.tensors.
Tensor
(tensor)¶ Bases:
object
A container class for a tensor representing either a state vector or an operator, with methods for common functionality of both
State
andOperator
.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
State
will have rank d, while anOperator
with have rank 2dReturns: The tensor rank. Return type: int
-
shape
¶ Get the shape of the tensor. For d qubit systems, a
State
will have shape [2] \(\times d\), while anOperator
will have shape [2] \(\times 2d\).Returns: The tensor shape. Return type: int
-
tensor_power
(n)¶ Return the
State
orOperator
given 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
State
orOperator
given by the tensor product of this object with anotherState
orOperator
. Can also be called with the infix * operator, i.e., A * B.Parameters: arg (State) – The State
orOperator
with 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)
-