Skip to main content
Functions:
NameDescription
unitary[Qmod core-library function].
multiply[Qmod core-library function].
multiply_constant[Qmod core-library function].
canonical_add[Qmod core-library function].
canonical_add_constant[Qmod core-library function].
canonical_multiply[Qmod core-library function].
canonical_multiply_constant[Qmod core-library function].
canonical_square[Qmod core-library function].

unitary

unitary(
elements: CArray[CArray[CReal]],
target: QArray[QBit, Literal[‘log(elements[0].len, 2)’]]
) -> None
[Qmod core-library function] Applies a unitary matrix on a quantum state. Parameters:
NameTypeDescriptionDefault
elementsCArray[CArray[CReal]]A 2d array of complex numbers representing the unitary matrix. This matrix must be unitary.required
targetQArray[QBit, Literal['log(elements[0].len, 2)']]The quantum state to apply the unitary on. Should be of corresponding size.required

multiply

multiply(
left: Const[QNum],
right: Const[QNum],
result: Output[QNum]
) -> None
[Qmod core-library function] Multiplies two quantum numeric variables: leftrightleftrightleftright \left|\text{left}\right\rangle \left|\text{right}\right\rangle \mapsto \left|\text{left}\right\rangle \left|\text{right}\right\rangle \left|\text{left} \cdot \text{right} \right\rangle Parameters:
NameTypeDescriptionDefault
leftConst[QNum]The first argument for the multiplication.required
rightConst[QNum]The second argument for the multiplication.required
resultOutput[QNum]The quantum variable to hold the multiplication result.required

multiply_constant

multiply_constant(
left: CReal,
right: Const[QNum],
result: Output[QNum]
) -> None
[Qmod core-library function] Multiplies a quantum numeric variable with a constant: rightrightleftright \left|\text{right}\right\rangle \mapsto \left|\text{right}\right\rangle \left|\text{left} \cdot \text{right} \right\rangle Parameters:
NameTypeDescriptionDefault
leftCRealThe constant argument for the multiplication.required
rightConst[QNum]The variable argument for the multiplication.required
resultOutput[QNum]The quantum variable to hold the multiplication result.required

canonical_add

canonical_add(
left: Const[QArray],
extend_left: CBool,
right: QArray
) -> None
[Qmod core-library function] Adds two quantum variables representing integers (signed or unsigned), storing the result in the second variable (in-place): leftrightleft(right+left)mod2right.size \left|\text{left}\right\rangle \left|\text{right}\right\rangle \mapsto \left|\text{left}\right\rangle \left|\left(\text{right} + \text{left}\right) \bmod 2^{\text{right.size}} \right\rangle Parameters:
NameTypeDescriptionDefault
leftConst[QArray]The out-of-place argument for the addition.required
extend_leftCBoolWhether to sign-extend the left argument.required
rightQArrayThe in-place argument for the addition, holds the final result.required

canonical_add_constant

canonical_add_constant(
left: CInt,
right: QArray
) -> None
[Qmod core-library function] Adds an integer constant to a quantum variable representing an integer (signed or unsigned): right(right+left)mod2right.size \left|\text{right}\right\rangle \mapsto \left|\left(\text{right} + \text{left}\right) \bmod 2^{\text{right.size}} \right\rangle Parameters:
NameTypeDescriptionDefault
leftCIntThe constant argument for the addition.required
rightQArrayThe quantum argument for the addition, holds the final result.required

canonical_multiply

canonical_multiply(
left: Const[QArray],
extend_left: CBool,
right: Const[QArray],
extend_right: CBool,
result: QArray,
trim_result_lsb: CBool
) -> None
[Qmod core-library function] Multiplies two quantum variables representing integers (signed or unsigned) into the result variable which is assumed to start in the 0|0\rangle state. If trim_result_lsb is False, applies the transformation: leftright0leftright(leftright)mod2result.size \left|\text{left}\right\rangle \left|\text{right}\right\rangle \left|0\right\rangle \mapsto \left|\text{left}\right\rangle \left|\text{right}\right\rangle \left|\left( \text{left} \cdot \text{right} \right) \bmod 2^{\text{result.size}} \right\rangle If trim_result_lsb is True, the function avoids computing the result’s LSB and applies the transformation: leftright0leftright(leftright)1mod2result.size \left|\text{left}\right\rangle \left|\text{right}\right\rangle \left|0\right\rangle \mapsto \left|\text{left}\right\rangle \left|\text{right}\right\rangle \left|\left( \text{left} \cdot \text{right} \right) \gg 1 \bmod 2^{\text{result.size}} \right\rangle Parameters:
NameTypeDescriptionDefault
leftConst[QArray]The first argument for the multiplication.required
extend_leftCBoolWhether to sign-extend the left argument.required
rightConst[QArray]The second argument for the multiplication.required
extend_rightCBoolWhether to sign-extend the right argument.required
resultQArrayThe quantum variable to hold the multiplication result.required
trim_result_lsbCBoolWhether to avoid computing the result’s LSB.required

canonical_multiply_constant

canonical_multiply_constant(
left: CInt,
right: Const[QArray],
extend_right: CBool,
result: QArray,
trim_result_lsb: CBool
) -> None
[Qmod core-library function] Multiplies a quantum variable representing an integer (signed or unsigned) with a constant, into the result variable which is assumed to start in the 0|0\rangle state. If trim_result_lsb is False, applies the transformation: right0right(leftright)mod2result.size \left|\text{right}\right\rangle \left|0\right\rangle \mapsto \left|\text{right}\right\rangle \left|\left( \text{left} \cdot \text{right} \right) \bmod 2^{\text{result.size}} \right\rangle If trim_result_lsb is True, the function avoids computing the result’s LSB and applies the transformation: right0right(leftright)1mod2result.size \left|\text{right}\right\rangle \left|0\right\rangle \mapsto \left|\text{right}\right\rangle \left|\left( \text{left} \cdot \text{right} \right) \gg 1 \bmod 2^{\text{result.size}} \right\rangle Parameters:
NameTypeDescriptionDefault
leftCIntThe constant argument for the multiplication.required
rightConst[QArray]The variable argument for the multiplication.required
extend_rightCBoolWhether to sign-extend the right argument.required
resultQArrayThe quantum variable to hold the multiplication result.required
trim_result_lsbCBoolWhether to avoid computing the result’s LSB.required

canonical_square

canonical_square(
arg: Const[QArray],
extend_arg: CBool,
result: QArray,
trim_result_lsb: CBool
) -> None
[Qmod core-library function] Squares a quantum variable representing an integer (signed or unsigned), into the result variable which is assumed to start in the 0|0\rangle state. If trim_result_lsb is False, applies the transformation: arg0arg(arg2)mod2result.size \left|\text{arg}\right\rangle \left|0\right\rangle \mapsto \left|\text{arg}\right\rangle \left|\left( \text{arg}^{2}\right) \bmod 2^{\text{result.size}} \right\rangle If trim_result_lsb is True, the function avoids computing the result’s LSB and applies the transformation: arg0arg(arg2)1mod2result.size \left|\text{arg}\right\rangle \left|0\right\rangle \mapsto \left|\text{arg}\right\rangle \left|\left( \text{arg}^{2} \right) \gg 1 \bmod 2^{\text{result.size}} \right\rangle Parameters:
NameTypeDescriptionDefault
argConst[QArray]The argument to square.required
extend_argCBoolWhether to sign-extend the argument.required
resultQArrayThe quantum variable to hold the squared result.required
trim_result_lsbCBoolWhether to avoid computing the result’s LSB.required