Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add state control functions #245

Merged
merged 2 commits into from
Oct 12, 2020

Conversation

corryvrequan
Copy link
Contributor

I've added three functions to control quantum state objects.

  1. tensor_product

We can generate a tensor product of two quantum states.

Usage

from qulacs.state import tensor_product
from qulacs import QuantumState

qs1 = QuantumState(3)
qs2 = QuantumState(5)
qs3 = tensor_product(qs1, qs2)
# qs3 is 8-qubit state
# np.kron(qs1.get_vector(), qs2.get_vector()) = tensor_product(qs1, qs2).get_vector()
  1. permutate_qubit

We can permutate the order of qubits in a quantum state.

Usage

from qulacs.state import permutate_qubit
from qulacs import QuantumState

qs1 = QuantumState(3)
qs2 = permutate_qubit(qs1, [1,0,2])
# qs1's [0,1,2,3,4,5,6,7]-th elements are ordered as [0,2,1,3,4,6,5,7]
  1. drop_qubit

We can drop a set of qubits from a quantum state with projecting to a given subspace.

Usage

from qulacs.state import drop_qubit
from qulacs import QuantumState

qs1 = QuantumState(3)
drop_index = [2,1]
projection = [0,1]
qs2 = drop_qubit(qs1, drop_index, projection)
# 2nd and 1st qubits are removed, and projected to a subspace of |01*> (rightmost is 0-th qubit).
# Thus, qs2[0] = qs1[2], qs2[1] = qs1[3]

@corryvrequan
Copy link
Contributor Author

Since this feature works correctly and seems correct as far as I tested. So let me merge it and fix bugs if there are.

@corryvrequan corryvrequan merged commit e4c5737 into qulacs:dev Oct 12, 2020
kotamanegi pushed a commit to kotamanegi/qulacs that referenced this pull request Jun 14, 2022
…uming-ci

Restrict trigger to run Windows and wheel build CI
m-ymzk pushed a commit to m-ymzk/qulacs that referenced this pull request Apr 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant