mirror of
https://github.com/pgvector/pgvector.git
synced 2026-06-06 14:01:31 +08:00
24 lines
690 B
C
24 lines
690 B
C
#ifndef VECTOR_H
|
|
#define VECTOR_H
|
|
|
|
#define VECTOR_MAX_DIM 16000
|
|
|
|
#define VECTOR_SIZE(_dim) (offsetof(Vector, x) + sizeof(float)*(_dim))
|
|
#define DatumGetVector(x) ((Vector *) PG_DETOAST_DATUM(x))
|
|
#define PG_GETARG_VECTOR_P(x) DatumGetVector(PG_GETARG_DATUM(x))
|
|
#define PG_RETURN_VECTOR_P(x) PG_RETURN_POINTER(x)
|
|
|
|
typedef struct Vector
|
|
{
|
|
int32 vl_len_; /* varlena header (do not touch directly!) */
|
|
int16 dim; /* number of dimensions */
|
|
int16 unused; /* reserved for future use, always zero */
|
|
float x[FLEXIBLE_ARRAY_MEMBER];
|
|
} Vector;
|
|
|
|
Vector *InitVector(int dim);
|
|
void PrintVector(char *msg, Vector * vector);
|
|
int vector_cmp_internal(Vector * a, Vector * b);
|
|
|
|
#endif
|