Esempio n. 1
0
 public Qubit(double zeroProbability)
 {
     if (zeroProbability < 0 || zeroProbability > 1)
     {
         throw new ArgumentException("probability should be between 0 and 1 included");
     }
     State         = new QuantumState(zeroProbability, 1 - zeroProbability);
     StateOperator = StateOperator.FromQuantumState(State);
 }
Esempio n. 2
0
 public void ReduceStateOperator(int qubitIndex, StateOperator compositeOperator)
 {
     if (compositeOperator.Size == 1)
     {
         StateOperator = new StateOperator(compositeOperator);
     }
     else
     {
         List <int> discardedQubits = new List <int>();
         for (int i = 0; i < compositeOperator.Size; i++)
         {
             if (i != qubitIndex)
             {
                 discardedQubits.Add(i);
             }
         }
         StateOperator = compositeOperator.PartialTrace(discardedQubits);
     }
 }
Esempio n. 3
0
 public Qubit(Complex zeroAmplitude, Complex oneAmplitude)
 {
     State         = new QuantumState(zeroAmplitude, oneAmplitude);
     StateOperator = StateOperator.FromQuantumState(State);
 }
Esempio n. 4
0
 public Qubit(Qubit qubit)
 {
     State         = new QuantumState(qubit.State);
     StateOperator = new StateOperator(qubit.StateOperator);
 }