qrisp.inpl_adder_test#

inpl_adder_test(inpl_adder)[source]#

This function runs tests on a desired inplace addition function. An inplace addition function is a function mapping (a, b) to (a, a+b), where a is a QuantumVariable, list[Qubit] or an integer and b is either a QuantumVariable or a list[Qubit].

Parameters:
inpl_addercallable

A quantum inplace addition function that can either act on single QuantumVariables or on lists of Qubits by adding the first one to the second.

Returns:
Bool:

True if all tests are passed, else False/ Exceptions.

Examples

We test the built-in Cuccaro adder:

from qrisp import cuccaro_adder, inpl_adder_test

inpl_adder_test(cuccaro_adder)
print("The cuccaro adder passed the tests without errors.")

And now a new user-defined qcla adder:

from qrisp import inpl_adder_test, qcla

qcla_2_0 = lambda x, y : qcla(x, y, radix_base = 2, radix_exponent = 0)
inpl_adder_test(qcla_2_0)
print("The qcla_2_0 adder passed the tests without errors.")