aboutsummaryrefslogtreecommitdiff
path: root/tester
diff options
context:
space:
mode:
authorhachem <im@hachem.wtf>2026-09-06 23:13:30 +0200
committerhachem <im@hachem.wtf>2026-09-06 23:13:30 +0200
commitaaea07b252f3a668d2b321765770f09759365356 (patch)
tree694942bf328f37b88d97a49782a63c1f3ef890f8 /tester
parent5cfc8515fdbe22214dc9840568ad41a73c105200 (diff)
add: scalar kernel engine with fusion
Diffstat (limited to 'tester')
-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);
}