/// <summary> /// Initializes a new instance of the <see cref="RotationZ"/> class. /// </summary> /// <param name="theta">The theta angle radians.</param> public RotationZ(double theta) : base("Rz") { Matrix = new Complex[, ] { { QCUtil.ComplexExp(-Complex.ImaginaryOne * theta / 2), 0 }, { 0, QCUtil.ComplexExp(Complex.ImaginaryOne * theta / 2) }, }; }
/// <summary> /// Initializes a new instance of the <see cref="PhaseShift"/> class. /// </summary> /// <param name="phase">The phase.</param> public PhaseShift(double phase) : base("S") { Matrix = new Complex[, ] { { 1, 0 }, { 0, QCUtil.ComplexExp(Complex.ImaginaryOne * phase) }, }; }
public QuantumFourierTransform(int registerLength = 1) : base("QFT") { int order = 1 << registerLength; Matrix = new ComplexMatrix(order, order); // Only n distinct coefficients are found in the quantum Fourier transform matrix Complex[] coefficients = new Complex[order]; for (int i = 0; i < order; i++) { coefficients[i] = QCUtil.ComplexExp(Complex.ImaginaryOne * 2 * Math.PI * i / order) / Math.Sqrt(order); } // Populate matrix for (int i = 0; i < order; i++) { for (int j = 0; j < order; j++) { Matrix[i, j] = coefficients[i * j % order]; } } }