1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
|
#pragma once
#include <stddef.h>
#include "core/quantum_components.h"
#include "maths/matrix.h"
enum PsiCompositeOp
{
PSI_OP_H,
PSI_OP_X,
PSI_OP_Y,
PSI_OP_Z,
PSI_OP_S,
PSI_OP_T,
PSI_OP_CNOT,
PSI_OP_CZ,
PSI_OP_SWAP,
PSI_OP_CCNOT,
PSI_OP_CSWAP,
};
struct PsiCompositeGateOp
{
enum PsiCompositeOp op;
size_t targets[3];
size_t target_count;
};
enum PsiCustomGateKind
{
PSI_CUSTOM_GATE_MATRIX,
PSI_CUSTOM_GATE_COMPOSITE,
};
struct PsiCustomGate
{
const char* name;
size_t num_qubits;
enum PsiCustomGateKind kind;
union
{
struct PsiMatrix matrix;
struct
{
struct PsiCompositeGateOp* ops;
size_t count;
} composite;
} definition;
};
struct PsiCustomGate psi_new_custom_gate_from_matrix(const char* name, struct PsiMatrix matrix);
struct PsiCustomGate psi_new_custom_gate_from_composite(const char* name, size_t num_qubits,
const struct PsiCompositeGateOp* ops,
size_t op_count);
void psi_free_custom_gate(struct PsiCustomGate* gate);
struct PsiQuantumGate psi_to_quantum_gate(struct PsiCustomGate gate);
|