The Plain Adder Network by Vedral et.al

Peter Belkner <pbelkner@snafu.de>

The following figure and it's caption is taken from quant-ph/9511018 (Vedral et.al.: Quantum networks for elementary arithmetic operations).

Plain adder network. In a first step, all the carries are calculated until the last carry gives the most significant digit of the result. Then all these operations apart from the last one are undone in reverse order, and the sum of the digits is performed correspondingly. Note the position of a thick black bar on the right or left hand side of basic carry and sum networks. A network with a bar on the left side represents the reversed sequence of elementary gates embeded in the same network with the bar on the right side.

1. The Plain Adder

void EqcsVedral::plain_adder(EqcsGateArray &a, int n)
{
    int a0 = 0;
    int b0 = n;
    int c0 = 2 * n;

    --n;

    for (int i = 0; i < n; ++i)
        carry(a, c0 + 1 + i, b0 + i, a0 + i, c0 + i);

    carry(a, b0 + n - 1, b0 + n, a0 + n, c0 + n);
    a.push_back(CNot(b0 + n, a0 + n));
    sum(a, b0 + n, a0 + n, c0 + n);

    for (int i = n - 1; i >= 0; --i) {
        rcarry(a, c0 + i + 1, b0 + i, a0 + i, c0 + i);
        sum(a, b0 + i, a0 + i, c0 + i);
    }
}
Listing 1: The plain adder.

2. The Plain Adder in Reversed Order

void EqcsVedral::rplain_adder(EqcsGateArray &a, int n)
{
    int a0 = 0;
    int b0 = n;
    int c0 = 2 * n;

    --n;

    for (int i = 0; i < n; ++i) {
        sum(a, b0 + i, a0 + i, c0 + i);
        rcarry(a, c0 + i + 1, b0 + i, a0 + i, c0 + i);
    }

    rsum(a, b0 + n, a0 + n, c0 + n);
    a.push_back(CNot(b0 + n, a0 + n));
    rcarry(a, b0 + n - 1, b0 + n, a0 + n, c0 + n);

    for (int i = n - 1; i >= 0; --i)
        rcarry(a, c0 + 1 + i, b0 + i, a0 + i, c0 + i);
}
Listing 2: The plain adder in reversed order.


Peter Belkner <pbelkner@snafu.de>