diff options
Diffstat (limited to 'tester/main.c')
| -rw-r--r-- | tester/main.c | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/tester/main.c b/tester/main.c index cc32de1..e401288 100644 --- a/tester/main.c +++ b/tester/main.c @@ -1,5 +1,6 @@ #include <stdio.h> +#include "core/custom_gate.h" #include "core/gates.h" #include "core/quantum_components.h" #include "maths/complex.h" @@ -97,5 +98,24 @@ int main(void) psi_free_quantum_gate(&cnot); psi_free_quantum_register(®); + struct PsiCompositeGateOp bell_ops[] = { + { PSI_OP_H, { 0 }, 1 }, + { PSI_OP_CNOT, { 0, 1 }, 2 }, + }; + struct PsiCustomGate bell = psi_new_custom_gate_from_composite("BELL", 2, bell_ops, 2); + struct PsiQuantumGate bell_gate = psi_to_quantum_gate(bell); + + struct PsiQuantumRegister reg2 = psi_new_quantum_register("bell2", names, 2); + size_t t01b[] = { 0, 1 }; + psi_apply_gate(®2, bell_gate, t01b, 2); + + printf("custom = %s -> [%g, %g, %g, %g]\n", bell_gate.name, + reg2.state_vector.data[0].real, reg2.state_vector.data[1].real, + reg2.state_vector.data[2].real, reg2.state_vector.data[3].real); + + psi_free_custom_gate(&bell); + psi_free_quantum_gate(&bell_gate); + psi_free_quantum_register(®2); + return 0; } |
