MultiplyAndAddByModularInteger operation

Warning

This documentation refers to the Classic QDK, which has been replaced by the Modern QDK.

Please see https://aka.ms/qdk.api for the API documentation for the Modern QDK.

Namespace: Microsoft.Quantum.Arithmetic

Package: Microsoft.Quantum.Standard

Performs a modular multiply-and-add by integer constants on a qubit register.

operation MultiplyAndAddByModularInteger (constMultiplier : Int, modulus : Int, multiplicand : Microsoft.Quantum.Arithmetic.LittleEndian, summand : Microsoft.Quantum.Arithmetic.LittleEndian) : Unit is Adj + Ctl

Description

Implements the map $$ \begin{align} \ket{x} \ket{b} \mapsto \ket{x} \ket{(b + a \cdot x) \operatorname{mod} N} \end{align} $$ for a given modulus $N$, constant multiplier $a$, and summand $b$.

Input

constMultiplier : Int

An integer $a$ by which multiplicand is being multiplied. Must be between 0 and modulus-1, inclusive.

modulus : Int

The modulus $N$ which addition and multiplication is taken with respect to.

multiplicand : LittleEndian

A quantum register representing an unsigned integer whose value, multiplied by constMultiplier, is to be added to each basis state label of summand. Corresponds to the register in state $\ket{x}$ above.

summand : LittleEndian

A quantum register representing an unsigned integer to use as the target for this operation. Corresponds to the register initially in $\ket{b}$ above.

Output : Unit

Remarks

See Also