Performs (a^x) modulo N, for given integers a and N. The x (one value or a superposition) is given in the input register x.
After computation, the result (or results, when x stores superposition of multiple integers) is stored in register x1.
This method is a simple variant of ExpModulo(QuantumComputer, Register, Register, Register, Register, Register, Register, Int32, Int32). It allocates additional registers and frees them at the end. This variant has also requirements for the width of each given register but if they are not fullfilled, the exception is thrown.
Assembly: Quantum (in Quantum.dll) Version: 1.0.0.0 (1.0.0.0)
Parameters
- comp
- Type: Quantum QuantumComputer
The QuantumComputer instance.
- x
- Type: Quantum Register
Register for x. Its initial value could be any integer or a superposition of multiple integers. Its width must equal 2 * WIDTH (See Remarks).
- x1
- Type: Quantum Register
Output register. Its initial value must equal 1. Its width must equal WIDTH + 1 (See Remarks).
- valueA
- Type: System Int32
Integer value of a. (For computing (a^x) modulo N).
- valueN
- Type: System Int32
Integer value of N. (For computing (a^x) modulo N).
Usage Note
In Visual Basic and C#, you can call this method as an instance method on any object of type QuantumComputer. When you use instance method syntax to call this method, omit the first parameter. For more information, see Extension Methods (Visual Basic) or Extension Methods (C# Programming Guide).There are precise requirements for the width of each register given as argument. They result from a need for carry bits, overflow flag and a requirement for ensuring that the operation is inversible.
Let WIDTH equals the number of bits required to store N.
The width of x register must equal 2 * WIDTH. This value results from the requirements of Peter Shor's algorithm. Such a width ensures that the probability of getting the right result will be enough high.