将 n 个量子位应用于阿达玛门

Apply n qubits to a Hadamard Gate

首先对冗长的文字感到抱歉,我试图尽可能好地解释我的问题/误解。

对于我的学生项目,我必须实现一个简单的量子计算机的模拟。我现在想了解的是不同的盖茨是如何一点一点地应用于 n 量子比特的。

例如,一个量子位由两个复数 (a1, a2) 表示:

a1 |0> + a2 |1>

其中 a1 和 a2 是幅度 - 测量值的可能性。所有振幅的平方和总和必须始终等于 1。

所以我添加了一个 Hadamard 门,由其 2x2 矩阵表示

public void Hadamard(){
  gate.entries[0][0] = new ComplexNumber(1,0);
  gate.entries[0][1] = new ComplexNumber(1,0);
  gate.entries[1][0] = new ComplexNumber(1,0);
  gate.entries[1][1] = new ComplexNumber(-1,0);
  gate = (Matrix.scalarMultiplication(gate,Math.pow(2,-0.5)));
}

现在我将使用阿达玛门对 a1 和 a2 进行矩阵乘法。

所以我将寄存器设置为复数的二维数组,表示位的状态:

Register register = new Register(1); 

其中数字代表量子位的数量。我们只创建一行来保存我们所有的状态,列的索引等于状态。所以例如

[0][0] = |0> and [0][1] = |1> 

如果我们说 a1=1+0i 和 a2=0+0i,乘法将如下所示:

 cmplx1 = cmplxMultiplicate(gate.entries[0][0],a1);
 cmplx2 = cmplxMultiplicate(gate.entries[0][1],a2);
 cmplx3 = cmplxMultiplicate(gate.entries[1][0],a1);
 cmplx4 = cmplxMultiplciate(gate.entires[1][1],a2);
 register.entries[0][0] = cmplxAddition(cmplx1,cmplx2); // 0.70710678118
 register.entries[0][1] = cmplxAddition(cmplx3,cmplx4); // 0.70710678118

现在问题来了——如果我们有多个量子比特,我不知道该怎么做。例如在两个 Qubits 我会有

a1 |00> + a2 |01> + a3 |10> + a4 |11> 

四种不同的状态(或任何给定数字的 2^(numberOfQubits) 状态)。但是我现在如何将所有 4 个状态应用于我的 Hadamard Gate?我是否必须做出所有可能的结果,我将 a1 与每个值相乘,而不是 a2 等等?像这样:

 cmplx1 = cmplxMultiplicate(gate.entries[0][0],a1);
 cmplx2 = cmplxMultiplicate(gate.entries[0][1],a2);
 cmplx3 = cmplxMultiplicate(gate.entries[1][0],a1);
 cmplx4 = cmplxMultiplciate(gate.entries[1][1],a2);
 cmplx1 = cmplxMultiplicate(gate.entries[0][0],a1);
 cmplx2 = cmplxMultiplicate(gate.entries[0][1],a3);
 cmplx3 = cmplxMultiplicate(gate.entries[1][0],a1);
 cmplx4 = cmplxMultiplciate(gate.entries[1][1],a3);

我对此真的一无所知,我认为我的网站存在根本性的误解,这让事情对我来说变得如此复杂。

如果能帮助我走上正确的道路/轨道,我们将不胜感激。

非常感谢。

请注意 https://en.wikipedia.org/wiki/Hadamard_transform#Quantum_computing_applications 写道:

It is useful to note that computing the quantum Hadamard transform is simply the application of a Hadamard gate to each qubit individually because of the tensor product structure of the Hadamard transform.

因此只对一个门建模并实例化多次是有意义的。

But how could i now apply all 4 States to my Hadamard Gate ?

该门将应用于您的 2 量子位寄存器的所有 4 种状态。它将对成对的系数进行操作,即那些只有一位不同的系数,对应于应用门的位位置。

如果你想看大图,先对左边的量子位应用阿达玛运算

((|00> + |10>) <00| + (|00> - |10>) <10| + (|01> + |11>) <01| + (|01> - |11>) <11|) / sqrt(2)

然后到右边的量子位

((|00> + |01>) <00| + (|00> - |01>) <01| + (|10> + |11>) <10| + (|10> - |11>) <11|) / sqrt(2)

用你的系数顺序将其写成矩阵(第一步右矩阵和第二步左矩阵)你得到

  ⎛1  1  0  0⎞ ⎛1  0  1  0⎞     ⎛1  1  1  1⎞
  ⎜1 -1  0  0⎟ ⎜0  1  0  1⎟     ⎜1 -1  1 -1⎟
½ ⎜0  0  1  1⎟ ⎜1  0 -1  0⎟ = ½ ⎜1  1 -1 -1⎟
  ⎝0  0  1 -1⎠ ⎝0  1  0 -1⎠     ⎝1 -1 -1  1⎠

如果您愿意,可以用您的符号对乘积矩阵进行编码。但我宁愿找到一种方法来模拟将量子门操作应用于寄存器中的量子位子集,同时通过其他未修改的位。这可以通过扩展矩阵来实现,就像我在上面所做的那样,从传统的 2×2 变为我使用的 4×4。或者它可能是您评估矩阵乘以向量乘积的方式,以便更好地利用这些矩阵的稀疏性质。

看了你的代码,我有点担心你 register.entries[0][0] 中的两个索引。如果第一个索引应该是量子位的索引,第二个是该量子位的值,则表示不适合对纠缠情况进行建模。