Hello Mohan,
You won’t be able to use superposed inputs directly on a back-end. However, the Simulator
class can do what you’re asking for. It can compute probabilities and evolutions on all pure and mixed states.
Here is an example code to get you on track:
from perceval import Unitary, Simulator, SLOSBackend, StateVector, Matrix
input_state = StateVector([1, 0, 1, 0]) + StateVector([0, 1, 0, 1]) # Create a superposed state
circuit = Unitary(Matrix.random_unitary(4)) # Create any circuit
sim = Simulator(SLOSBackend()) # Use SLOS back-end in a Simulator
sim.set_circuit(circuit)
results = sim.probs(input_state) # Run your simulation
print(input_state)
print(results)
Outputs:
0.707*|1,0,1,0>+0.707*|0,1,0,1>
{
|2,0,0,0>: 0.04473871713436912
|0,1,0,1>: 0.031961342520798616
|1,0,0,1>: 0.05329046508196197
|1,1,0,0>: 0.10222962070815501
|0,0,2,0>: 0.024612467813262918
|1,0,1,0>: 0.2550024799411448
|0,2,0,0>: 0.1258443072321124
|0,1,1,0>: 0.11412042230682148
|0,0,1,1>: 0.08165216212550813
|0,0,0,2>: 0.16654801513586562
}
To go further and discover all Simulator
features, you may read: Simulator — perceval v0.13 documentation
Best wishes,
Eric