Download Notebook

Tensor product between QOperations

This note describes tensor products between Qoperations and their samples.

Tensor Product

Tensor product is an operation in the spatial direction. To compute the tensor product, use tensor_product() in the quara.objects.operators module.

As a simple example, let’s look at how to compute the tensor product between the following States.

formula:

\(\rho_{z0} {\otimes } \rho_{z1}\)

quantum circuit diagram:

── \(\rho_{z0}\) ──
── \(\rho_{z1}\) ──

First, prepare the State to be used for the operation. Note that the IDs of the ElementalSystems between QOperations to be calculated with tensor products must be different.

[1]:
from quara.objects.composite_system_typical import generate_composite_system
from quara.objects.qoperation_typical import generate_qoperation

# Prepare State
c_sys_0 = generate_composite_system("qubit", 1, ids_esys=[0])
c_sys_1 = generate_composite_system("qubit", 1, ids_esys=[1])
state_z0 = generate_qoperation(mode="state", name="z0", c_sys=c_sys_0)
state_z1 = generate_qoperation(mode="state", name="z1", c_sys=c_sys_1)

print(f"vec of state_z0: {state_z0.vec}")
print(f"vec of state_z1: {state_z1.vec}")
vec of state_z0: [0.70710678 0.         0.         0.70710678]
vec of state_z1: [ 0.70710678  0.          0.         -0.70710678]

\(\rho_{z0} {\otimes } \rho_{z1}\) can be written as follows.

[2]:
from quara.objects.operators import tensor_product

# Tensor product
result = tensor_product(state_z0, state_z1)

# Result
print(result)
Type:
State

Dim:
4

Vec:
[ 0.5  0.   0.  -0.5  0.   0.   0.   0.   0.   0.   0.   0.   0.5  0.
  0.  -0.5]

The result of the tensor product between 1-qubit States is a 2-qubit State.

Order of operations

The order of operations within tensor_product() follows the order of the ElementalSystem IDs of each QOperation in ascending order.

In the following cases, the tensor product of \(\rho_{z0}\) and \(\rho_{z1}\) is computed. Since the ElementalSystem ID of \(\rho_{z0}\) is 0 and the ElementalSystem ID of \(\rho_{z0}\) is 1, the tensor product is calculated in the order \(\rho_{z0} {\otimes } {\rho_{z1}}\). Because the calculation is based on the order of the IDs in the ElementalSystem, the result will be the same even if the order passed to the tensor_product() argument is different.

[3]:
# Prepare State
c_sys_0 = generate_composite_system("qubit", 1, ids_esys=[0])
c_sys_1 = generate_composite_system("qubit", 1, ids_esys=[1])
state_0 = generate_qoperation(mode="state", name="z0", c_sys=c_sys_0)
state_1 = generate_qoperation(mode="state", name="z1", c_sys=c_sys_1)

# Case 1:
result = tensor_product(state_z0, state_z1)
print("Case 1:")
print(result.vec)

# Case 2: Same result as Case 1
result = tensor_product(state_z1, state_z0)
print("Case 2:")
print(result.vec)
Case 1:
[ 0.5  0.   0.  -0.5  0.   0.   0.   0.   0.   0.   0.   0.   0.5  0.
  0.  -0.5]
Case 2:
[ 0.5  0.   0.  -0.5  0.   0.   0.   0.   0.   0.   0.   0.   0.5  0.
  0.  -0.5]

Different ElementalSystem IDs will change the results as follows. Since the ElementalSystem ID of \(\rho_{z0}\) is 1 and the ElementalSystem ID of \(\rho_{z0}\) is 0, the tensor product is calculated in the order \(\rho_{z1} {\otimes } {\rho_{z0}}\), not \(\rho_{z0} {\otimes } {\rho_{z1}}\).

[4]:
# Prepare State
c_sys_0 = generate_composite_system("qubit", 1, ids_esys=[1])  # change id_esys
c_sys_1 = generate_composite_system("qubit", 1, ids_esys=[0])  # change id_esys
state_z0 = generate_qoperation(mode="state", name="z0", c_sys=c_sys_0)
state_z1 = generate_qoperation(mode="state", name="z1", c_sys=c_sys_1)

# Case 3: Different results from Case 1 and Case 2
result = tensor_product(state_z0, state_z1)
print("Case 3:")
print(result.vec)
Case 3:
[ 0.5  0.   0.   0.5  0.   0.   0.   0.   0.   0.   0.   0.  -0.5  0.
  0.  -0.5]

Tensor product of three or more QOperations

For three or more QOepration operations, add to the argument. The following code computes the tensor product of three States ( \(\rho_{z0} {\otimes } \rho_{z1} {\otimes } \rho_{x0}\) )

[5]:
# Prepare States
c_sys_0 = generate_composite_system("qubit", 1, ids_esys=[0])
c_sys_1 = generate_composite_system("qubit", 1, ids_esys=[1])
c_sys_2 = generate_composite_system("qubit", 1, ids_esys=[2])

state_z0 = generate_qoperation(mode="state", name="z0", c_sys=c_sys_0)
state_z1 = generate_qoperation(mode="state", name="z1", c_sys=c_sys_1)
state_x0 = generate_qoperation(mode="state", name="x0", c_sys=c_sys_2)

# Tensor product of three or more QOperations
result = tensor_product(state_z0, state_z1, state_x0)
print(result)
Type:
State

Dim:
8

Vec:
[ 0.35355339  0.35355339  0.          0.          0.          0.
  0.          0.          0.          0.          0.          0.
 -0.35355339 -0.35355339  0.          0.          0.          0.
  0.          0.          0.          0.          0.          0.
  0.          0.          0.          0.          0.          0.
  0.          0.          0.          0.          0.          0.
  0.          0.          0.          0.          0.          0.
  0.          0.          0.          0.          0.          0.
  0.35355339  0.35355339  0.          0.          0.          0.
  0.          0.          0.          0.          0.          0.
 -0.35355339 -0.35355339  0.          0.        ]

It is also possible to specify QOperations as a list. For example, the following two expressions have the same meaning.

[6]:
# Specify by appending to the argument
result = tensor_product(state_z0, state_z1, state_x0)

# Specify by list
result = tensor_product([state_z0, state_z1, state_x0])

Utility for typical tensor product

Tensor products between typical QOperations can also be computed with generate_qoperation(). The tensor product of Qoperation names “a” and “b” is written “a_b”.

For example, the tensor product of two States, z0 and z1, can be written as follows

[7]:
from quara.objects.qoperation_typical import generate_qoperation

# Using utility function
# Tensor product of z0 and z1
c_sys_2qubit = generate_composite_system("qubit", 2, ids_esys=[0, 1])
result =  generate_qoperation(mode="state", name="z0_z1", c_sys=c_sys_2qubit)
print(result)
Type:
State

Dim:
4

Vec:
[ 0.5  0.   0.  -0.5  0.   0.   0.   0.   0.   0.   0.   0.   0.5  0.
  0.  -0.5]

Supported operations

The tensor_product() supports the following combinations of QOperations.

Input

Output

State \({\otimes }\) State

State

Povm \({\otimes }\) Povm

Povm

Gate \({\otimes }\) Gate

Gate

State \({\otimes }\) StateEnsemble

StateEnsemble

StateEnsemble \({\otimes }\) State

StateEnsemble

StateEnsemble \({\otimes }\) StateEnsemble

StateEnsemble

Gate \({\otimes }\) MProcess

MProcess

MProcess \({\otimes }\) Gate

MProcess

MProcess \({\otimes }\) MProcess

MProcess

MatrixBasis \({\otimes }\) MatrixBasis

MatrixBasis

Examples

State \({\otimes }\) State -> State

[8]:
# Prepare
c_sys_0 = generate_composite_system("qubit", 1, ids_esys=[0])
c_sys_1 = generate_composite_system("qubit", 1, ids_esys=[1])
state_0 = generate_qoperation(mode="state", name="z0", c_sys=c_sys_0)
state_1 = generate_qoperation(mode="state", name="z1", c_sys=c_sys_1)

# Tensor product
result = tensor_product(state_0, state_1)
print(result)  # State
Type:
State

Dim:
4

Vec:
[ 0.5  0.   0.  -0.5  0.   0.   0.   0.   0.   0.   0.   0.   0.5  0.
  0.  -0.5]

Povm \({\otimes }\) Povm -> Povm

[9]:
# Prepare
povm_0 = generate_qoperation(mode="povm", name="x", c_sys=c_sys_0)
povm_1 = generate_qoperation(mode="povm", name="z", c_sys=c_sys_1)

# Tensor product
result = tensor_product(povm_0, povm_1)
print(result)  # Povm
Type:
Povm

Dim:
4

Number of outcomes:
4

Vecs:
[[ 0.5  0.   0.   0.5  0.5  0.   0.   0.5  0.   0.   0.   0.   0.   0.
   0.   0. ]
 [ 0.5  0.   0.  -0.5  0.5  0.   0.  -0.5  0.   0.   0.   0.   0.   0.
   0.   0. ]
 [ 0.5  0.   0.   0.5 -0.5  0.   0.  -0.5  0.   0.   0.   0.   0.   0.
   0.   0. ]
 [ 0.5  0.   0.  -0.5 -0.5  0.   0.   0.5  0.   0.   0.   0.   0.   0.
   0.   0. ]]

Gate \({\otimes }\) Gate -> Gate

[10]:
# Prepare
gate_0 = generate_qoperation(mode="gate", name="x", c_sys=c_sys_0)
gate_1 = generate_qoperation(mode="gate", name="y", c_sys=c_sys_1)

# Tensor product
result = tensor_product(gate_0, gate_1)
print(result)  # Gate
Type:
Gate

Dim:
4

HS:
[[ 1.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.]
 [ 0. -1.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.]
 [ 0.  0.  1.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.]
 [ 0.  0.  0. -1.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.]
 [ 0.  0.  0.  0.  1.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.]
 [ 0.  0.  0.  0.  0. -1.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.]
 [ 0.  0.  0.  0.  0.  0.  1.  0.  0.  0.  0.  0.  0.  0.  0.  0.]
 [ 0.  0.  0.  0.  0.  0.  0. -1.  0.  0.  0.  0.  0.  0.  0.  0.]
 [ 0.  0.  0.  0.  0.  0.  0.  0. -1.  0.  0.  0.  0.  0.  0.  0.]
 [ 0.  0.  0.  0.  0.  0.  0.  0.  0.  1.  0.  0.  0.  0.  0.  0.]
 [ 0.  0.  0.  0.  0.  0.  0.  0.  0.  0. -1.  0.  0.  0.  0.  0.]
 [ 0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  1.  0.  0.  0.  0.]
 [ 0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0. -1.  0.  0.  0.]
 [ 0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  1.  0.  0.]
 [ 0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0. -1.  0.]
 [ 0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  1.]]

State \({\otimes }\) StateEnsemble -> StateEnsemble

[11]:
# Prepare
state_0 = generate_qoperation(mode="state", name="z0", c_sys=c_sys_0)
state_ensemble_0 = generate_qoperation(mode="state_ensemble", name="z0", c_sys=c_sys_1)

# Tensor product
result = tensor_product(state_0, state_ensemble_0)
print(result)  # StateEnsemble
Type:
StateEnsemble

States:
states[0]: [0.5 0.  0.  0.5 0.  0.  0.  0.  0.  0.  0.  0.  0.5 0.  0.  0.5]
states[1]: [ 0.5  0.   0.  -0.5  0.   0.   0.   0.   0.   0.   0.   0.   0.5  0.
  0.  -0.5]

MultinomialDistribution:
shape = (2,)
ps = [1. 0.]

StateEnsemble \({\otimes }\) State -> StateEnsemble

[12]:
# Tensor product
result = tensor_product(state_ensemble_0, state_0)
print(result)  # StateEnsemble
Type:
StateEnsemble

States:
states[0]: [0.5 0.  0.  0.5 0.  0.  0.  0.  0.  0.  0.  0.  0.5 0.  0.  0.5]
states[1]: [ 0.5  0.   0.  -0.5  0.   0.   0.   0.   0.   0.   0.   0.   0.5  0.
  0.  -0.5]

MultinomialDistribution:
shape = (2,)
ps = [1. 0.]

StateEnsemble \({\otimes }\) StateEnsemble -> StateEnsemble

[13]:
# Prepare
state_ensemble_0 = generate_qoperation(mode="state_ensemble", name="z0", c_sys=c_sys_0)
state_ensemble_1 = generate_qoperation(mode="state_ensemble", name="z1", c_sys=c_sys_1)

# Tensor product
result = tensor_product(state_ensemble_0, state_ensemble_1)
print(result)  # StateEnsemble
Type:
StateEnsemble

States:
states[0]: [0.5 0.  0.  0.5 0.  0.  0.  0.  0.  0.  0.  0.  0.5 0.  0.  0.5]
states[1]: [ 0.5  0.   0.  -0.5  0.   0.   0.   0.   0.   0.   0.   0.   0.5  0.
  0.  -0.5]
states[2]: [ 0.5  0.   0.   0.5  0.   0.   0.   0.   0.   0.   0.   0.  -0.5  0.
  0.  -0.5]
states[3]: [ 0.5  0.   0.  -0.5  0.   0.   0.   0.   0.   0.   0.   0.  -0.5  0.
  0.   0.5]

MultinomialDistribution:
shape = (2, 2)
ps = [0. 1. 0. 0.]

Gate \({\otimes }\) MProcess -> MProcess

[14]:
# Prepare
gate_0 = generate_qoperation(mode="gate", name="x", c_sys=c_sys_0)
mprocess_0 = generate_qoperation(mode="mprocess", name="x-type1", c_sys=c_sys_1)

# Tensor product
result = tensor_product(gate_0, mprocess_0)
print(result)  # MProcess
Type:
MProcess

Dim:
4

HSs:
[array([[ 0.5,  0.5,  0. ,  0. ,  0. ,  0. ,  0. ,  0. ,  0. ,  0. ,  0. ,
         0. ,  0. ,  0. ,  0. ,  0. ],
       [ 0.5,  0.5,  0. ,  0. ,  0. ,  0. ,  0. ,  0. ,  0. ,  0. ,  0. ,
         0. ,  0. ,  0. ,  0. ,  0. ],
       [ 0. ,  0. ,  0. ,  0. ,  0. ,  0. ,  0. ,  0. ,  0. ,  0. ,  0. ,
         0. ,  0. ,  0. ,  0. ,  0. ],
       [ 0. ,  0. ,  0. ,  0. ,  0. ,  0. ,  0. ,  0. ,  0. ,  0. ,  0. ,
         0. ,  0. ,  0. ,  0. ,  0. ],
       [ 0. ,  0. ,  0. ,  0. ,  0.5,  0.5,  0. ,  0. ,  0. ,  0. ,  0. ,
         0. ,  0. ,  0. ,  0. ,  0. ],
       [ 0. ,  0. ,  0. ,  0. ,  0.5,  0.5,  0. ,  0. ,  0. ,  0. ,  0. ,
         0. ,  0. ,  0. ,  0. ,  0. ],
       [ 0. ,  0. ,  0. ,  0. ,  0. ,  0. ,  0. ,  0. ,  0. ,  0. ,  0. ,
         0. ,  0. ,  0. ,  0. ,  0. ],
       [ 0. ,  0. ,  0. ,  0. ,  0. ,  0. ,  0. ,  0. ,  0. ,  0. ,  0. ,
         0. ,  0. ,  0. ,  0. ,  0. ],
       [ 0. ,  0. ,  0. ,  0. ,  0. ,  0. ,  0. ,  0. , -0.5, -0.5,  0. ,
         0. ,  0. ,  0. ,  0. ,  0. ],
       [ 0. ,  0. ,  0. ,  0. ,  0. ,  0. ,  0. ,  0. , -0.5, -0.5,  0. ,
         0. ,  0. ,  0. ,  0. ,  0. ],
       [ 0. ,  0. ,  0. ,  0. ,  0. ,  0. ,  0. ,  0. ,  0. ,  0. ,  0. ,
         0. ,  0. ,  0. ,  0. ,  0. ],
       [ 0. ,  0. ,  0. ,  0. ,  0. ,  0. ,  0. ,  0. ,  0. ,  0. ,  0. ,
         0. ,  0. ,  0. ,  0. ,  0. ],
       [ 0. ,  0. ,  0. ,  0. ,  0. ,  0. ,  0. ,  0. ,  0. ,  0. ,  0. ,
         0. , -0.5, -0.5,  0. ,  0. ],
       [ 0. ,  0. ,  0. ,  0. ,  0. ,  0. ,  0. ,  0. ,  0. ,  0. ,  0. ,
         0. , -0.5, -0.5,  0. ,  0. ],
       [ 0. ,  0. ,  0. ,  0. ,  0. ,  0. ,  0. ,  0. ,  0. ,  0. ,  0. ,
         0. ,  0. ,  0. ,  0. ,  0. ],
       [ 0. ,  0. ,  0. ,  0. ,  0. ,  0. ,  0. ,  0. ,  0. ,  0. ,  0. ,
         0. ,  0. ,  0. ,  0. ,  0. ]]), array([[ 0.5, -0.5,  0. ,  0. ,  0. ,  0. ,  0. ,  0. ,  0. ,  0. ,  0. ,
         0. ,  0. ,  0. ,  0. ,  0. ],
       [-0.5,  0.5,  0. ,  0. ,  0. ,  0. ,  0. ,  0. ,  0. ,  0. ,  0. ,
         0. ,  0. ,  0. ,  0. ,  0. ],
       [ 0. ,  0. ,  0. ,  0. ,  0. ,  0. ,  0. ,  0. ,  0. ,  0. ,  0. ,
         0. ,  0. ,  0. ,  0. ,  0. ],
       [ 0. ,  0. ,  0. ,  0. ,  0. ,  0. ,  0. ,  0. ,  0. ,  0. ,  0. ,
         0. ,  0. ,  0. ,  0. ,  0. ],
       [ 0. ,  0. ,  0. ,  0. ,  0.5, -0.5,  0. ,  0. ,  0. ,  0. ,  0. ,
         0. ,  0. ,  0. ,  0. ,  0. ],
       [ 0. ,  0. ,  0. ,  0. , -0.5,  0.5,  0. ,  0. ,  0. ,  0. ,  0. ,
         0. ,  0. ,  0. ,  0. ,  0. ],
       [ 0. ,  0. ,  0. ,  0. ,  0. ,  0. ,  0. ,  0. ,  0. ,  0. ,  0. ,
         0. ,  0. ,  0. ,  0. ,  0. ],
       [ 0. ,  0. ,  0. ,  0. ,  0. ,  0. ,  0. ,  0. ,  0. ,  0. ,  0. ,
         0. ,  0. ,  0. ,  0. ,  0. ],
       [ 0. ,  0. ,  0. ,  0. ,  0. ,  0. ,  0. ,  0. , -0.5,  0.5,  0. ,
         0. ,  0. ,  0. ,  0. ,  0. ],
       [ 0. ,  0. ,  0. ,  0. ,  0. ,  0. ,  0. ,  0. ,  0.5, -0.5,  0. ,
         0. ,  0. ,  0. ,  0. ,  0. ],
       [ 0. ,  0. ,  0. ,  0. ,  0. ,  0. ,  0. ,  0. ,  0. ,  0. ,  0. ,
         0. ,  0. ,  0. ,  0. ,  0. ],
       [ 0. ,  0. ,  0. ,  0. ,  0. ,  0. ,  0. ,  0. ,  0. ,  0. ,  0. ,
         0. ,  0. ,  0. ,  0. ,  0. ],
       [ 0. ,  0. ,  0. ,  0. ,  0. ,  0. ,  0. ,  0. ,  0. ,  0. ,  0. ,
         0. , -0.5,  0.5,  0. ,  0. ],
       [ 0. ,  0. ,  0. ,  0. ,  0. ,  0. ,  0. ,  0. ,  0. ,  0. ,  0. ,
         0. ,  0.5, -0.5,  0. ,  0. ],
       [ 0. ,  0. ,  0. ,  0. ,  0. ,  0. ,  0. ,  0. ,  0. ,  0. ,  0. ,
         0. ,  0. ,  0. ,  0. ,  0. ],
       [ 0. ,  0. ,  0. ,  0. ,  0. ,  0. ,  0. ,  0. ,  0. ,  0. ,  0. ,
         0. ,  0. ,  0. ,  0. ,  0. ]])]

ModeSampling:
False

MProcess \({\otimes }\) Gate -> MProcess

[15]:
# Prepare
mprocess_0 = generate_qoperation(mode="mprocess", name="x-type1", c_sys=c_sys_1)
gate_0 = generate_qoperation(mode="gate", name="x", c_sys=c_sys_0)

# Tensor product
result = tensor_product(mprocess_0, gate_0)
print(result)  # MProcess
Type:
MProcess

Dim:
4

HSs:
[array([[ 0.5,  0.5,  0. ,  0. ,  0. ,  0. ,  0. ,  0. ,  0. ,  0. ,  0. ,
         0. ,  0. ,  0. ,  0. ,  0. ],
       [ 0.5,  0.5,  0. ,  0. ,  0. ,  0. ,  0. ,  0. ,  0. ,  0. ,  0. ,
         0. ,  0. ,  0. ,  0. ,  0. ],
       [ 0. ,  0. ,  0. ,  0. ,  0. ,  0. ,  0. ,  0. ,  0. ,  0. ,  0. ,
         0. ,  0. ,  0. ,  0. ,  0. ],
       [ 0. ,  0. ,  0. ,  0. ,  0. ,  0. ,  0. ,  0. ,  0. ,  0. ,  0. ,
         0. ,  0. ,  0. ,  0. ,  0. ],
       [ 0. ,  0. ,  0. ,  0. ,  0.5,  0.5,  0. ,  0. ,  0. ,  0. ,  0. ,
         0. ,  0. ,  0. ,  0. ,  0. ],
       [ 0. ,  0. ,  0. ,  0. ,  0.5,  0.5,  0. ,  0. ,  0. ,  0. ,  0. ,
         0. ,  0. ,  0. ,  0. ,  0. ],
       [ 0. ,  0. ,  0. ,  0. ,  0. ,  0. ,  0. ,  0. ,  0. ,  0. ,  0. ,
         0. ,  0. ,  0. ,  0. ,  0. ],
       [ 0. ,  0. ,  0. ,  0. ,  0. ,  0. ,  0. ,  0. ,  0. ,  0. ,  0. ,
         0. ,  0. ,  0. ,  0. ,  0. ],
       [ 0. ,  0. ,  0. ,  0. ,  0. ,  0. ,  0. ,  0. , -0.5, -0.5,  0. ,
         0. ,  0. ,  0. ,  0. ,  0. ],
       [ 0. ,  0. ,  0. ,  0. ,  0. ,  0. ,  0. ,  0. , -0.5, -0.5,  0. ,
         0. ,  0. ,  0. ,  0. ,  0. ],
       [ 0. ,  0. ,  0. ,  0. ,  0. ,  0. ,  0. ,  0. ,  0. ,  0. ,  0. ,
         0. ,  0. ,  0. ,  0. ,  0. ],
       [ 0. ,  0. ,  0. ,  0. ,  0. ,  0. ,  0. ,  0. ,  0. ,  0. ,  0. ,
         0. ,  0. ,  0. ,  0. ,  0. ],
       [ 0. ,  0. ,  0. ,  0. ,  0. ,  0. ,  0. ,  0. ,  0. ,  0. ,  0. ,
         0. , -0.5, -0.5,  0. ,  0. ],
       [ 0. ,  0. ,  0. ,  0. ,  0. ,  0. ,  0. ,  0. ,  0. ,  0. ,  0. ,
         0. , -0.5, -0.5,  0. ,  0. ],
       [ 0. ,  0. ,  0. ,  0. ,  0. ,  0. ,  0. ,  0. ,  0. ,  0. ,  0. ,
         0. ,  0. ,  0. ,  0. ,  0. ],
       [ 0. ,  0. ,  0. ,  0. ,  0. ,  0. ,  0. ,  0. ,  0. ,  0. ,  0. ,
         0. ,  0. ,  0. ,  0. ,  0. ]]), array([[ 0.5, -0.5,  0. ,  0. ,  0. ,  0. ,  0. ,  0. ,  0. ,  0. ,  0. ,
         0. ,  0. ,  0. ,  0. ,  0. ],
       [-0.5,  0.5,  0. ,  0. ,  0. ,  0. ,  0. ,  0. ,  0. ,  0. ,  0. ,
         0. ,  0. ,  0. ,  0. ,  0. ],
       [ 0. ,  0. ,  0. ,  0. ,  0. ,  0. ,  0. ,  0. ,  0. ,  0. ,  0. ,
         0. ,  0. ,  0. ,  0. ,  0. ],
       [ 0. ,  0. ,  0. ,  0. ,  0. ,  0. ,  0. ,  0. ,  0. ,  0. ,  0. ,
         0. ,  0. ,  0. ,  0. ,  0. ],
       [ 0. ,  0. ,  0. ,  0. ,  0.5, -0.5,  0. ,  0. ,  0. ,  0. ,  0. ,
         0. ,  0. ,  0. ,  0. ,  0. ],
       [ 0. ,  0. ,  0. ,  0. , -0.5,  0.5,  0. ,  0. ,  0. ,  0. ,  0. ,
         0. ,  0. ,  0. ,  0. ,  0. ],
       [ 0. ,  0. ,  0. ,  0. ,  0. ,  0. ,  0. ,  0. ,  0. ,  0. ,  0. ,
         0. ,  0. ,  0. ,  0. ,  0. ],
       [ 0. ,  0. ,  0. ,  0. ,  0. ,  0. ,  0. ,  0. ,  0. ,  0. ,  0. ,
         0. ,  0. ,  0. ,  0. ,  0. ],
       [ 0. ,  0. ,  0. ,  0. ,  0. ,  0. ,  0. ,  0. , -0.5,  0.5,  0. ,
         0. ,  0. ,  0. ,  0. ,  0. ],
       [ 0. ,  0. ,  0. ,  0. ,  0. ,  0. ,  0. ,  0. ,  0.5, -0.5,  0. ,
         0. ,  0. ,  0. ,  0. ,  0. ],
       [ 0. ,  0. ,  0. ,  0. ,  0. ,  0. ,  0. ,  0. ,  0. ,  0. ,  0. ,
         0. ,  0. ,  0. ,  0. ,  0. ],
       [ 0. ,  0. ,  0. ,  0. ,  0. ,  0. ,  0. ,  0. ,  0. ,  0. ,  0. ,
         0. ,  0. ,  0. ,  0. ,  0. ],
       [ 0. ,  0. ,  0. ,  0. ,  0. ,  0. ,  0. ,  0. ,  0. ,  0. ,  0. ,
         0. , -0.5,  0.5,  0. ,  0. ],
       [ 0. ,  0. ,  0. ,  0. ,  0. ,  0. ,  0. ,  0. ,  0. ,  0. ,  0. ,
         0. ,  0.5, -0.5,  0. ,  0. ],
       [ 0. ,  0. ,  0. ,  0. ,  0. ,  0. ,  0. ,  0. ,  0. ,  0. ,  0. ,
         0. ,  0. ,  0. ,  0. ,  0. ],
       [ 0. ,  0. ,  0. ,  0. ,  0. ,  0. ,  0. ,  0. ,  0. ,  0. ,  0. ,
         0. ,  0. ,  0. ,  0. ,  0. ]])]

ModeSampling:
False

MProcess \({\otimes }\) MProcess -> MProcess

[16]:
# Prepare
mprocess_0 = generate_qoperation(mode="mprocess", name="x-type1", c_sys=c_sys_1)
mprocess_1 = generate_qoperation(mode="mprocess", name="y-type1", c_sys=c_sys_0)

# Tensor product
result = tensor_product(mprocess_0, mprocess_1)
print(result)  # MProcess
Type:
MProcess

Dim:
4

HSs:
[array([[0.25, 0.25, 0.  , 0.  , 0.  , 0.  , 0.  , 0.  , 0.25, 0.25, 0.  ,
        0.  , 0.  , 0.  , 0.  , 0.  ],
       [0.25, 0.25, 0.  , 0.  , 0.  , 0.  , 0.  , 0.  , 0.25, 0.25, 0.  ,
        0.  , 0.  , 0.  , 0.  , 0.  ],
       [0.  , 0.  , 0.  , 0.  , 0.  , 0.  , 0.  , 0.  , 0.  , 0.  , 0.  ,
        0.  , 0.  , 0.  , 0.  , 0.  ],
       [0.  , 0.  , 0.  , 0.  , 0.  , 0.  , 0.  , 0.  , 0.  , 0.  , 0.  ,
        0.  , 0.  , 0.  , 0.  , 0.  ],
       [0.  , 0.  , 0.  , 0.  , 0.  , 0.  , 0.  , 0.  , 0.  , 0.  , 0.  ,
        0.  , 0.  , 0.  , 0.  , 0.  ],
       [0.  , 0.  , 0.  , 0.  , 0.  , 0.  , 0.  , 0.  , 0.  , 0.  , 0.  ,
        0.  , 0.  , 0.  , 0.  , 0.  ],
       [0.  , 0.  , 0.  , 0.  , 0.  , 0.  , 0.  , 0.  , 0.  , 0.  , 0.  ,
        0.  , 0.  , 0.  , 0.  , 0.  ],
       [0.  , 0.  , 0.  , 0.  , 0.  , 0.  , 0.  , 0.  , 0.  , 0.  , 0.  ,
        0.  , 0.  , 0.  , 0.  , 0.  ],
       [0.25, 0.25, 0.  , 0.  , 0.  , 0.  , 0.  , 0.  , 0.25, 0.25, 0.  ,
        0.  , 0.  , 0.  , 0.  , 0.  ],
       [0.25, 0.25, 0.  , 0.  , 0.  , 0.  , 0.  , 0.  , 0.25, 0.25, 0.  ,
        0.  , 0.  , 0.  , 0.  , 0.  ],
       [0.  , 0.  , 0.  , 0.  , 0.  , 0.  , 0.  , 0.  , 0.  , 0.  , 0.  ,
        0.  , 0.  , 0.  , 0.  , 0.  ],
       [0.  , 0.  , 0.  , 0.  , 0.  , 0.  , 0.  , 0.  , 0.  , 0.  , 0.  ,
        0.  , 0.  , 0.  , 0.  , 0.  ],
       [0.  , 0.  , 0.  , 0.  , 0.  , 0.  , 0.  , 0.  , 0.  , 0.  , 0.  ,
        0.  , 0.  , 0.  , 0.  , 0.  ],
       [0.  , 0.  , 0.  , 0.  , 0.  , 0.  , 0.  , 0.  , 0.  , 0.  , 0.  ,
        0.  , 0.  , 0.  , 0.  , 0.  ],
       [0.  , 0.  , 0.  , 0.  , 0.  , 0.  , 0.  , 0.  , 0.  , 0.  , 0.  ,
        0.  , 0.  , 0.  , 0.  , 0.  ],
       [0.  , 0.  , 0.  , 0.  , 0.  , 0.  , 0.  , 0.  , 0.  , 0.  , 0.  ,
        0.  , 0.  , 0.  , 0.  , 0.  ]]), array([[ 0.25, -0.25,  0.  ,  0.  ,  0.  ,  0.  ,  0.  ,  0.  ,  0.25,
        -0.25,  0.  ,  0.  ,  0.  ,  0.  ,  0.  ,  0.  ],
       [-0.25,  0.25,  0.  ,  0.  ,  0.  ,  0.  ,  0.  ,  0.  , -0.25,
         0.25,  0.  ,  0.  ,  0.  ,  0.  ,  0.  ,  0.  ],
       [ 0.  ,  0.  ,  0.  ,  0.  ,  0.  ,  0.  ,  0.  ,  0.  ,  0.  ,
         0.  ,  0.  ,  0.  ,  0.  ,  0.  ,  0.  ,  0.  ],
       [ 0.  ,  0.  ,  0.  ,  0.  ,  0.  ,  0.  ,  0.  ,  0.  ,  0.  ,
         0.  ,  0.  ,  0.  ,  0.  ,  0.  ,  0.  ,  0.  ],
       [ 0.  ,  0.  ,  0.  ,  0.  ,  0.  ,  0.  ,  0.  ,  0.  ,  0.  ,
         0.  ,  0.  ,  0.  ,  0.  ,  0.  ,  0.  ,  0.  ],
       [ 0.  ,  0.  ,  0.  ,  0.  ,  0.  ,  0.  ,  0.  ,  0.  ,  0.  ,
         0.  ,  0.  ,  0.  ,  0.  ,  0.  ,  0.  ,  0.  ],
       [ 0.  ,  0.  ,  0.  ,  0.  ,  0.  ,  0.  ,  0.  ,  0.  ,  0.  ,
         0.  ,  0.  ,  0.  ,  0.  ,  0.  ,  0.  ,  0.  ],
       [ 0.  ,  0.  ,  0.  ,  0.  ,  0.  ,  0.  ,  0.  ,  0.  ,  0.  ,
         0.  ,  0.  ,  0.  ,  0.  ,  0.  ,  0.  ,  0.  ],
       [ 0.25, -0.25,  0.  ,  0.  ,  0.  ,  0.  ,  0.  ,  0.  ,  0.25,
        -0.25,  0.  ,  0.  ,  0.  ,  0.  ,  0.  ,  0.  ],
       [-0.25,  0.25,  0.  ,  0.  ,  0.  ,  0.  ,  0.  ,  0.  , -0.25,
         0.25,  0.  ,  0.  ,  0.  ,  0.  ,  0.  ,  0.  ],
       [ 0.  ,  0.  ,  0.  ,  0.  ,  0.  ,  0.  ,  0.  ,  0.  ,  0.  ,
         0.  ,  0.  ,  0.  ,  0.  ,  0.  ,  0.  ,  0.  ],
       [ 0.  ,  0.  ,  0.  ,  0.  ,  0.  ,  0.  ,  0.  ,  0.  ,  0.  ,
         0.  ,  0.  ,  0.  ,  0.  ,  0.  ,  0.  ,  0.  ],
       [ 0.  ,  0.  ,  0.  ,  0.  ,  0.  ,  0.  ,  0.  ,  0.  ,  0.  ,
         0.  ,  0.  ,  0.  ,  0.  ,  0.  ,  0.  ,  0.  ],
       [ 0.  ,  0.  ,  0.  ,  0.  ,  0.  ,  0.  ,  0.  ,  0.  ,  0.  ,
         0.  ,  0.  ,  0.  ,  0.  ,  0.  ,  0.  ,  0.  ],
       [ 0.  ,  0.  ,  0.  ,  0.  ,  0.  ,  0.  ,  0.  ,  0.  ,  0.  ,
         0.  ,  0.  ,  0.  ,  0.  ,  0.  ,  0.  ,  0.  ],
       [ 0.  ,  0.  ,  0.  ,  0.  ,  0.  ,  0.  ,  0.  ,  0.  ,  0.  ,
         0.  ,  0.  ,  0.  ,  0.  ,  0.  ,  0.  ,  0.  ]]), array([[ 0.25,  0.25,  0.  ,  0.  ,  0.  ,  0.  ,  0.  ,  0.  , -0.25,
        -0.25,  0.  ,  0.  ,  0.  ,  0.  ,  0.  ,  0.  ],
       [ 0.25,  0.25,  0.  ,  0.  ,  0.  ,  0.  ,  0.  ,  0.  , -0.25,
        -0.25,  0.  ,  0.  ,  0.  ,  0.  ,  0.  ,  0.  ],
       [ 0.  ,  0.  ,  0.  ,  0.  ,  0.  ,  0.  ,  0.  ,  0.  ,  0.  ,
         0.  ,  0.  ,  0.  ,  0.  ,  0.  ,  0.  ,  0.  ],
       [ 0.  ,  0.  ,  0.  ,  0.  ,  0.  ,  0.  ,  0.  ,  0.  ,  0.  ,
         0.  ,  0.  ,  0.  ,  0.  ,  0.  ,  0.  ,  0.  ],
       [ 0.  ,  0.  ,  0.  ,  0.  ,  0.  ,  0.  ,  0.  ,  0.  ,  0.  ,
         0.  ,  0.  ,  0.  ,  0.  ,  0.  ,  0.  ,  0.  ],
       [ 0.  ,  0.  ,  0.  ,  0.  ,  0.  ,  0.  ,  0.  ,  0.  ,  0.  ,
         0.  ,  0.  ,  0.  ,  0.  ,  0.  ,  0.  ,  0.  ],
       [ 0.  ,  0.  ,  0.  ,  0.  ,  0.  ,  0.  ,  0.  ,  0.  ,  0.  ,
         0.  ,  0.  ,  0.  ,  0.  ,  0.  ,  0.  ,  0.  ],
       [ 0.  ,  0.  ,  0.  ,  0.  ,  0.  ,  0.  ,  0.  ,  0.  ,  0.  ,
         0.  ,  0.  ,  0.  ,  0.  ,  0.  ,  0.  ,  0.  ],
       [-0.25, -0.25,  0.  ,  0.  ,  0.  ,  0.  ,  0.  ,  0.  ,  0.25,
         0.25,  0.  ,  0.  ,  0.  ,  0.  ,  0.  ,  0.  ],
       [-0.25, -0.25,  0.  ,  0.  ,  0.  ,  0.  ,  0.  ,  0.  ,  0.25,
         0.25,  0.  ,  0.  ,  0.  ,  0.  ,  0.  ,  0.  ],
       [ 0.  ,  0.  ,  0.  ,  0.  ,  0.  ,  0.  ,  0.  ,  0.  ,  0.  ,
         0.  ,  0.  ,  0.  ,  0.  ,  0.  ,  0.  ,  0.  ],
       [ 0.  ,  0.  ,  0.  ,  0.  ,  0.  ,  0.  ,  0.  ,  0.  ,  0.  ,
         0.  ,  0.  ,  0.  ,  0.  ,  0.  ,  0.  ,  0.  ],
       [ 0.  ,  0.  ,  0.  ,  0.  ,  0.  ,  0.  ,  0.  ,  0.  ,  0.  ,
         0.  ,  0.  ,  0.  ,  0.  ,  0.  ,  0.  ,  0.  ],
       [ 0.  ,  0.  ,  0.  ,  0.  ,  0.  ,  0.  ,  0.  ,  0.  ,  0.  ,
         0.  ,  0.  ,  0.  ,  0.  ,  0.  ,  0.  ,  0.  ],
       [ 0.  ,  0.  ,  0.  ,  0.  ,  0.  ,  0.  ,  0.  ,  0.  ,  0.  ,
         0.  ,  0.  ,  0.  ,  0.  ,  0.  ,  0.  ,  0.  ],
       [ 0.  ,  0.  ,  0.  ,  0.  ,  0.  ,  0.  ,  0.  ,  0.  ,  0.  ,
         0.  ,  0.  ,  0.  ,  0.  ,  0.  ,  0.  ,  0.  ]]), array([[ 0.25, -0.25,  0.  ,  0.  ,  0.  ,  0.  ,  0.  ,  0.  , -0.25,
         0.25,  0.  ,  0.  ,  0.  ,  0.  ,  0.  ,  0.  ],
       [-0.25,  0.25,  0.  ,  0.  ,  0.  ,  0.  ,  0.  ,  0.  ,  0.25,
        -0.25,  0.  ,  0.  ,  0.  ,  0.  ,  0.  ,  0.  ],
       [ 0.  ,  0.  ,  0.  ,  0.  ,  0.  ,  0.  ,  0.  ,  0.  ,  0.  ,
         0.  ,  0.  ,  0.  ,  0.  ,  0.  ,  0.  ,  0.  ],
       [ 0.  ,  0.  ,  0.  ,  0.  ,  0.  ,  0.  ,  0.  ,  0.  ,  0.  ,
         0.  ,  0.  ,  0.  ,  0.  ,  0.  ,  0.  ,  0.  ],
       [ 0.  ,  0.  ,  0.  ,  0.  ,  0.  ,  0.  ,  0.  ,  0.  ,  0.  ,
         0.  ,  0.  ,  0.  ,  0.  ,  0.  ,  0.  ,  0.  ],
       [ 0.  ,  0.  ,  0.  ,  0.  ,  0.  ,  0.  ,  0.  ,  0.  ,  0.  ,
         0.  ,  0.  ,  0.  ,  0.  ,  0.  ,  0.  ,  0.  ],
       [ 0.  ,  0.  ,  0.  ,  0.  ,  0.  ,  0.  ,  0.  ,  0.  ,  0.  ,
         0.  ,  0.  ,  0.  ,  0.  ,  0.  ,  0.  ,  0.  ],
       [ 0.  ,  0.  ,  0.  ,  0.  ,  0.  ,  0.  ,  0.  ,  0.  ,  0.  ,
         0.  ,  0.  ,  0.  ,  0.  ,  0.  ,  0.  ,  0.  ],
       [-0.25,  0.25,  0.  ,  0.  ,  0.  ,  0.  ,  0.  ,  0.  ,  0.25,
        -0.25,  0.  ,  0.  ,  0.  ,  0.  ,  0.  ,  0.  ],
       [ 0.25, -0.25,  0.  ,  0.  ,  0.  ,  0.  ,  0.  ,  0.  , -0.25,
         0.25,  0.  ,  0.  ,  0.  ,  0.  ,  0.  ,  0.  ],
       [ 0.  ,  0.  ,  0.  ,  0.  ,  0.  ,  0.  ,  0.  ,  0.  ,  0.  ,
         0.  ,  0.  ,  0.  ,  0.  ,  0.  ,  0.  ,  0.  ],
       [ 0.  ,  0.  ,  0.  ,  0.  ,  0.  ,  0.  ,  0.  ,  0.  ,  0.  ,
         0.  ,  0.  ,  0.  ,  0.  ,  0.  ,  0.  ,  0.  ],
       [ 0.  ,  0.  ,  0.  ,  0.  ,  0.  ,  0.  ,  0.  ,  0.  ,  0.  ,
         0.  ,  0.  ,  0.  ,  0.  ,  0.  ,  0.  ,  0.  ],
       [ 0.  ,  0.  ,  0.  ,  0.  ,  0.  ,  0.  ,  0.  ,  0.  ,  0.  ,
         0.  ,  0.  ,  0.  ,  0.  ,  0.  ,  0.  ,  0.  ],
       [ 0.  ,  0.  ,  0.  ,  0.  ,  0.  ,  0.  ,  0.  ,  0.  ,  0.  ,
         0.  ,  0.  ,  0.  ,  0.  ,  0.  ,  0.  ,  0.  ],
       [ 0.  ,  0.  ,  0.  ,  0.  ,  0.  ,  0.  ,  0.  ,  0.  ,  0.  ,
         0.  ,  0.  ,  0.  ,  0.  ,  0.  ,  0.  ,  0.  ]])]

ModeSampling:
False

MatrixBasis \({\otimes }\) MatrixBasis -> MatrixBasis

[17]:
from quara.objects.matrix_basis import get_pauli_basis

# Prepare
basis_0 = get_pauli_basis()
basis_1 = get_pauli_basis()

# Tensor product
result = tensor_product(basis_0, basis_1)
print(result)  # MatrixBasis
(array([[1.+0.j, 0.+0.j, 0.+0.j, 0.+0.j],
       [0.+0.j, 1.+0.j, 0.+0.j, 0.+0.j],
       [0.+0.j, 0.+0.j, 1.+0.j, 0.+0.j],
       [0.+0.j, 0.+0.j, 0.+0.j, 1.+0.j]]), array([[0.+0.j, 1.+0.j, 0.+0.j, 0.+0.j],
       [1.+0.j, 0.+0.j, 0.+0.j, 0.+0.j],
       [0.+0.j, 0.+0.j, 0.+0.j, 1.+0.j],
       [0.+0.j, 0.+0.j, 1.+0.j, 0.+0.j]]), array([[0.+0.j, 0.-1.j, 0.+0.j, 0.-0.j],
       [0.+1.j, 0.+0.j, 0.+0.j, 0.+0.j],
       [0.+0.j, 0.-0.j, 0.+0.j, 0.-1.j],
       [0.+0.j, 0.+0.j, 0.+1.j, 0.+0.j]]), array([[ 1.+0.j,  0.+0.j,  0.+0.j,  0.+0.j],
       [ 0.+0.j, -1.+0.j,  0.+0.j, -0.+0.j],
       [ 0.+0.j,  0.+0.j,  1.+0.j,  0.+0.j],
       [ 0.+0.j, -0.+0.j,  0.+0.j, -1.+0.j]]), array([[0.+0.j, 0.+0.j, 1.+0.j, 0.+0.j],
       [0.+0.j, 0.+0.j, 0.+0.j, 1.+0.j],
       [1.+0.j, 0.+0.j, 0.+0.j, 0.+0.j],
       [0.+0.j, 1.+0.j, 0.+0.j, 0.+0.j]]), array([[0.+0.j, 0.+0.j, 0.+0.j, 1.+0.j],
       [0.+0.j, 0.+0.j, 1.+0.j, 0.+0.j],
       [0.+0.j, 1.+0.j, 0.+0.j, 0.+0.j],
       [1.+0.j, 0.+0.j, 0.+0.j, 0.+0.j]]), array([[0.+0.j, 0.-0.j, 0.+0.j, 0.-1.j],
       [0.+0.j, 0.+0.j, 0.+1.j, 0.+0.j],
       [0.+0.j, 0.-1.j, 0.+0.j, 0.-0.j],
       [0.+1.j, 0.+0.j, 0.+0.j, 0.+0.j]]), array([[ 0.+0.j,  0.+0.j,  1.+0.j,  0.+0.j],
       [ 0.+0.j, -0.+0.j,  0.+0.j, -1.+0.j],
       [ 1.+0.j,  0.+0.j,  0.+0.j,  0.+0.j],
       [ 0.+0.j, -1.+0.j,  0.+0.j, -0.+0.j]]), array([[0.+0.j, 0.+0.j, 0.-1.j, 0.-0.j],
       [0.+0.j, 0.+0.j, 0.-0.j, 0.-1.j],
       [0.+1.j, 0.+0.j, 0.+0.j, 0.+0.j],
       [0.+0.j, 0.+1.j, 0.+0.j, 0.+0.j]]), array([[0.+0.j, 0.+0.j, 0.-0.j, 0.-1.j],
       [0.+0.j, 0.+0.j, 0.-1.j, 0.-0.j],
       [0.+0.j, 0.+1.j, 0.+0.j, 0.+0.j],
       [0.+1.j, 0.+0.j, 0.+0.j, 0.+0.j]]), array([[ 0.+0.j,  0.-0.j,  0.-0.j, -1.+0.j],
       [ 0.+0.j,  0.+0.j,  1.-0.j,  0.-0.j],
       [ 0.+0.j,  1.-0.j,  0.+0.j,  0.-0.j],
       [-1.+0.j,  0.+0.j,  0.+0.j,  0.+0.j]]), array([[ 0.+0.j,  0.+0.j,  0.-1.j,  0.-0.j],
       [ 0.+0.j, -0.+0.j,  0.-0.j,  0.+1.j],
       [ 0.+1.j,  0.+0.j,  0.+0.j,  0.+0.j],
       [ 0.+0.j, -0.-1.j,  0.+0.j, -0.+0.j]]), array([[ 1.+0.j,  0.+0.j,  0.+0.j,  0.+0.j],
       [ 0.+0.j,  1.+0.j,  0.+0.j,  0.+0.j],
       [ 0.+0.j,  0.+0.j, -1.+0.j, -0.+0.j],
       [ 0.+0.j,  0.+0.j, -0.+0.j, -1.+0.j]]), array([[ 0.+0.j,  1.+0.j,  0.+0.j,  0.+0.j],
       [ 1.+0.j,  0.+0.j,  0.+0.j,  0.+0.j],
       [ 0.+0.j,  0.+0.j, -0.+0.j, -1.+0.j],
       [ 0.+0.j,  0.+0.j, -1.+0.j, -0.+0.j]]), array([[ 0.+0.j,  0.-1.j,  0.+0.j,  0.-0.j],
       [ 0.+1.j,  0.+0.j,  0.+0.j,  0.+0.j],
       [ 0.+0.j,  0.-0.j, -0.+0.j,  0.+1.j],
       [ 0.+0.j,  0.+0.j, -0.-1.j, -0.+0.j]]), array([[ 1.+0.j,  0.+0.j,  0.+0.j,  0.+0.j],
       [ 0.+0.j, -1.+0.j,  0.+0.j, -0.+0.j],
       [ 0.+0.j,  0.+0.j, -1.+0.j, -0.+0.j],
       [ 0.+0.j, -0.+0.j, -0.+0.j,  1.-0.j]]))

Download Notebook