mirror of
https://github.com/pgvector/pgvector.git
synced 2026-07-03 19:20:56 +08:00
Added concatenate operator for vectors
This commit is contained in:
@@ -905,6 +905,30 @@ halfvec_mul(PG_FUNCTION_ARGS)
|
||||
PG_RETURN_POINTER(result);
|
||||
}
|
||||
|
||||
/*
|
||||
* Concatenate half vectors
|
||||
*/
|
||||
PGDLLEXPORT PG_FUNCTION_INFO_V1(halfvec_concat);
|
||||
Datum
|
||||
halfvec_concat(PG_FUNCTION_ARGS)
|
||||
{
|
||||
HalfVector *a = PG_GETARG_HALFVEC_P(0);
|
||||
HalfVector *b = PG_GETARG_HALFVEC_P(1);
|
||||
HalfVector *result;
|
||||
int dim = a->dim + b->dim;
|
||||
|
||||
CheckDim(dim);
|
||||
result = InitHalfVector(dim);
|
||||
|
||||
for (int i = 0; i < a->dim; i++)
|
||||
result->x[i] = a->x[i];
|
||||
|
||||
for (int i = 0; i < b->dim; i++)
|
||||
result->x[i + a->dim] = b->x[i];
|
||||
|
||||
PG_RETURN_POINTER(result);
|
||||
}
|
||||
|
||||
/*
|
||||
* Quantize a half vector
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user