-
Notifications
You must be signed in to change notification settings - Fork 0
/
tinyv.h
46 lines (36 loc) · 889 Bytes
/
tinyv.h
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
#ifndef TINYV_H
#define TINYV_H
#include <stdlib.h>
struct FileHeader
{
int version;
int num_vectors;
};
struct VectorHeader
{
int vector_size;
};
typedef struct
{
size_t current_size;
size_t max_size;
float *data;
} Vector;
typedef struct
{
Vector **data;
size_t current_size;
size_t max_size;
} VectorStore;
Vector *create_vector(size_t initial_size);
void resize_vector(Vector *v);
void add_to_vector(Vector *v, int value);
void free_vector(Vector *v);
VectorStore *create_vectorstore(size_t initial_size);
void resize_vectorstore(VectorStore *vs);
void add_to_vectorstore(VectorStore *vs, Vector *v);
VectorStore *read_vectorstore_from_file(const char *filename);
void write_vectorstore_to_file(VectorStore *vs, const char *filename);
void free_vectorstore(VectorStore *vs);
float dot_product(Vector *v1, Vector *v2);
#endif /* TINYV_H */