aboutsummaryrefslogtreecommitdiff
path: root/tester/simd.c
diff options
context:
space:
mode:
Diffstat (limited to 'tester/simd.c')
-rw-r--r--tester/simd.c98
1 files changed, 49 insertions, 49 deletions
diff --git a/tester/simd.c b/tester/simd.c
index bea2f06..cfc38e2 100644
--- a/tester/simd.c
+++ b/tester/simd.c
@@ -6,58 +6,58 @@ static const double R2 = 0.7071067811865476;
void run_simd_tests(void)
{
- psi_test_section("SIMD single-qubit kernels");
+ psi_test_section("SIMD single-qubit kernels");
- printf(" detected: %s\n", psi_simd_name(psi_detect_simd()));
+ printf(" detected: %s\n", psi_simd_name(psi_detect_simd()));
- struct PsiComplex h[2][2] = {
- { psi_new_complex(R2, 0.0), psi_new_complex(R2, 0.0) },
- { psi_new_complex(R2, 0.0), psi_new_complex(-R2, 0.0) },
- };
+ struct PsiComplex h[2][2] = {
+ { psi_new_complex(R2, 0.0), psi_new_complex(R2, 0.0) },
+ { psi_new_complex(R2, 0.0), psi_new_complex(-R2, 0.0) },
+ };
- struct PsiComplex two[4] = {
- psi_new_complex(1.0, 0.0),
- psi_new_complex(0.0, 0.0),
- psi_new_complex(0.0, 0.0),
- psi_new_complex(0.0, 0.0),
- };
- psi_apply_single_qubit_gate_simd(two, h, 0, 2);
- struct PsiComplex two_exp[] = {
- psi_new_complex(R2, 0.0),
- psi_new_complex(0.0, 0.0),
- psi_new_complex(R2, 0.0),
- psi_new_complex(0.0, 0.0),
- };
- psi_test_check(psi_amps_match(two, two_exp, 4), "SIMD H on q0 of |00>");
+ struct PsiComplex two[4] = {
+ psi_new_complex(1.0, 0.0),
+ psi_new_complex(0.0, 0.0),
+ psi_new_complex(0.0, 0.0),
+ psi_new_complex(0.0, 0.0),
+ };
+ psi_apply_single_qubit_gate_simd(two, h, 0, 2);
+ struct PsiComplex two_exp[] = {
+ psi_new_complex(R2, 0.0),
+ psi_new_complex(0.0, 0.0),
+ psi_new_complex(R2, 0.0),
+ psi_new_complex(0.0, 0.0),
+ };
+ psi_test_check(psi_amps_match(two, two_exp, 4), "SIMD H on q0 of |00>");
- struct PsiComplex three[8];
- for (size_t i = 0; i < 8; i++)
- three[i] = psi_new_complex(0.0, 0.0);
- three[0] = psi_new_complex(1.0, 0.0);
- psi_apply_single_qubit_gate_simd(three, h, 0, 3);
- struct PsiComplex three_exp[8];
- for (size_t i = 0; i < 8; i++)
- three_exp[i] = psi_new_complex(0.0, 0.0);
- three_exp[0] = psi_new_complex(R2, 0.0);
- three_exp[4] = psi_new_complex(R2, 0.0);
- psi_test_check(psi_amps_match(three, three_exp, 8), "SIMD H on q0 of |000> (chunked)");
+ struct PsiComplex three[8];
+ for (size_t i = 0; i < 8; i++)
+ three[i] = psi_new_complex(0.0, 0.0);
+ three[0] = psi_new_complex(1.0, 0.0);
+ psi_apply_single_qubit_gate_simd(three, h, 0, 3);
+ struct PsiComplex three_exp[8];
+ for (size_t i = 0; i < 8; i++)
+ three_exp[i] = psi_new_complex(0.0, 0.0);
+ three_exp[0] = psi_new_complex(R2, 0.0);
+ three_exp[4] = psi_new_complex(R2, 0.0);
+ psi_test_check(psi_amps_match(three, three_exp, 8), "SIMD H on q0 of |000> (chunked)");
- struct PsiComplex x[2][2] = {
- { psi_new_complex(0.0, 0.0), psi_new_complex(1.0, 0.0) },
- { psi_new_complex(1.0, 0.0), psi_new_complex(0.0, 0.0) },
- };
- struct PsiComplex flip[4] = {
- psi_new_complex(1.0, 0.0),
- psi_new_complex(0.0, 0.0),
- psi_new_complex(0.0, 0.0),
- psi_new_complex(0.0, 0.0),
- };
- psi_apply_single_qubit_gate_simd(flip, x, 1, 2);
- struct PsiComplex flip_exp[] = {
- psi_new_complex(0.0, 0.0),
- psi_new_complex(1.0, 0.0),
- psi_new_complex(0.0, 0.0),
- psi_new_complex(0.0, 0.0),
- };
- psi_test_check(psi_amps_match(flip, flip_exp, 4), "SIMD X on q1 of |00> = |01>");
+ struct PsiComplex x[2][2] = {
+ { psi_new_complex(0.0, 0.0), psi_new_complex(1.0, 0.0) },
+ { psi_new_complex(1.0, 0.0), psi_new_complex(0.0, 0.0) },
+ };
+ struct PsiComplex flip[4] = {
+ psi_new_complex(1.0, 0.0),
+ psi_new_complex(0.0, 0.0),
+ psi_new_complex(0.0, 0.0),
+ psi_new_complex(0.0, 0.0),
+ };
+ psi_apply_single_qubit_gate_simd(flip, x, 1, 2);
+ struct PsiComplex flip_exp[] = {
+ psi_new_complex(0.0, 0.0),
+ psi_new_complex(1.0, 0.0),
+ psi_new_complex(0.0, 0.0),
+ psi_new_complex(0.0, 0.0),
+ };
+ psi_test_check(psi_amps_match(flip, flip_exp, 4), "SIMD X on q1 of |00> = |01>");
}