aboutsummaryrefslogtreecommitdiff
path: root/tester/main.c
diff options
context:
space:
mode:
Diffstat (limited to 'tester/main.c')
-rw-r--r--tester/main.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/tester/main.c b/tester/main.c
index 194fc77..020b230 100644
--- a/tester/main.c
+++ b/tester/main.c
@@ -147,5 +147,24 @@ int main(void)
}
psi_free_quantum_circuit(&circuit);
+
+ size_t kt[] = { 0 };
+ struct PsiKernelBatch batch = psi_new_kernel_batch(1);
+ struct PsiQuantumGate hg = psi_hadamard_gate();
+ psi_add_kernel(&batch, psi_new_kernel("H", psi_clone_matrix(hg.matrix), kt, 1));
+ psi_add_kernel(&batch, psi_new_kernel("H", psi_clone_matrix(hg.matrix), kt, 1));
+ psi_free_quantum_gate(&hg);
+
+ size_t before = batch.count;
+ psi_optimize_kernel_batch(&batch);
+
+ struct PsiVector state = psi_new_state_0();
+ psi_execute_kernel_batch(batch, &state);
+
+ printf("kernels = %zu -> %zu (fused), HH|0> = [%g, %g]\n",
+ before, batch.count, state.data[0].real, state.data[1].real);
+
+ psi_free_vector(&state);
+ psi_free_kernel_batch(&batch);
}