aboutsummaryrefslogtreecommitdiff
path: root/include/core/kernel.h
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 /include/core/kernel.h
parent5cfc8515fdbe22214dc9840568ad41a73c105200 (diff)
add: scalar kernel engine with fusion
Diffstat (limited to 'include/core/kernel.h')
-rw-r--r--include/core/kernel.h46
1 files changed, 46 insertions, 0 deletions
diff --git a/include/core/kernel.h b/include/core/kernel.h
new file mode 100644
index 0000000..f827731
--- /dev/null
+++ b/include/core/kernel.h
@@ -0,0 +1,46 @@
+#pragma once
+
+#include <stdbool.h>
+#include <stddef.h>
+
+#include "maths/matrix.h"
+#include "maths/vector.h"
+
+enum PsiGateType
+{
+ PSI_GATE_TYPE_DIAGONAL,
+ PSI_GATE_TYPE_NON_DIAGONAL,
+ PSI_GATE_TYPE_CONTROLLED,
+};
+
+struct PsiKernel
+{
+ struct PsiMatrix matrix;
+ size_t *targets;
+ size_t target_count;
+ char *name;
+ enum PsiGateType gate_type;
+};
+
+struct PsiKernel psi_new_kernel(const char *name, struct PsiMatrix matrix, const size_t *targets, size_t target_count);
+struct PsiKernel psi_clone_kernel(struct PsiKernel kernel);
+void psi_free_kernel(struct PsiKernel *kernel);
+
+bool psi_kernels_share_qubits(struct PsiKernel a, struct PsiKernel b);
+bool psi_kernels_commute(struct PsiKernel a, struct PsiKernel b);
+bool psi_kernels_can_fuse(struct PsiKernel a, struct PsiKernel b);
+bool psi_fuse_kernels(struct PsiKernel a, struct PsiKernel b, struct PsiKernel *out);
+
+struct PsiKernelBatch
+{
+ struct PsiKernel *kernels;
+ size_t count;
+ size_t capacity;
+ size_t num_qubits;
+};
+
+struct PsiKernelBatch psi_new_kernel_batch(size_t num_qubits);
+void psi_free_kernel_batch(struct PsiKernelBatch *batch);
+void psi_add_kernel(struct PsiKernelBatch *batch, struct PsiKernel kernel);
+void psi_optimize_kernel_batch(struct PsiKernelBatch *batch);
+void psi_execute_kernel_batch(struct PsiKernelBatch batch, struct PsiVector *state);