Ejemplo n.º 1
0
 public virtual void ControlledR(IQArray <Qubit> controls, Pauli axis, double theta, Qubit qubit)
 {
     throw new NotImplementedException();
 }
Ejemplo n.º 2
0
 public virtual void RFrac(Pauli axis, long numerator, long power, Qubit qubit)
 {
     throw new NotImplementedException();
 }
Ejemplo n.º 3
0
 public virtual void ControlledRFrac(IQArray <Qubit> controls, Pauli axis, long numerator, long power, Qubit qubit)
 {
     throw new UnsupportedOperationException();
 }
Ejemplo n.º 4
0
 public virtual void R(Pauli axis, double theta, Qubit qubit)
 {
     throw new NotImplementedException();
 }
Ejemplo n.º 5
0
 Qubit?f(Pauli p, Qubit q) =>
 p switch
 {
Ejemplo n.º 6
0
 /// <summary>
 /// The implementation of the controlled adjoint specialization of the operation.
 /// For the Toffoli simulator *only*, the controlled specialization is self-adjoint.
 /// </summary>
 void IIntrinsicR.ControlledAdjointBody(IQArray <Qubit> controls, Pauli pauli, double angle, Qubit target) => ((IIntrinsicR)this).ControlledBody(controls, pauli, angle, target);
Ejemplo n.º 7
0
 public virtual void R__ControlledAdjointBody(IQArray <Qubit> controls, Pauli pauli, double angle, Qubit target)
 {
     R__ControlledBody(controls, pauli, -angle, target);
 }
Ejemplo n.º 8
0
 private void Clifford(long id, Pauli pauli, Qubit target)
 {
     DoPrimitiveOperation(PrimitiveOperationsGroups.QubitClifford, new QArray <Qubit>(target));
 }
Ejemplo n.º 9
0
 private static extern void MCR(uint id, Pauli basis, double angle, uint count, uint[] ctrls, uint qubit);
Ejemplo n.º 10
0
 public virtual void R__AdjointBody(Pauli pauli, double angle, Qubit target)
 {
     R__Body(pauli, -angle, target);
 }
Ejemplo n.º 11
0
 /// <summary>
 /// The implementation of the adjoint specialization of the operation.
 /// For the Toffoli simulator *only*, this operation is self-adjoint.
 /// </summary>
 public void R__AdjointBody(Pauli pauli, double angle, Qubit target) => R__Body(pauli, angle, target);
Ejemplo n.º 12
0
 public override void RFrac(Pauli axis, long numerator, long power, Qubit qubit) =>
 throw new UnsupportedOperationException("This operation is not supported in the CHP Stabilizer formalism.");
Ejemplo n.º 13
0
 public override void R(Pauli axis, double theta, Qubit qubit) =>
 throw new UnsupportedOperationException("This operation is not supported in the CHP Stabilizer formalism.");
Ejemplo n.º 14
0
 public virtual void ControlledRFrac(IQArray <Qubit> controls, Pauli axis, long numerator, long power, Qubit qubit)
 {
     throw new NotImplementedException();
 }
Ejemplo n.º 15
0
 public virtual void R(Pauli axis, double theta, Qubit qubit)
 {
     throw new UnsupportedOperationException();
 }
Ejemplo n.º 16
0
        internal static (bool, bool) CheckRotation(Pauli axis, long numerator, long power)
        {
            // Rotations around X of odd multiples of pi/2 are X (up to global phase).
            // Rotations around any axis of multiples of pi are I (up to global phase).
            // Rotations of any angle around I are I.
            // Rotations around any axis of even multiples of pi are safe to control.
            // The angle here is pi*numerator/(2^power).

            // The sign of the numerator doesn't matter.
            // Reduce the numerator and power in case there are factors of 2 in the numerator.
            numerator = Abs(numerator);
            while ((power > 0) && (numerator % 2 == 0))
            {
                numerator /= 2;
                power--;
            }

            bool equivalentToX = false;
            bool safeToControl = false;

            // If the power < 0, we're guaranteed to be a multiple of 2*pi, so exactly the identity.
            if (power < 0)
            {
                equivalentToX = false;
                safeToControl = true;
            }
            // If power > 1, then we're an odd multiple of pi/4, so illegal
            else if (power > 1)
            {
                throw new InvalidOperationException($"The Toffoli simulator can only perform rotations of multiples of pi/2.");
            }
            // If power == 1, then we're an odd multiple of pi/2, so X if the axis is X,
            // I if the axis is I, and illegal otherwise.
            else if (power == 1)
            {
                switch (axis)
                {
                case Pauli.PauliI:
                    equivalentToX = false;
                    safeToControl = false;
                    break;

                case Pauli.PauliX:
                    equivalentToX = true;
                    safeToControl = false;
                    break;

                case Pauli.PauliY:
                case Pauli.PauliZ:
                    throw new InvalidOperationException($"The Toffoli simulator can only perform non-identity rotations around the X axis.");
                }
            }
            // If power == 0, then we're a multiple of pi, possible an even multiple.
            else
            {
                equivalentToX = false;
                safeToControl = (numerator % 2 == 0);
            }

            return(equivalentToX, safeToControl);
        }
Ejemplo n.º 17
0
 public virtual void ControlledR(IQArray <Qubit> controls, Pauli axis, double theta, Qubit qubit)
 {
     throw new UnsupportedOperationException();
 }
Ejemplo n.º 18
0
 private void R(Pauli pauli, double angle, Qubit target)
 {
     DoPrimitiveOperation(PrimitiveOperationsGroups.R, new QArray <Qubit>(target));
 }
Ejemplo n.º 19
0
 public virtual void RFrac(Pauli axis, long numerator, long power, Qubit qubit)
 {
     throw new UnsupportedOperationException();
 }
Ejemplo n.º 20
0
 private static extern void R(uint id, Pauli basis, double angle, uint qubit);
Ejemplo n.º 21
0
 /// <summary>
 /// The implementation of the adjoint specialization of the operation.
 /// For the Toffoli simulator *only*, this operation is self-adjoint.
 /// </summary>
 void IIntrinsicR.AdjointBody(Pauli pauli, double angle, Qubit target) => ((IIntrinsicR)this).Body(pauli, angle, target);