diff options
| author | hachem <im@hachem.wtf> | 2026-09-10 20:20:14 +0200 |
|---|---|---|
| committer | hachem <im@hachem.wtf> | 2026-09-10 20:20:14 +0200 |
| commit | 7e093e9726d7017943f5b9c45470a2acd9024d70 (patch) | |
| tree | a4278203a826aba8ee1d3874e87dd84f7f36340c /tester | |
| parent | e75de99a233f446d7ee1d80d5b2af24e9edf822e (diff) | |
feat: rt execution engine and circuit compute
Diffstat (limited to 'tester')
| -rw-r--r-- | tester/main.c | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/tester/main.c b/tester/main.c index 57fc7ca..c8077e9 100644 --- a/tester/main.c +++ b/tester/main.c @@ -192,5 +192,22 @@ int main(void) psi_free_vector(&sast); psi_free_structure_aware_batch(&sa); + + struct PsiQuantumCircuit ghz = psi_new_quantum_circuit(3); + psi_apply_h(&ghz, 0); + psi_apply_cnot(&ghz, 0, 1); + psi_apply_cnot(&ghz, 1, 2); + + const struct PsiVector *ghz_state = psi_compute_circuit_with(&ghz, PSI_RUNTIME_STRUCTURE_AWARE); + printf("ghz ="); + for (size_t i = 0; i < ghz_state->size; i++) + printf(" %g", ghz_state->data[i].real); + printf("\n"); + + double probs[8]; + psi_circuit_probabilities(&ghz, probs); + printf("p(000) = %g, p(111) = %g\n", probs[0], probs[7]); + + psi_free_quantum_circuit(&ghz); } |
