aboutsummaryrefslogtreecommitdiff
path: root/include/maths
diff options
context:
space:
mode:
Diffstat (limited to 'include/maths')
-rw-r--r--include/maths/complex.h4
-rw-r--r--include/maths/format.h6
-rw-r--r--include/maths/matrix.h8
-rw-r--r--include/maths/simd.h8
-rw-r--r--include/maths/vector.h22
5 files changed, 27 insertions, 21 deletions
diff --git a/include/maths/complex.h b/include/maths/complex.h
index c94f64a..d2782eb 100644
--- a/include/maths/complex.h
+++ b/include/maths/complex.h
@@ -2,8 +2,8 @@
struct PsiComplex
{
- double real;
- double imaginary;
+ double real;
+ double imaginary;
};
struct PsiComplex psi_new_complex(double real, double imaginary);
diff --git a/include/maths/format.h b/include/maths/format.h
index a11e3be..3b746a5 100644
--- a/include/maths/format.h
+++ b/include/maths/format.h
@@ -1,8 +1,14 @@
#pragma once
#include <stddef.h>
+#include <stdio.h>
#include "maths/complex.h"
+#include "maths/matrix.h"
+#include "maths/vector.h"
char* psi_format_amplitude(struct PsiComplex c, char* out, size_t cap);
char* psi_format_probability(double p, char* out, size_t cap);
+
+void psi_print_matrix(struct PsiMatrix m, FILE* out);
+void psi_print_vector(struct PsiVector v, FILE* out);
diff --git a/include/maths/matrix.h b/include/maths/matrix.h
index ff996d6..87bdcee 100644
--- a/include/maths/matrix.h
+++ b/include/maths/matrix.h
@@ -7,9 +7,9 @@
struct PsiMatrix
{
- struct PsiComplex* data;
- size_t rows;
- size_t cols;
+ struct PsiComplex* data;
+ size_t rows;
+ size_t cols;
};
struct PsiMatrix psi_new_matrix(size_t rows, size_t cols);
@@ -19,7 +19,7 @@ struct PsiMatrix psi_clone_matrix(struct PsiMatrix m);
void psi_free_matrix(struct PsiMatrix* m);
#define psi_matrix(rows, cols, ...) \
- psi_new_matrix_from((struct PsiComplex[]){ __VA_ARGS__ }, rows, cols)
+ psi_new_matrix_from((struct PsiComplex[]){ __VA_ARGS__ }, rows, cols)
struct PsiComplex psi_get_matrix(struct PsiMatrix m, size_t row, size_t col);
void psi_set_matrix(struct PsiMatrix* m, size_t row, size_t col, struct PsiComplex value);
diff --git a/include/maths/simd.h b/include/maths/simd.h
index 38d0171..5533913 100644
--- a/include/maths/simd.h
+++ b/include/maths/simd.h
@@ -6,10 +6,10 @@
enum PsiSimdCapability
{
- PSI_SIMD_NONE,
- PSI_SIMD_AVX2,
- PSI_SIMD_AVX512,
- PSI_SIMD_NEON,
+ PSI_SIMD_NONE,
+ PSI_SIMD_AVX2,
+ PSI_SIMD_AVX512,
+ PSI_SIMD_NEON,
};
enum PsiSimdCapability psi_detect_simd(void);
diff --git a/include/maths/vector.h b/include/maths/vector.h
index 0136715..a9ddf1f 100644
--- a/include/maths/vector.h
+++ b/include/maths/vector.h
@@ -6,15 +6,15 @@
enum PsiVectorKind
{
- PSI_ROW_VECTOR,
- PSI_COLUMN_VECTOR,
+ PSI_ROW_VECTOR,
+ PSI_COLUMN_VECTOR,
};
struct PsiVector
{
- struct PsiComplex* data;
- size_t size;
- enum PsiVectorKind kind;
+ struct PsiComplex* data;
+ size_t size;
+ enum PsiVectorKind kind;
};
struct PsiVector psi_new_vector(size_t size, enum PsiVectorKind kind);
@@ -24,13 +24,13 @@ struct PsiVector psi_clone_vector(struct PsiVector v);
void psi_free_vector(struct PsiVector* v);
#define psi_row_vector(...) \
- psi_new_vector_from((struct PsiComplex[]){ __VA_ARGS__ }, \
- sizeof((struct PsiComplex[]){ __VA_ARGS__ }) / sizeof(struct PsiComplex), \
- PSI_ROW_VECTOR)
+ psi_new_vector_from((struct PsiComplex[]){ __VA_ARGS__ }, \
+ sizeof((struct PsiComplex[]){ __VA_ARGS__ }) / sizeof(struct PsiComplex), \
+ PSI_ROW_VECTOR)
#define psi_column_vector(...) \
- psi_new_vector_from((struct PsiComplex[]){ __VA_ARGS__ }, \
- sizeof((struct PsiComplex[]){ __VA_ARGS__ }) / sizeof(struct PsiComplex), \
- PSI_COLUMN_VECTOR)
+ psi_new_vector_from((struct PsiComplex[]){ __VA_ARGS__ }, \
+ sizeof((struct PsiComplex[]){ __VA_ARGS__ }) / sizeof(struct PsiComplex), \
+ PSI_COLUMN_VECTOR)
struct PsiComplex psi_get_vector(struct PsiVector v, size_t index);
void psi_set_vector(struct PsiVector* v, size_t index, struct PsiComplex value);